r8564: Sometimes we're too dumb to live... Fix samr calls where we were
[Samba/nascimento.git] / source / rpc_parse / parse_samr.c
blob6b0193c6e46e58a402c000b58b8541c1185e09e6
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, uint32 server_role)
569 u_7->server_role = server_role;
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("server_role", ps, depth, &u_7->server_role))
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, uint32 server_role)
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->server_role = server_role;
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("server_role ", ps, depth, &u_2->server_role))
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,
1520 uint32 num_entries, uint32 start_idx,
1521 struct samr_displayentry *entries)
1523 uint32 i;
1525 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1527 if (num_entries==0)
1528 return NT_STATUS_OK;
1530 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1531 if (*sam == NULL)
1532 return NT_STATUS_NO_MEMORY;
1534 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1535 if ((*sam)->sam == NULL)
1536 return NT_STATUS_NO_MEMORY;
1538 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1539 if ((*sam)->str == NULL)
1540 return NT_STATUS_NO_MEMORY;
1542 for (i = 0; i < num_entries ; i++) {
1543 init_unistr2(&(*sam)->str[i].uni_acct_name,
1544 entries[i].account_name, UNI_FLAGS_NONE);
1545 init_unistr2(&(*sam)->str[i].uni_full_name,
1546 entries[i].fullname, UNI_FLAGS_NONE);
1547 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1548 entries[i].description, UNI_FLAGS_NONE);
1550 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1551 &(*sam)->str[i].uni_acct_name,
1552 &(*sam)->str[i].uni_full_name,
1553 &(*sam)->str[i].uni_acct_desc,
1554 entries[i].rid, entries[i].acct_flags);
1557 return NT_STATUS_OK;
1560 /*******************************************************************
1561 reads or writes a structure.
1562 ********************************************************************/
1564 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1565 uint32 num_entries,
1566 prs_struct *ps, int depth)
1568 uint32 i;
1570 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1571 depth++;
1573 if(!prs_align(ps))
1574 return False;
1576 if (UNMARSHALLING(ps) && num_entries > 0) {
1578 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1579 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1580 return False;
1583 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1584 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1585 return False;
1589 for (i = 0; i < num_entries; i++) {
1590 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1591 return False;
1594 for (i = 0; i < num_entries; i++) {
1595 if(!sam_io_sam_str1("", &sam->str[i],
1596 sam->sam[i].hdr_acct_name.buffer,
1597 sam->sam[i].hdr_user_name.buffer,
1598 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1599 return False;
1602 return True;
1605 /*******************************************************************
1606 inits a SAM_DISPINFO_2 structure.
1607 ********************************************************************/
1609 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1610 uint32 num_entries, uint32 start_idx,
1611 struct samr_displayentry *entries)
1613 uint32 i;
1615 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1617 if (num_entries==0)
1618 return NT_STATUS_OK;
1620 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1621 if (*sam == NULL)
1622 return NT_STATUS_NO_MEMORY;
1624 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1625 if ((*sam)->sam == NULL)
1626 return NT_STATUS_NO_MEMORY;
1628 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1629 if ((*sam)->str == NULL)
1630 return NT_STATUS_NO_MEMORY;
1632 for (i = 0; i < num_entries; i++) {
1633 init_unistr2(&(*sam)->str[i].uni_srv_name,
1634 entries[i].account_name, UNI_FLAGS_NONE);
1635 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1636 entries[i].description, UNI_FLAGS_NONE);
1638 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1639 &(*sam)->str[i].uni_srv_name,
1640 &(*sam)->str[i].uni_srv_desc,
1641 entries[i].rid, entries[i].acct_flags);
1644 return NT_STATUS_OK;
1647 /*******************************************************************
1648 reads or writes a structure.
1649 ********************************************************************/
1651 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1652 uint32 num_entries,
1653 prs_struct *ps, int depth)
1655 uint32 i;
1657 if (sam == NULL)
1658 return False;
1660 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1661 depth++;
1663 if(!prs_align(ps))
1664 return False;
1666 if (UNMARSHALLING(ps) && num_entries > 0) {
1668 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1669 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1670 return False;
1673 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1674 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1675 return False;
1679 for (i = 0; i < num_entries; i++) {
1680 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1681 return False;
1684 for (i = 0; i < num_entries; i++) {
1685 if(!sam_io_sam_str2("", &sam->str[i],
1686 sam->sam[i].hdr_srv_name.buffer,
1687 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1688 return False;
1691 return True;
1694 /*******************************************************************
1695 inits a SAM_DISPINFO_3 structure.
1696 ********************************************************************/
1698 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1699 uint32 num_entries, uint32 start_idx,
1700 struct samr_displayentry *entries)
1702 uint32 i;
1704 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1706 if (num_entries==0)
1707 return NT_STATUS_OK;
1709 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1710 if (*sam == NULL)
1711 return NT_STATUS_NO_MEMORY;
1713 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1714 return NT_STATUS_NO_MEMORY;
1716 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1717 return NT_STATUS_NO_MEMORY;
1719 for (i = 0; i < num_entries; i++) {
1720 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1722 init_unistr2(&(*sam)->str[i].uni_grp_name,
1723 entries[i].account_name, UNI_FLAGS_NONE);
1724 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1725 entries[i].description, UNI_FLAGS_NONE);
1727 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1728 &(*sam)->str[i].uni_grp_name,
1729 &(*sam)->str[i].uni_grp_desc,
1730 entries[i].rid);
1733 return NT_STATUS_OK;
1736 /*******************************************************************
1737 reads or writes a structure.
1738 ********************************************************************/
1740 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1741 uint32 num_entries,
1742 prs_struct *ps, int depth)
1744 uint32 i;
1746 if (sam == NULL)
1747 return False;
1749 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1750 depth++;
1752 if(!prs_align(ps))
1753 return False;
1755 if (UNMARSHALLING(ps) && num_entries > 0) {
1757 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1758 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1759 return False;
1762 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1763 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1764 return False;
1768 for (i = 0; i < num_entries; i++) {
1769 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1770 return False;
1773 for (i = 0; i < num_entries; i++) {
1774 if(!sam_io_sam_str3("", &sam->str[i],
1775 sam->sam[i].hdr_grp_name.buffer,
1776 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1777 return False;
1780 return True;
1783 /*******************************************************************
1784 inits a SAM_DISPINFO_4 structure.
1785 ********************************************************************/
1787 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1788 uint32 num_entries, uint32 start_idx,
1789 struct samr_displayentry *entries)
1791 uint32 i;
1793 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1795 if (num_entries==0)
1796 return NT_STATUS_OK;
1798 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1799 if (*sam == NULL)
1800 return NT_STATUS_NO_MEMORY;
1802 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1803 if ((*sam)->sam == NULL)
1804 return NT_STATUS_NO_MEMORY;
1806 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1807 if ((*sam)->str == NULL)
1808 return NT_STATUS_NO_MEMORY;
1810 for (i = 0; i < num_entries; i++) {
1811 size_t len_sam_name = strlen(entries[i].account_name);
1813 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1815 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1816 len_sam_name);
1818 init_string2(&(*sam)->str[i].acct_name,
1819 entries[i].account_name, len_sam_name+1,
1820 len_sam_name);
1823 return NT_STATUS_OK;
1826 /*******************************************************************
1827 reads or writes a structure.
1828 ********************************************************************/
1830 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1831 uint32 num_entries,
1832 prs_struct *ps, int depth)
1834 uint32 i;
1836 if (sam == NULL)
1837 return False;
1839 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1840 depth++;
1842 if(!prs_align(ps))
1843 return False;
1845 if (UNMARSHALLING(ps) && num_entries > 0) {
1847 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1848 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1849 return False;
1852 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1853 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1854 return False;
1858 for (i = 0; i < num_entries; i++) {
1859 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1860 return False;
1863 for (i = 0; i < num_entries; i++) {
1864 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1865 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1866 return False;
1869 return True;
1872 /*******************************************************************
1873 inits a SAM_DISPINFO_5 structure.
1874 ********************************************************************/
1876 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1877 uint32 num_entries, uint32 start_idx,
1878 struct samr_displayentry *entries)
1880 uint32 len_sam_name;
1881 uint32 i;
1883 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1885 if (num_entries==0)
1886 return NT_STATUS_OK;
1888 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1889 if (*sam == NULL)
1890 return NT_STATUS_NO_MEMORY;
1892 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1893 return NT_STATUS_NO_MEMORY;
1895 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1896 return NT_STATUS_NO_MEMORY;
1898 for (i = 0; i < num_entries; i++) {
1899 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1901 len_sam_name = strlen(entries[i].account_name);
1903 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1904 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1905 len_sam_name+1, len_sam_name);
1908 return NT_STATUS_OK;
1911 /*******************************************************************
1912 reads or writes a structure.
1913 ********************************************************************/
1915 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1916 uint32 num_entries,
1917 prs_struct *ps, int depth)
1919 uint32 i;
1921 if (sam == NULL)
1922 return False;
1924 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1925 depth++;
1927 if(!prs_align(ps))
1928 return False;
1930 if (UNMARSHALLING(ps) && num_entries > 0) {
1932 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1933 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1934 return False;
1937 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1938 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1939 return False;
1943 for (i = 0; i < num_entries; i++) {
1944 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1945 return False;
1948 for (i = 0; i < num_entries; i++) {
1949 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1950 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1951 return False;
1954 return True;
1957 /*******************************************************************
1958 inits a SAMR_R_QUERY_DISPINFO structure.
1959 ********************************************************************/
1961 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1962 uint32 num_entries, uint32 total_size, uint32 data_size,
1963 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1964 NTSTATUS status)
1966 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1968 r_u->total_size = total_size;
1970 r_u->data_size = data_size;
1972 r_u->switch_level = switch_level;
1973 r_u->num_entries = num_entries;
1975 if (num_entries==0)
1976 r_u->ptr_entries = 0;
1977 else
1978 r_u->ptr_entries = 1;
1980 r_u->num_entries2 = num_entries;
1981 r_u->ctr = ctr;
1983 r_u->status = status;
1986 /*******************************************************************
1987 reads or writes a structure.
1988 ********************************************************************/
1990 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1991 prs_struct *ps, int depth)
1993 if (r_u == NULL)
1994 return False;
1996 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
1997 depth++;
1999 if(!prs_align(ps))
2000 return False;
2002 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2003 return False;
2004 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2005 return False;
2006 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2007 return False;
2008 if(!prs_align(ps))
2009 return False;
2011 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2012 return False;
2013 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2014 return False;
2016 if (r_u->ptr_entries==0) {
2017 if(!prs_align(ps))
2018 return False;
2019 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2020 return False;
2022 return True;
2025 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2026 return False;
2028 switch (r_u->switch_level) {
2029 case 0x1:
2030 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2031 r_u->num_entries, ps, depth))
2032 return False;
2033 break;
2034 case 0x2:
2035 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2036 r_u->num_entries, ps, depth))
2037 return False;
2038 break;
2039 case 0x3:
2040 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2041 r_u->num_entries, ps, depth))
2042 return False;
2043 break;
2044 case 0x4:
2045 if(!sam_io_sam_dispinfo_4("user list",
2046 r_u->ctr->sam.info4,
2047 r_u->num_entries, ps, depth))
2048 return False;
2049 break;
2050 case 0x5:
2051 if(!sam_io_sam_dispinfo_5("group list",
2052 r_u->ctr->sam.info5,
2053 r_u->num_entries, ps, depth))
2054 return False;
2055 break;
2056 default:
2057 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2058 break;
2061 if(!prs_align(ps))
2062 return False;
2063 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2064 return False;
2066 return True;
2069 /*******************************************************************
2070 inits a SAMR_Q_OPEN_GROUP structure.
2071 ********************************************************************/
2073 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2074 POLICY_HND *hnd,
2075 uint32 access_mask, uint32 rid)
2077 DEBUG(5, ("init_samr_q_open_group\n"));
2079 q_c->domain_pol = *hnd;
2080 q_c->access_mask = access_mask;
2081 q_c->rid_group = rid;
2084 /*******************************************************************
2085 reads or writes a structure.
2086 ********************************************************************/
2088 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2089 prs_struct *ps, int depth)
2091 if (q_u == NULL)
2092 return False;
2094 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2095 depth++;
2097 if(!prs_align(ps))
2098 return False;
2100 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2101 return False;
2103 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2104 return False;
2105 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2106 return False;
2108 return True;
2111 /*******************************************************************
2112 reads or writes a structure.
2113 ********************************************************************/
2115 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2116 prs_struct *ps, int depth)
2118 if (r_u == NULL)
2119 return False;
2121 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2122 depth++;
2124 if(!prs_align(ps))
2125 return False;
2127 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2128 return False;
2130 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2131 return False;
2133 return True;
2136 /*******************************************************************
2137 inits a GROUP_INFO1 structure.
2138 ********************************************************************/
2140 void init_samr_group_info1(GROUP_INFO1 * gr1,
2141 char *acct_name, char *acct_desc,
2142 uint32 num_members)
2144 DEBUG(5, ("init_samr_group_info1\n"));
2146 gr1->unknown_1 = 0x3;
2147 gr1->num_members = num_members;
2149 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2150 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2151 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2152 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2155 /*******************************************************************
2156 reads or writes a structure.
2157 ********************************************************************/
2159 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2160 prs_struct *ps, int depth)
2162 uint16 dummy = 1;
2164 if (gr1 == NULL)
2165 return False;
2167 prs_debug(ps, depth, desc, "samr_io_group_info1");
2168 depth++;
2170 if(!prs_uint16("level", ps, depth, &dummy))
2171 return False;
2173 if(!prs_align(ps))
2174 return False;
2176 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2177 return False;
2179 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2180 return False;
2181 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2182 return False;
2184 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2185 return False;
2187 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2188 gr1->hdr_acct_name.buffer, ps, depth))
2189 return False;
2191 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2192 gr1->hdr_acct_desc.buffer, ps, depth))
2193 return False;
2195 return True;
2198 /*******************************************************************
2199 inits a GROUP_INFO2 structure.
2200 ********************************************************************/
2202 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2204 DEBUG(5, ("init_samr_group_info2\n"));
2206 gr2->level = 2;
2207 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2208 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2211 /*******************************************************************
2212 reads or writes a structure.
2213 ********************************************************************/
2215 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2217 if (gr2 == NULL)
2218 return False;
2220 prs_debug(ps, depth, desc, "samr_io_group_info2");
2221 depth++;
2223 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2224 return False;
2226 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2227 return False;
2228 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2229 gr2->hdr_acct_name.buffer, ps, depth))
2230 return False;
2232 return True;
2235 /*******************************************************************
2236 inits a GROUP_INFO3 structure.
2237 ********************************************************************/
2239 void init_samr_group_info3(GROUP_INFO3 *gr3)
2241 DEBUG(5, ("init_samr_group_info3\n"));
2243 gr3->unknown_1 = 0x3;
2246 /*******************************************************************
2247 reads or writes a structure.
2248 ********************************************************************/
2250 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2252 if (gr3 == NULL)
2253 return False;
2255 prs_debug(ps, depth, desc, "samr_io_group_info3");
2256 depth++;
2258 if(!prs_align(ps))
2259 return False;
2261 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2262 return False;
2264 return True;
2267 /*******************************************************************
2268 inits a GROUP_INFO4 structure.
2269 ********************************************************************/
2271 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2273 DEBUG(5, ("init_samr_group_info4\n"));
2275 gr4->level = 4;
2276 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2277 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2280 /*******************************************************************
2281 reads or writes a structure.
2282 ********************************************************************/
2284 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2285 prs_struct *ps, int depth)
2287 if (gr4 == NULL)
2288 return False;
2290 prs_debug(ps, depth, desc, "samr_io_group_info4");
2291 depth++;
2293 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2294 return False;
2295 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2296 return False;
2297 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2298 gr4->hdr_acct_desc.buffer, ps, depth))
2299 return False;
2301 return True;
2304 /*******************************************************************
2305 reads or writes a structure.
2306 ********************************************************************/
2308 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2309 prs_struct *ps, int depth)
2311 if (UNMARSHALLING(ps))
2312 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2314 if (*ctr == NULL)
2315 return False;
2317 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2318 depth++;
2320 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2321 return False;
2323 switch ((*ctr)->switch_value1) {
2324 case 1:
2325 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2326 return False;
2327 break;
2328 case 2:
2329 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2330 return False;
2331 break;
2332 case 3:
2333 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2334 return False;
2335 break;
2336 case 4:
2337 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2338 return False;
2339 break;
2340 default:
2341 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2342 break;
2345 return True;
2348 /*******************************************************************
2349 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2350 ********************************************************************/
2352 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2353 POLICY_HND *pol, const char *acct_desc,
2354 uint32 access_mask)
2356 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2358 q_e->pol = *pol;
2360 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2361 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2363 q_e->access_mask = access_mask;
2366 /*******************************************************************
2367 reads or writes a structure.
2368 ********************************************************************/
2370 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2371 prs_struct *ps, int depth)
2373 if (q_e == NULL)
2374 return False;
2376 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2377 depth++;
2379 if(!prs_align(ps))
2380 return False;
2382 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2383 return False;
2385 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2386 return False;
2387 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2388 q_e->hdr_acct_desc.buffer, ps, depth))
2389 return False;
2391 if(!prs_align(ps))
2392 return False;
2393 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2394 return False;
2396 return True;
2399 /*******************************************************************
2400 reads or writes a structure.
2401 ********************************************************************/
2403 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2404 prs_struct *ps, int depth)
2406 if (r_u == NULL)
2407 return False;
2409 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2410 depth++;
2412 if(!prs_align(ps))
2413 return False;
2415 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2416 return False;
2418 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2419 return False;
2420 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2421 return False;
2423 return True;
2426 /*******************************************************************
2427 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2428 ********************************************************************/
2430 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2431 POLICY_HND *hnd)
2433 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2435 q_c->group_pol = *hnd;
2438 /*******************************************************************
2439 reads or writes a structure.
2440 ********************************************************************/
2442 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2443 prs_struct *ps, int depth)
2445 if (q_u == NULL)
2446 return False;
2448 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2449 depth++;
2451 if(!prs_align(ps))
2452 return False;
2454 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2455 return False;
2457 return True;
2460 /*******************************************************************
2461 reads or writes a structure.
2462 ********************************************************************/
2464 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2465 prs_struct *ps, int depth)
2467 if (r_u == NULL)
2468 return False;
2470 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2471 depth++;
2473 if(!prs_align(ps))
2474 return False;
2476 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2477 return False;
2479 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2480 return False;
2482 return True;
2485 /*******************************************************************
2486 inits a SAMR_Q_DEL_GROUPMEM structure.
2487 ********************************************************************/
2489 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2490 POLICY_HND *pol, uint32 rid)
2492 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2494 q_e->pol = *pol;
2495 q_e->rid = rid;
2498 /*******************************************************************
2499 reads or writes a structure.
2500 ********************************************************************/
2502 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2503 prs_struct *ps, int depth)
2505 if (q_e == NULL)
2506 return False;
2508 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2509 depth++;
2511 if(!prs_align(ps))
2512 return False;
2514 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2515 return False;
2517 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2518 return False;
2520 return True;
2523 /*******************************************************************
2524 inits a SAMR_R_DEL_GROUPMEM structure.
2525 ********************************************************************/
2527 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2528 NTSTATUS status)
2530 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2532 r_u->status = status;
2535 /*******************************************************************
2536 reads or writes a structure.
2537 ********************************************************************/
2539 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2540 prs_struct *ps, int depth)
2542 if (r_u == NULL)
2543 return False;
2545 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2546 depth++;
2548 if(!prs_align(ps))
2549 return False;
2551 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2552 return False;
2554 return True;
2557 /*******************************************************************
2558 inits a SAMR_Q_ADD_GROUPMEM structure.
2559 ********************************************************************/
2561 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2562 POLICY_HND *pol, uint32 rid)
2564 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2566 q_e->pol = *pol;
2567 q_e->rid = rid;
2568 q_e->unknown = 0x0005;
2571 /*******************************************************************
2572 reads or writes a structure.
2573 ********************************************************************/
2575 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2576 prs_struct *ps, int depth)
2578 if (q_e == NULL)
2579 return False;
2581 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2582 depth++;
2584 if(!prs_align(ps))
2585 return False;
2587 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2588 return False;
2590 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2591 return False;
2592 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2593 return False;
2595 return True;
2598 /*******************************************************************
2599 inits a SAMR_R_ADD_GROUPMEM structure.
2600 ********************************************************************/
2602 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2603 NTSTATUS status)
2605 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2607 r_u->status = status;
2610 /*******************************************************************
2611 reads or writes a structure.
2612 ********************************************************************/
2614 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2615 prs_struct *ps, int depth)
2617 if (r_u == NULL)
2618 return False;
2620 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2621 depth++;
2623 if(!prs_align(ps))
2624 return False;
2626 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2627 return False;
2629 return True;
2632 /*******************************************************************
2633 inits a SAMR_Q_SET_GROUPINFO structure.
2634 ********************************************************************/
2636 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2637 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2639 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2641 q_e->pol = *pol;
2642 q_e->ctr = ctr;
2645 /*******************************************************************
2646 reads or writes a structure.
2647 ********************************************************************/
2649 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2650 prs_struct *ps, int depth)
2652 if (q_e == NULL)
2653 return False;
2655 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2656 depth++;
2658 if(!prs_align(ps))
2659 return False;
2661 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2662 return False;
2664 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2665 return False;
2667 return True;
2670 /*******************************************************************
2671 inits a SAMR_R_SET_GROUPINFO structure.
2672 ********************************************************************/
2674 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2676 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2678 r_u->status = status;
2681 /*******************************************************************
2682 reads or writes a structure.
2683 ********************************************************************/
2685 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2686 prs_struct *ps, int depth)
2688 if (r_u == NULL)
2689 return False;
2691 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2692 depth++;
2694 if(!prs_align(ps))
2695 return False;
2697 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2698 return False;
2700 return True;
2703 /*******************************************************************
2704 inits a SAMR_Q_QUERY_GROUPINFO structure.
2705 ********************************************************************/
2707 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2708 POLICY_HND *pol, uint16 switch_level)
2710 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2712 q_e->pol = *pol;
2714 q_e->switch_level = switch_level;
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2722 prs_struct *ps, int depth)
2724 if (q_e == NULL)
2725 return False;
2727 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2728 depth++;
2730 if(!prs_align(ps))
2731 return False;
2733 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2734 return False;
2736 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2737 return False;
2739 return True;
2742 /*******************************************************************
2743 inits a SAMR_R_QUERY_GROUPINFO structure.
2744 ********************************************************************/
2746 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2747 GROUP_INFO_CTR * ctr, NTSTATUS status)
2749 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2751 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2752 r_u->ctr = ctr;
2753 r_u->status = status;
2756 /*******************************************************************
2757 reads or writes a structure.
2758 ********************************************************************/
2760 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2761 prs_struct *ps, int depth)
2763 if (r_u == NULL)
2764 return False;
2766 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2767 depth++;
2769 if(!prs_align(ps))
2770 return False;
2772 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2773 return False;
2775 if (r_u->ptr != 0) {
2776 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2777 return False;
2780 if(!prs_align(ps))
2781 return False;
2782 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2783 return False;
2785 return True;
2788 /*******************************************************************
2789 inits a SAMR_Q_QUERY_GROUPMEM structure.
2790 ********************************************************************/
2792 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2794 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2796 q_c->group_pol = *hnd;
2799 /*******************************************************************
2800 reads or writes a structure.
2801 ********************************************************************/
2803 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2804 prs_struct *ps, int depth)
2806 if (q_u == NULL)
2807 return False;
2809 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2810 depth++;
2812 if(!prs_align(ps))
2813 return False;
2815 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2816 return False;
2818 return True;
2821 /*******************************************************************
2822 inits a SAMR_R_QUERY_GROUPMEM structure.
2823 ********************************************************************/
2825 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2826 uint32 num_entries, uint32 *rid,
2827 uint32 *attr, NTSTATUS status)
2829 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2831 if (NT_STATUS_IS_OK(status)) {
2832 r_u->ptr = 1;
2833 r_u->num_entries = num_entries;
2835 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2836 r_u->ptr_rids = rid != NULL ? 1 : 0;
2838 r_u->num_rids = num_entries;
2839 r_u->rid = rid;
2841 r_u->num_attrs = num_entries;
2842 r_u->attr = attr;
2843 } else {
2844 r_u->ptr = 0;
2845 r_u->num_entries = 0;
2848 r_u->status = status;
2851 /*******************************************************************
2852 reads or writes a structure.
2853 ********************************************************************/
2855 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2856 prs_struct *ps, int depth)
2858 uint32 i;
2860 if (r_u == NULL)
2861 return False;
2863 if (UNMARSHALLING(ps))
2864 ZERO_STRUCTP(r_u);
2866 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2867 depth++;
2869 if(!prs_align(ps))
2870 return False;
2872 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2873 return False;
2874 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2875 return False;
2877 if (r_u->ptr != 0) {
2878 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2879 return False;
2880 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2881 return False;
2883 if (r_u->ptr_rids != 0) {
2884 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2885 return False;
2886 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2887 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2888 if (r_u->rid == NULL)
2889 return False;
2892 for (i = 0; i < r_u->num_rids; i++) {
2893 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2894 return False;
2898 if (r_u->ptr_attrs != 0) {
2899 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2900 return False;
2902 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2903 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2904 if (r_u->attr == NULL)
2905 return False;
2908 for (i = 0; i < r_u->num_attrs; i++) {
2909 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2910 return False;
2915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2916 return False;
2918 return True;
2921 /*******************************************************************
2922 inits a SAMR_Q_QUERY_USERGROUPS structure.
2923 ********************************************************************/
2925 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2926 POLICY_HND *hnd)
2928 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2930 q_u->pol = *hnd;
2933 /*******************************************************************
2934 reads or writes a structure.
2935 ********************************************************************/
2937 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2938 prs_struct *ps, int depth)
2940 if (q_u == NULL)
2941 return False;
2943 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2944 depth++;
2946 if(!prs_align(ps))
2947 return False;
2949 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2950 return False;
2952 return True;
2955 /*******************************************************************
2956 inits a SAMR_R_QUERY_USERGROUPS structure.
2957 ********************************************************************/
2959 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2960 uint32 num_gids, DOM_GID * gid,
2961 NTSTATUS status)
2963 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2965 if (NT_STATUS_IS_OK(status)) {
2966 r_u->ptr_0 = 1;
2967 r_u->num_entries = num_gids;
2968 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2969 r_u->num_entries2 = num_gids;
2971 r_u->gid = gid;
2972 } else {
2973 r_u->ptr_0 = 0;
2974 r_u->num_entries = 0;
2975 r_u->ptr_1 = 0;
2976 r_u->gid = NULL;
2979 r_u->status = status;
2982 /*******************************************************************
2983 reads or writes a structure.
2984 ********************************************************************/
2986 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
2987 prs_struct *ps, int depth)
2989 uint32 i;
2990 if (gid == NULL)
2991 return False;
2993 prs_debug(ps, depth, desc, "samr_io_gids");
2994 depth++;
2996 if(!prs_align(ps))
2997 return False;
2999 if(!prs_uint32("num_gids", ps, depth, num_gids))
3000 return False;
3002 if ((*num_gids) != 0) {
3003 if (UNMARSHALLING(ps)) {
3004 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3007 if ((*gid) == NULL) {
3008 return False;
3011 for (i = 0; i < (*num_gids); i++) {
3012 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3013 return False;
3017 return True;
3020 /*******************************************************************
3021 reads or writes a structure.
3022 ********************************************************************/
3024 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3025 prs_struct *ps, int depth)
3027 if (r_u == NULL)
3028 return False;
3030 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3031 depth++;
3033 if(!prs_align(ps))
3034 return False;
3036 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3037 return False;
3039 if (r_u->ptr_0 != 0) {
3040 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3041 return False;
3042 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3043 return False;
3045 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3046 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3047 return False;
3051 if(!prs_align(ps))
3052 return False;
3053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3054 return False;
3056 return True;
3059 /*******************************************************************
3060 inits a SAMR_Q_ENUM_DOMAINS structure.
3061 ********************************************************************/
3063 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3064 POLICY_HND *pol,
3065 uint32 start_idx, uint32 size)
3067 DEBUG(5, ("init_samr_q_enum_domains\n"));
3069 q_e->pol = *pol;
3071 q_e->start_idx = start_idx;
3072 q_e->max_size = size;
3075 /*******************************************************************
3076 reads or writes a structure.
3077 ********************************************************************/
3079 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3080 prs_struct *ps, int depth)
3082 if (q_e == NULL)
3083 return False;
3085 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3086 depth++;
3088 if(!prs_align(ps))
3089 return False;
3091 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3092 return False;
3094 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3095 return False;
3096 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3097 return False;
3099 return True;
3102 /*******************************************************************
3103 inits a SAMR_R_ENUM_DOMAINS structure.
3104 ********************************************************************/
3106 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3107 uint32 next_idx, uint32 num_sam_entries)
3109 DEBUG(5, ("init_samr_r_enum_domains\n"));
3111 r_u->next_idx = next_idx;
3113 if (num_sam_entries != 0) {
3114 r_u->ptr_entries1 = 1;
3115 r_u->ptr_entries2 = 1;
3116 r_u->num_entries2 = num_sam_entries;
3117 r_u->num_entries3 = num_sam_entries;
3119 r_u->num_entries4 = num_sam_entries;
3120 } else {
3121 r_u->ptr_entries1 = 0;
3122 r_u->num_entries2 = num_sam_entries;
3123 r_u->ptr_entries2 = 1;
3127 /*******************************************************************
3128 reads or writes a structure.
3129 ********************************************************************/
3131 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3132 prs_struct *ps, int depth)
3134 uint32 i;
3136 if (r_u == NULL)
3137 return False;
3139 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3140 depth++;
3142 if(!prs_align(ps))
3143 return False;
3145 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3146 return False;
3147 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3148 return False;
3150 if (r_u->ptr_entries1 != 0) {
3151 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3152 return False;
3153 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3154 return False;
3155 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3156 return False;
3158 if (UNMARSHALLING(ps)) {
3159 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3160 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3163 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3164 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3165 r_u->num_entries4 = 0;
3166 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3167 return False;
3170 for (i = 0; i < r_u->num_entries2; i++) {
3171 fstring tmp;
3172 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3173 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3174 return False;
3177 for (i = 0; i < r_u->num_entries2; i++) {
3178 fstring tmp;
3179 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3180 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3181 r_u->sam[i].hdr_name.buffer, ps,
3182 depth))
3183 return False;
3188 if(!prs_align(ps))
3189 return False;
3190 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3191 return False;
3192 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3193 return False;
3195 return True;
3198 /*******************************************************************
3199 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3200 ********************************************************************/
3202 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3203 POLICY_HND *pol,
3204 uint32 start_idx, uint32 size)
3206 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3208 q_e->pol = *pol;
3210 q_e->start_idx = start_idx;
3211 q_e->max_size = size;
3214 /*******************************************************************
3215 reads or writes a structure.
3216 ********************************************************************/
3218 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3219 prs_struct *ps, int depth)
3221 if (q_e == NULL)
3222 return False;
3224 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3225 depth++;
3227 if(!prs_align(ps))
3228 return False;
3230 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3231 return False;
3233 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3234 return False;
3235 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3236 return False;
3238 return True;
3241 /*******************************************************************
3242 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3243 ********************************************************************/
3245 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3246 uint32 next_idx, uint32 num_sam_entries)
3248 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3250 r_u->next_idx = next_idx;
3252 if (num_sam_entries != 0) {
3253 r_u->ptr_entries1 = 1;
3254 r_u->ptr_entries2 = 1;
3255 r_u->num_entries2 = num_sam_entries;
3256 r_u->num_entries3 = num_sam_entries;
3258 r_u->num_entries4 = num_sam_entries;
3259 } else {
3260 r_u->ptr_entries1 = 0;
3261 r_u->num_entries2 = num_sam_entries;
3262 r_u->ptr_entries2 = 1;
3266 /*******************************************************************
3267 reads or writes a structure.
3268 ********************************************************************/
3270 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3271 prs_struct *ps, int depth)
3273 uint32 i;
3275 if (r_u == NULL)
3276 return False;
3278 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3279 depth++;
3281 if(!prs_align(ps))
3282 return False;
3284 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3285 return False;
3286 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3287 return False;
3289 if (r_u->ptr_entries1 != 0) {
3290 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3291 return False;
3292 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3293 return False;
3294 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3295 return False;
3297 if (UNMARSHALLING(ps)) {
3298 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3299 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3302 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3303 DEBUG(0,
3304 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3305 r_u->num_entries4 = 0;
3306 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3307 return False;
3310 for (i = 0; i < r_u->num_entries2; i++) {
3311 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3312 return False;
3315 for (i = 0; i < r_u->num_entries2; i++) {
3316 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3317 r_u->sam[i].hdr_name.buffer, ps, depth))
3318 return False;
3322 if(!prs_align(ps))
3323 return False;
3324 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3325 return False;
3326 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3327 return False;
3329 return True;
3332 /*******************************************************************
3333 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3334 ********************************************************************/
3336 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3337 POLICY_HND *pol, uint32 start_idx,
3338 uint32 size)
3340 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3342 q_e->pol = *pol;
3344 q_e->start_idx = start_idx;
3345 q_e->max_size = size;
3349 /*******************************************************************
3350 reads or writes a structure.
3351 ********************************************************************/
3353 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3354 prs_struct *ps, int depth)
3356 if (q_e == NULL)
3357 return False;
3359 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3360 depth++;
3362 if(!prs_align(ps))
3363 return False;
3365 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3366 return False;
3368 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3369 return False;
3370 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3371 return False;
3373 return True;
3376 /*******************************************************************
3377 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3378 ********************************************************************/
3380 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3382 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3384 r_u->next_idx = next_idx;
3386 if (num_sam_entries != 0) {
3387 r_u->ptr_entries1 = 1;
3388 r_u->ptr_entries2 = 1;
3389 r_u->num_entries2 = num_sam_entries;
3390 r_u->num_entries3 = num_sam_entries;
3392 r_u->num_entries4 = num_sam_entries;
3393 } else {
3394 r_u->ptr_entries1 = 0;
3395 r_u->num_entries2 = num_sam_entries;
3396 r_u->ptr_entries2 = 1;
3400 /*******************************************************************
3401 reads or writes a structure.
3402 ********************************************************************/
3404 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3405 prs_struct *ps, int depth)
3407 uint32 i;
3409 if (r_u == NULL)
3410 return False;
3412 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3413 depth++;
3415 if(!prs_align(ps))
3416 return False;
3418 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3419 return False;
3420 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3421 return False;
3423 if (r_u->ptr_entries1 != 0) {
3424 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3425 return False;
3426 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3427 return False;
3428 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3429 return False;
3431 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3432 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3433 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3436 if (r_u->num_entries2 != 0 &&
3437 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3438 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3439 r_u->num_entries4 = 0;
3440 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3441 return False;
3444 for (i = 0; i < r_u->num_entries2; i++) {
3445 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3446 return False;
3449 for (i = 0; i < r_u->num_entries2; i++) {
3450 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3451 r_u->sam[i].hdr_name.buffer, ps,
3452 depth))
3453 return False;
3457 if(!prs_align(ps))
3458 return False;
3459 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3460 return False;
3461 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3462 return False;
3464 return True;
3467 /*******************************************************************
3468 inits a ALIAS_INFO1 structure.
3469 ********************************************************************/
3471 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3473 DEBUG(5, ("init_samr_alias_info1\n"));
3475 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3476 al1->num_member = num_member;
3477 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3480 /*******************************************************************
3481 reads or writes a structure.
3482 ********************************************************************/
3484 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3485 prs_struct *ps, int depth)
3487 if (al1 == NULL)
3488 return False;
3490 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3491 depth++;
3493 if(!prs_align(ps))
3494 return False;
3496 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3497 return False;
3498 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3499 return False;
3500 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3501 return False;
3503 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3504 return False;
3505 if ( !prs_align(ps) )
3506 return False;
3507 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3508 return False;
3509 if ( !prs_align(ps) )
3510 return False;
3512 return True;
3515 /*******************************************************************
3516 inits a ALIAS_INFO3 structure.
3517 ********************************************************************/
3519 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3521 DEBUG(5, ("init_samr_alias_info3\n"));
3523 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3526 /*******************************************************************
3527 reads or writes a structure.
3528 ********************************************************************/
3530 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3531 prs_struct *ps, int depth)
3533 if (al3 == NULL)
3534 return False;
3536 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3537 depth++;
3539 if(!prs_align(ps))
3540 return False;
3542 if (!prs_unistr4("description", ps, depth, &al3->description))
3543 return False;
3545 return True;
3548 /*******************************************************************
3549 reads or writes a structure.
3550 ********************************************************************/
3552 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3554 if ( !ctr )
3555 return False;
3557 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3558 depth++;
3560 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3561 return False;
3563 if(!prs_align(ps))
3564 return False;
3565 switch (ctr->level) {
3566 case 1:
3567 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3568 return False;
3569 break;
3570 case 3:
3571 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3572 return False;
3573 break;
3574 default:
3575 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3576 break;
3579 return True;
3582 /*******************************************************************
3583 inits a SAMR_Q_QUERY_ALIASINFO structure.
3584 ********************************************************************/
3586 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3587 POLICY_HND *pol, uint32 switch_level)
3589 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3591 q_e->pol = *pol;
3592 q_e->level = switch_level;
3595 /*******************************************************************
3596 reads or writes a structure.
3597 ********************************************************************/
3599 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3600 prs_struct *ps, int depth)
3602 if ( !in )
3603 return False;
3605 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3606 depth++;
3608 if(!prs_align(ps))
3609 return False;
3611 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3612 return False;
3614 if ( !prs_uint16("level", ps, depth, &in->level) )
3615 return False;
3617 return True;
3620 /*******************************************************************
3621 inits a SAMR_R_QUERY_ALIASINFO structure.
3622 ********************************************************************/
3624 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3625 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3627 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3629 out->ctr = ctr;
3630 out->status = status;
3633 /*******************************************************************
3634 reads or writes a structure.
3635 ********************************************************************/
3637 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3638 prs_struct *ps, int depth)
3640 if ( !out )
3641 return False;
3643 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3644 depth++;
3646 if(!prs_align(ps))
3647 return False;
3649 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3650 return False;
3651 if(!prs_align(ps))
3652 return False;
3654 if(!prs_ntstatus("status", ps, depth, &out->status))
3655 return False;
3657 return True;
3660 /*******************************************************************
3661 inits a SAMR_Q_SET_ALIASINFO structure.
3662 ********************************************************************/
3664 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3665 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3667 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3669 q_u->alias_pol = *hnd;
3670 q_u->ctr = *ctr;
3673 /*******************************************************************
3674 reads or writes a structure.
3675 ********************************************************************/
3677 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3678 prs_struct *ps, int depth)
3680 if (q_u == NULL)
3681 return False;
3683 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3684 depth++;
3686 if(!prs_align(ps))
3687 return False;
3689 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3690 return False;
3691 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3692 return False;
3694 return True;
3697 /*******************************************************************
3698 reads or writes a structure.
3699 ********************************************************************/
3701 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3702 prs_struct *ps, int depth)
3704 if (r_u == NULL)
3705 return False;
3707 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3708 depth++;
3710 if(!prs_align(ps))
3711 return False;
3712 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3713 return False;
3715 return True;
3718 /*******************************************************************
3719 inits a SAMR_Q_QUERY_USERALIASES structure.
3720 ********************************************************************/
3722 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3723 POLICY_HND *hnd,
3724 uint32 num_sids,
3725 uint32 *ptr_sid, DOM_SID2 * sid)
3727 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3729 q_u->pol = *hnd;
3731 q_u->num_sids1 = num_sids;
3732 q_u->ptr = 1;
3733 q_u->num_sids2 = num_sids;
3735 q_u->ptr_sid = ptr_sid;
3736 q_u->sid = sid;
3739 /*******************************************************************
3740 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3741 ********************************************************************/
3743 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3744 prs_struct *ps, int depth)
3746 fstring tmp;
3747 uint32 i;
3749 if (q_u == NULL)
3750 return False;
3752 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3753 depth++;
3755 if(!prs_align(ps))
3756 return False;
3758 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3759 return False;
3761 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3762 return False;
3763 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3764 return False;
3766 if (q_u->ptr==0)
3767 return True;
3769 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3770 return False;
3772 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3773 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3774 if (q_u->ptr_sid == NULL)
3775 return False;
3777 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3778 if (q_u->sid == NULL)
3779 return False;
3782 for (i = 0; i < q_u->num_sids2; i++) {
3783 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3784 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3785 return False;
3788 for (i = 0; i < q_u->num_sids2; i++) {
3789 if (q_u->ptr_sid[i] != 0) {
3790 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3791 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3792 return False;
3796 return True;
3799 /*******************************************************************
3800 inits a SAMR_R_QUERY_USERALIASES structure.
3801 ********************************************************************/
3803 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3804 uint32 num_rids, uint32 *rid,
3805 NTSTATUS status)
3807 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3809 if (NT_STATUS_IS_OK(status)) {
3810 r_u->num_entries = num_rids;
3811 r_u->ptr = 1;
3812 r_u->num_entries2 = num_rids;
3814 r_u->rid = rid;
3815 } else {
3816 r_u->num_entries = 0;
3817 r_u->ptr = 0;
3818 r_u->num_entries2 = 0;
3821 r_u->status = status;
3824 /*******************************************************************
3825 reads or writes a structure.
3826 ********************************************************************/
3828 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3829 prs_struct *ps, int depth)
3831 fstring tmp;
3832 uint32 i;
3833 if (rid == NULL)
3834 return False;
3836 prs_debug(ps, depth, desc, "samr_io_rids");
3837 depth++;
3839 if(!prs_align(ps))
3840 return False;
3842 if(!prs_uint32("num_rids", ps, depth, num_rids))
3843 return False;
3845 if ((*num_rids) != 0) {
3846 if (UNMARSHALLING(ps)) {
3847 /* reading */
3848 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3850 if ((*rid) == NULL)
3851 return False;
3853 for (i = 0; i < (*num_rids); i++) {
3854 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3855 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3856 return False;
3860 return True;
3863 /*******************************************************************
3864 reads or writes a structure.
3865 ********************************************************************/
3867 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3868 prs_struct *ps, int depth)
3870 if (r_u == NULL)
3871 return False;
3873 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3874 depth++;
3876 if(!prs_align(ps))
3877 return False;
3879 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3880 return False;
3881 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3882 return False;
3884 if (r_u->ptr != 0) {
3885 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3886 return False;
3889 if(!prs_align(ps))
3890 return False;
3891 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3892 return False;
3894 return True;
3897 /*******************************************************************
3898 inits a SAMR_Q_OPEN_ALIAS structure.
3899 ********************************************************************/
3901 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3902 uint32 access_mask, uint32 rid)
3904 DEBUG(5, ("init_samr_q_open_alias\n"));
3906 q_u->dom_pol = *pol;
3907 q_u->access_mask = access_mask;
3908 q_u->rid_alias = rid;
3911 /*******************************************************************
3912 reads or writes a structure.
3913 ********************************************************************/
3915 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3916 prs_struct *ps, int depth)
3918 if (q_u == NULL)
3919 return False;
3921 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3922 depth++;
3924 if(!prs_align(ps))
3925 return False;
3927 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3928 return False;
3930 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3931 return False;
3932 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3933 return False;
3935 return True;
3938 /*******************************************************************
3939 reads or writes a structure.
3940 ********************************************************************/
3942 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3943 prs_struct *ps, int depth)
3945 if (r_u == NULL)
3946 return False;
3948 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3949 depth++;
3951 if(!prs_align(ps))
3952 return False;
3954 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
3955 return False;
3957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3958 return False;
3960 return True;
3963 /*******************************************************************
3964 inits a SAMR_Q_LOOKUP_RIDS structure.
3965 ********************************************************************/
3967 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
3968 POLICY_HND *pol, uint32 flags,
3969 uint32 num_rids, uint32 *rid)
3971 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3973 q_u->pol = *pol;
3975 q_u->num_rids1 = num_rids;
3976 q_u->flags = flags;
3977 q_u->ptr = 0;
3978 q_u->num_rids2 = num_rids;
3979 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
3980 if (q_u->rid == NULL) {
3981 q_u->num_rids1 = 0;
3982 q_u->num_rids2 = 0;
3983 } else {
3984 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
3988 /*******************************************************************
3989 reads or writes a structure.
3990 ********************************************************************/
3992 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
3993 prs_struct *ps, int depth)
3995 uint32 i;
3996 fstring tmp;
3998 if (q_u == NULL)
3999 return False;
4001 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4002 depth++;
4004 if (UNMARSHALLING(ps))
4005 ZERO_STRUCTP(q_u);
4007 if(!prs_align(ps))
4008 return False;
4010 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4011 return False;
4013 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4014 return False;
4015 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4016 return False;
4017 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4018 return False;
4019 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4020 return False;
4022 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4023 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4024 if (q_u->rid == NULL)
4025 return False;
4028 for (i = 0; i < q_u->num_rids2; i++) {
4029 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4030 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4031 return False;
4034 return True;
4037 /*******************************************************************
4038 inits a SAMR_R_LOOKUP_RIDS structure.
4039 ********************************************************************/
4041 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4042 uint32 num_names, UNIHDR * hdr_name,
4043 UNISTR2 *uni_name, uint32 *type)
4045 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4047 r_u->hdr_name = NULL;
4048 r_u->uni_name = NULL;
4049 r_u->type = NULL;
4051 if (num_names != 0) {
4052 r_u->num_names1 = num_names;
4053 r_u->ptr_names = 1;
4054 r_u->num_names2 = num_names;
4056 r_u->num_types1 = num_names;
4057 r_u->ptr_types = 1;
4058 r_u->num_types2 = num_names;
4060 r_u->hdr_name = hdr_name;
4061 r_u->uni_name = uni_name;
4062 r_u->type = type;
4063 } else {
4064 r_u->num_names1 = num_names;
4065 r_u->ptr_names = 0;
4066 r_u->num_names2 = num_names;
4068 r_u->num_types1 = num_names;
4069 r_u->ptr_types = 0;
4070 r_u->num_types2 = num_names;
4074 /*******************************************************************
4075 reads or writes a structure.
4076 ********************************************************************/
4078 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4079 prs_struct *ps, int depth)
4081 uint32 i;
4082 fstring tmp;
4083 if (r_u == NULL)
4084 return False;
4086 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4087 depth++;
4089 if(!prs_align(ps))
4090 return False;
4092 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4093 return False;
4094 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4095 return False;
4097 if (r_u->ptr_names != 0) {
4099 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4100 return False;
4103 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4104 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4105 if (r_u->hdr_name == NULL)
4106 return False;
4108 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4109 if (r_u->uni_name == NULL)
4110 return False;
4113 for (i = 0; i < r_u->num_names2; i++) {
4114 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4115 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4116 return False;
4118 for (i = 0; i < r_u->num_names2; i++) {
4119 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4120 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4121 return False;
4126 if(!prs_align(ps))
4127 return False;
4128 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4129 return False;
4130 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4131 return False;
4133 if (r_u->ptr_types != 0) {
4135 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4136 return False;
4138 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4139 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4140 if (r_u->type == NULL)
4141 return False;
4144 for (i = 0; i < r_u->num_types2; i++) {
4145 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4146 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4147 return False;
4151 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4152 return False;
4154 return True;
4157 /*******************************************************************
4158 inits a SAMR_Q_OPEN_ALIAS structure.
4159 ********************************************************************/
4161 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4163 DEBUG(5, ("init_samr_q_delete_alias\n"));
4165 q_u->alias_pol = *hnd;
4168 /*******************************************************************
4169 reads or writes a structure.
4170 ********************************************************************/
4172 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4173 prs_struct *ps, int depth)
4175 if (q_u == NULL)
4176 return False;
4178 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4179 depth++;
4181 if(!prs_align(ps))
4182 return False;
4184 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4185 return False;
4187 return True;
4190 /*******************************************************************
4191 reads or writes a structure.
4192 ********************************************************************/
4194 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4195 prs_struct *ps, int depth)
4197 if (r_u == NULL)
4198 return False;
4200 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4201 depth++;
4203 if(!prs_align(ps))
4204 return False;
4206 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4207 return False;
4208 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4209 return False;
4211 return True;
4214 /*******************************************************************
4215 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4216 ********************************************************************/
4218 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4219 POLICY_HND *hnd, const char *acct_desc)
4221 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4223 q_u->dom_pol = *hnd;
4225 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4226 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4228 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4231 /*******************************************************************
4232 reads or writes a structure.
4233 ********************************************************************/
4235 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4236 prs_struct *ps, int depth)
4238 if (q_u == NULL)
4239 return False;
4241 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4242 depth++;
4244 if(!prs_align(ps))
4245 return False;
4247 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4248 return False;
4250 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4251 return False;
4252 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4253 q_u->hdr_acct_desc.buffer, ps, depth))
4254 return False;
4256 if(!prs_align(ps))
4257 return False;
4258 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4259 return False;
4261 return True;
4264 /*******************************************************************
4265 reads or writes a structure.
4266 ********************************************************************/
4268 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4269 prs_struct *ps, int depth)
4271 if (r_u == NULL)
4272 return False;
4274 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4275 depth++;
4277 if(!prs_align(ps))
4278 return False;
4280 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4281 return False;
4283 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4284 return False;
4286 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4287 return False;
4289 return True;
4292 /*******************************************************************
4293 inits a SAMR_Q_ADD_ALIASMEM structure.
4294 ********************************************************************/
4296 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4297 DOM_SID *sid)
4299 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4301 q_u->alias_pol = *hnd;
4302 init_dom_sid2(&q_u->sid, sid);
4305 /*******************************************************************
4306 reads or writes a structure.
4307 ********************************************************************/
4309 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4310 prs_struct *ps, int depth)
4312 if (q_u == NULL)
4313 return False;
4315 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4316 depth++;
4318 if(!prs_align(ps))
4319 return False;
4321 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4322 return False;
4323 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4324 return False;
4326 return True;
4329 /*******************************************************************
4330 reads or writes a structure.
4331 ********************************************************************/
4333 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4334 prs_struct *ps, int depth)
4336 if (r_u == NULL)
4337 return False;
4339 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4340 depth++;
4342 if(!prs_align(ps))
4343 return False;
4345 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4346 return False;
4348 return True;
4351 /*******************************************************************
4352 inits a SAMR_Q_DEL_ALIASMEM structure.
4353 ********************************************************************/
4355 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4356 DOM_SID *sid)
4358 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4360 q_u->alias_pol = *hnd;
4361 init_dom_sid2(&q_u->sid, sid);
4364 /*******************************************************************
4365 reads or writes a structure.
4366 ********************************************************************/
4368 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4369 prs_struct *ps, int depth)
4371 if (q_u == NULL)
4372 return False;
4374 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4375 depth++;
4377 if(!prs_align(ps))
4378 return False;
4380 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4381 return False;
4382 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4383 return False;
4385 return True;
4388 /*******************************************************************
4389 reads or writes a structure.
4390 ********************************************************************/
4392 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4393 prs_struct *ps, int depth)
4395 if (r_u == NULL)
4396 return False;
4398 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4399 depth++;
4401 if(!prs_align(ps))
4402 return False;
4404 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4405 return False;
4407 return True;
4410 /*******************************************************************
4411 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4412 ********************************************************************/
4414 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4415 POLICY_HND *hnd)
4417 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4419 q_c->alias_pol = *hnd;
4422 /*******************************************************************
4423 reads or writes a structure.
4424 ********************************************************************/
4426 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4427 prs_struct *ps, int depth)
4429 if (q_u == NULL)
4430 return False;
4432 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4433 depth++;
4435 if(!prs_align(ps))
4436 return False;
4438 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4439 return False;
4441 return True;
4444 /*******************************************************************
4445 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4446 ********************************************************************/
4448 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4449 NTSTATUS status)
4451 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4453 r_u->status = status;
4456 /*******************************************************************
4457 reads or writes a structure.
4458 ********************************************************************/
4460 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4461 prs_struct *ps, int depth)
4463 if (r_u == NULL)
4464 return False;
4466 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4467 depth++;
4469 if(!prs_align(ps))
4470 return False;
4472 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4473 return False;
4475 return True;
4478 /*******************************************************************
4479 inits a SAMR_Q_QUERY_ALIASMEM structure.
4480 ********************************************************************/
4482 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4483 POLICY_HND *hnd)
4485 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4487 q_c->alias_pol = *hnd;
4490 /*******************************************************************
4491 reads or writes a structure.
4492 ********************************************************************/
4494 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4495 prs_struct *ps, int depth)
4497 if (q_u == NULL)
4498 return False;
4500 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4501 depth++;
4503 if(!prs_align(ps))
4504 return False;
4506 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4507 return False;
4509 return True;
4512 /*******************************************************************
4513 inits a SAMR_R_QUERY_ALIASMEM structure.
4514 ********************************************************************/
4516 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4517 uint32 num_sids, DOM_SID2 * sid,
4518 NTSTATUS status)
4520 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4522 if (NT_STATUS_IS_OK(status)) {
4523 r_u->num_sids = num_sids;
4524 r_u->ptr = (num_sids != 0) ? 1 : 0;
4525 r_u->num_sids1 = num_sids;
4527 r_u->sid = sid;
4528 } else {
4529 r_u->ptr = 0;
4530 r_u->num_sids = 0;
4533 r_u->status = status;
4536 /*******************************************************************
4537 reads or writes a structure.
4538 ********************************************************************/
4540 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4541 prs_struct *ps, int depth)
4543 uint32 i;
4545 if (r_u == NULL)
4546 return False;
4548 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4549 depth++;
4551 if(!prs_align(ps))
4552 return False;
4554 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4555 return False;
4556 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4557 return False;
4559 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4560 uint32 *ptr_sid = NULL;
4562 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4563 return False;
4565 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4566 if (!ptr_sid) {
4567 return False;
4570 for (i = 0; i < r_u->num_sids1; i++) {
4571 ptr_sid[i] = 1;
4572 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4573 return False;
4576 if (UNMARSHALLING(ps)) {
4577 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4580 for (i = 0; i < r_u->num_sids1; i++) {
4581 if (ptr_sid[i] != 0) {
4582 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4583 return False;
4588 if(!prs_align(ps))
4589 return False;
4590 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4591 return False;
4593 return True;
4596 /*******************************************************************
4597 inits a SAMR_Q_LOOKUP_NAMES structure.
4598 ********************************************************************/
4600 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4601 POLICY_HND *pol, uint32 flags,
4602 uint32 num_names, const char **name)
4604 uint32 i;
4606 DEBUG(5, ("init_samr_q_lookup_names\n"));
4608 q_u->pol = *pol;
4610 q_u->num_names1 = num_names;
4611 q_u->flags = flags;
4612 q_u->ptr = 0;
4613 q_u->num_names2 = num_names;
4615 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4616 return NT_STATUS_NO_MEMORY;
4618 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4619 return NT_STATUS_NO_MEMORY;
4621 for (i = 0; i < num_names; i++) {
4622 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4623 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4626 return NT_STATUS_OK;
4629 /*******************************************************************
4630 reads or writes a structure.
4631 ********************************************************************/
4633 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4634 prs_struct *ps, int depth)
4636 uint32 i;
4638 if (q_u == NULL)
4639 return False;
4641 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4642 depth++;
4644 if (UNMARSHALLING(ps))
4645 ZERO_STRUCTP(q_u);
4647 if(!prs_align(ps))
4648 return False;
4650 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4651 return False;
4653 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4654 return False;
4655 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4656 return False;
4657 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4658 return False;
4659 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4660 return False;
4662 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4663 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4664 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4665 if (!q_u->hdr_name || !q_u->uni_name)
4666 return False;
4669 for (i = 0; i < q_u->num_names2; i++) {
4670 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4671 return False;
4674 for (i = 0; i < q_u->num_names2; i++) {
4675 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4676 return False;
4679 return True;
4682 /*******************************************************************
4683 inits a SAMR_R_LOOKUP_NAMES structure.
4684 ********************************************************************/
4686 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4687 uint32 num_rids,
4688 uint32 *rid, uint32 *type,
4689 NTSTATUS status)
4691 DEBUG(5, ("init_samr_r_lookup_names\n"));
4693 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4694 uint32 i;
4696 r_u->num_types1 = num_rids;
4697 r_u->ptr_types = 1;
4698 r_u->num_types2 = num_rids;
4700 r_u->num_rids1 = num_rids;
4701 r_u->ptr_rids = 1;
4702 r_u->num_rids2 = num_rids;
4704 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4705 return NT_STATUS_NO_MEMORY;
4706 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4707 return NT_STATUS_NO_MEMORY;
4709 if (!r_u->rids || !r_u->types)
4710 goto empty;
4712 for (i = 0; i < num_rids; i++) {
4713 r_u->rids[i] = rid[i];
4714 r_u->types[i] = type[i];
4716 } else {
4718 empty:
4719 r_u->num_types1 = 0;
4720 r_u->ptr_types = 0;
4721 r_u->num_types2 = 0;
4723 r_u->num_rids1 = 0;
4724 r_u->ptr_rids = 0;
4725 r_u->num_rids2 = 0;
4727 r_u->rids = NULL;
4728 r_u->types = NULL;
4731 r_u->status = status;
4733 return NT_STATUS_OK;
4736 /*******************************************************************
4737 reads or writes a structure.
4738 ********************************************************************/
4740 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4741 prs_struct *ps, int depth)
4743 uint32 i;
4744 fstring tmp;
4746 if (r_u == NULL)
4747 return False;
4749 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4750 depth++;
4752 if (UNMARSHALLING(ps))
4753 ZERO_STRUCTP(r_u);
4755 if(!prs_align(ps))
4756 return False;
4758 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4759 return False;
4760 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4761 return False;
4763 if (r_u->ptr_rids != 0) {
4764 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4765 return False;
4767 if (r_u->num_rids2 != r_u->num_rids1) {
4768 /* RPC fault */
4769 return False;
4772 if (UNMARSHALLING(ps))
4773 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4775 if (!r_u->rids) {
4776 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4777 return False;
4780 for (i = 0; i < r_u->num_rids2; i++) {
4781 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4782 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4783 return False;
4787 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4788 return False;
4789 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4790 return False;
4792 if (r_u->ptr_types != 0) {
4793 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4794 return False;
4796 if (r_u->num_types2 != r_u->num_types1) {
4797 /* RPC fault */
4798 return False;
4801 if (UNMARSHALLING(ps))
4802 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4804 if (!r_u->types) {
4805 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4806 return False;
4809 for (i = 0; i < r_u->num_types2; i++) {
4810 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4811 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4812 return False;
4816 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4817 return False;
4819 return True;
4822 /*******************************************************************
4823 inits a SAMR_Q_DELETE_DOM_USER structure.
4824 ********************************************************************/
4826 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4827 POLICY_HND *hnd)
4829 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4831 q_c->user_pol = *hnd;
4834 /*******************************************************************
4835 reads or writes a structure.
4836 ********************************************************************/
4838 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4839 prs_struct *ps, int depth)
4841 if (q_u == NULL)
4842 return False;
4844 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4845 depth++;
4847 if(!prs_align(ps))
4848 return False;
4850 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4851 return False;
4853 return True;
4856 /*******************************************************************
4857 reads or writes a structure.
4858 ********************************************************************/
4860 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4861 prs_struct *ps, int depth)
4863 if (r_u == NULL)
4864 return False;
4866 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4867 depth++;
4869 if(!prs_align(ps))
4870 return False;
4872 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4873 return False;
4874 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4875 return False;
4877 return True;
4880 /*******************************************************************
4881 reads or writes a structure.
4882 ********************************************************************/
4884 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4885 POLICY_HND *pol,
4886 uint32 access_mask, uint32 rid)
4888 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4890 q_u->domain_pol = *pol;
4891 q_u->access_mask = access_mask;
4892 q_u->user_rid = rid;
4895 /*******************************************************************
4896 reads or writes a structure.
4897 ********************************************************************/
4899 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4900 prs_struct *ps, int depth)
4902 if (q_u == NULL)
4903 return False;
4905 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4906 depth++;
4908 if(!prs_align(ps))
4909 return False;
4911 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4912 return False;
4914 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4915 return False;
4916 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4917 return False;
4919 return True;
4922 /*******************************************************************
4923 reads or writes a structure.
4924 ********************************************************************/
4926 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_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_open_user");
4933 depth++;
4935 if(!prs_align(ps))
4936 return False;
4938 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4939 return False;
4941 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4942 return False;
4944 return True;
4948 /*******************************************************************
4949 reads or writes a structure.
4950 ********************************************************************/
4952 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
4953 POLICY_HND *pol,
4954 const char *name,
4955 uint32 acb_info, uint32 access_mask)
4957 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4959 q_u->domain_pol = *pol;
4961 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
4962 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
4964 q_u->acb_info = acb_info;
4965 q_u->access_mask = access_mask;
4968 /*******************************************************************
4969 reads or writes a structure.
4970 ********************************************************************/
4972 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
4973 prs_struct *ps, int depth)
4975 if (q_u == NULL)
4976 return False;
4978 prs_debug(ps, depth, desc, "samr_io_q_create_user");
4979 depth++;
4981 if(!prs_align(ps))
4982 return False;
4984 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4985 return False;
4987 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
4988 return False;
4989 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
4990 return False;
4992 if(!prs_align(ps))
4993 return False;
4994 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
4995 return False;
4996 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4997 return False;
4999 return True;
5002 /*******************************************************************
5003 reads or writes a structure.
5004 ********************************************************************/
5006 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5007 prs_struct *ps, int depth)
5009 if (r_u == NULL)
5010 return False;
5012 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5013 depth++;
5015 if(!prs_align(ps))
5016 return False;
5018 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5019 return False;
5021 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5022 return False;
5023 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5024 return False;
5025 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5026 return False;
5028 return True;
5031 /*******************************************************************
5032 inits a SAMR_Q_QUERY_USERINFO structure.
5033 ********************************************************************/
5035 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5036 POLICY_HND *hnd, uint16 switch_value)
5038 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5040 q_u->pol = *hnd;
5041 q_u->switch_value = switch_value;
5044 /*******************************************************************
5045 reads or writes a structure.
5046 ********************************************************************/
5048 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5049 prs_struct *ps, int depth)
5051 if (q_u == NULL)
5052 return False;
5054 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5055 depth++;
5057 if(!prs_align(ps))
5058 return False;
5060 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5061 return False;
5063 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5064 return False;
5066 return True;
5069 /*******************************************************************
5070 reads or writes a LOGON_HRS structure.
5071 ********************************************************************/
5073 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5074 prs_struct *ps, int depth)
5076 if (hrs == NULL)
5077 return False;
5079 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5080 depth++;
5082 if(!prs_align(ps))
5083 return False;
5085 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5086 return False;
5088 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5089 return False;
5091 if(!prs_uint32("len ", ps, depth, &hrs->len))
5092 return False;
5094 if (hrs->len > sizeof(hrs->hours)) {
5095 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5096 hrs->len = sizeof(hrs->hours);
5099 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5100 return False;
5102 return True;
5105 /*******************************************************************
5106 inits a SAM_USER_INFO_18 structure.
5107 ********************************************************************/
5109 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5110 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5112 DEBUG(5, ("init_sam_user_info18\n"));
5114 usr->lm_pwd_active =
5115 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5116 usr->nt_pwd_active =
5117 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5120 /*******************************************************************
5121 reads or writes a structure.
5122 ********************************************************************/
5124 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5125 prs_struct *ps, int depth)
5127 if (u == NULL)
5128 return False;
5130 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5131 depth++;
5133 if(!prs_align(ps))
5134 return False;
5136 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5137 return False;
5138 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5139 return False;
5141 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5142 return False;
5143 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5144 return False;
5146 return True;
5149 /*******************************************************************
5150 inits a SAM_USER_INFO_7 structure.
5151 ********************************************************************/
5153 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5155 DEBUG(5, ("init_sam_user_info7\n"));
5157 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5158 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5162 /*******************************************************************
5163 reads or writes a structure.
5164 ********************************************************************/
5166 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5167 prs_struct *ps, int depth)
5169 if (usr == NULL)
5170 return False;
5172 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5173 depth++;
5175 if(!prs_align(ps))
5176 return False;
5178 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5179 return False;
5181 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5182 return False;
5184 return True;
5187 /*******************************************************************
5188 inits a SAM_USER_INFO_16 structure.
5189 ********************************************************************/
5191 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5193 DEBUG(5, ("init_sam_user_info16\n"));
5195 usr->acb_info = acb_info;
5198 /*******************************************************************
5199 reads or writes a structure.
5200 ********************************************************************/
5202 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5203 prs_struct *ps, int depth)
5205 if (usr == NULL)
5206 return False;
5208 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5209 depth++;
5211 if(!prs_align(ps))
5212 return False;
5214 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5215 return False;
5217 return True;
5220 /*******************************************************************
5221 inits a SAM_USER_INFO_17 structure.
5222 ********************************************************************/
5224 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5225 NTTIME * expiry,
5226 char *mach_acct,
5227 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5229 DEBUG(5, ("init_sam_user_info17\n"));
5231 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5232 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5234 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5236 usr->ptr_1 = 1; /* pointer */
5237 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5238 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5240 usr->ptr_2 = 1; /* pointer */
5241 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5243 usr->ptr_3 = 1; /* pointer */
5244 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5246 usr->rid_user = rid_user;
5247 usr->rid_group = rid_group;
5249 usr->acct_ctrl = acct_ctrl;
5250 usr->unknown_3 = 0x0000;
5252 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5253 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5255 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5256 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5258 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5259 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5262 /*******************************************************************
5263 reads or writes a structure.
5264 ********************************************************************/
5266 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5267 prs_struct *ps, int depth)
5269 if (usr == NULL)
5270 return False;
5272 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5273 depth++;
5275 if(!prs_align(ps))
5276 return False;
5278 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5279 return False;
5281 if(!smb_io_time("time", &usr->expiry, ps, depth))
5282 return False;
5284 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5285 return False;
5287 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5288 return False;
5290 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5291 return False;
5293 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5294 return False;
5295 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5296 return False;
5298 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5299 return False;
5301 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5302 return False;
5303 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5304 return False;
5306 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5307 return False;
5308 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5309 return False;
5311 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5312 return False;
5313 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5314 return False;
5315 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5316 return False;
5317 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5318 return False;
5319 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5320 return False;
5321 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5322 return False;
5324 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5325 return False;
5327 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5328 return False;
5330 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5331 return False;
5333 if(!prs_align(ps))
5334 return False;
5336 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5337 return False;
5339 return True;
5342 /*************************************************************************
5343 init_sam_user_infoa
5344 *************************************************************************/
5346 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5348 DEBUG(10, ("init_sam_user_info24:\n"));
5349 memcpy(usr->pass, newpass, sizeof(usr->pass));
5350 usr->pw_len = pw_len;
5353 /*******************************************************************
5354 reads or writes a structure.
5355 ********************************************************************/
5357 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5358 prs_struct *ps, int depth)
5360 if (usr == NULL)
5361 return False;
5363 prs_debug(ps, depth, desc, "sam_io_user_info24");
5364 depth++;
5366 if(!prs_align(ps))
5367 return False;
5369 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5370 sizeof(usr->pass)))
5371 return False;
5373 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5374 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5375 return False;
5377 if(!prs_align(ps))
5378 return False;
5380 return True;
5383 /*************************************************************************
5384 init_sam_user_info23
5386 unknown_6 = 0x0000 04ec
5388 *************************************************************************/
5390 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5391 NTTIME * logoff_time, /* all zeros */
5392 NTTIME * kickoff_time, /* all zeros */
5393 NTTIME * pass_last_set_time, /* all zeros */
5394 NTTIME * pass_can_change_time, /* all zeros */
5395 NTTIME * pass_must_change_time, /* all zeros */
5396 UNISTR2 *user_name,
5397 UNISTR2 *full_name,
5398 UNISTR2 *home_dir,
5399 UNISTR2 *dir_drive,
5400 UNISTR2 *log_scr,
5401 UNISTR2 *prof_path,
5402 UNISTR2 *desc,
5403 UNISTR2 *wkstas,
5404 UNISTR2 *unk_str,
5405 UNISTR2 *mung_dial,
5406 uint32 user_rid, /* 0x0000 0000 */
5407 uint32 group_rid,
5408 uint32 acb_info,
5409 uint32 fields_present,
5410 uint16 logon_divs,
5411 LOGON_HRS * hrs,
5412 uint16 bad_password_count,
5413 uint16 logon_count,
5414 char newpass[516])
5416 usr->logon_time = *logon_time; /* all zeros */
5417 usr->logoff_time = *logoff_time; /* all zeros */
5418 usr->kickoff_time = *kickoff_time; /* all zeros */
5419 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5420 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5421 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5423 ZERO_STRUCT(usr->nt_pwd);
5424 ZERO_STRUCT(usr->lm_pwd);
5426 usr->user_rid = user_rid; /* 0x0000 0000 */
5427 usr->group_rid = group_rid;
5428 usr->acb_info = acb_info;
5429 usr->fields_present = fields_present; /* 09f8 27fa */
5431 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5432 usr->ptr_logon_hrs = hrs ? 1 : 0;
5434 if (nt_time_is_zero(pass_must_change_time)) {
5435 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5436 } else {
5437 usr->passmustchange=0;
5440 ZERO_STRUCT(usr->padding1);
5441 ZERO_STRUCT(usr->padding2);
5443 usr->bad_password_count = bad_password_count;
5444 usr->logon_count = logon_count;
5446 memcpy(usr->pass, newpass, sizeof(usr->pass));
5448 copy_unistr2(&usr->uni_user_name, user_name);
5449 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5451 copy_unistr2(&usr->uni_full_name, full_name);
5452 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5454 copy_unistr2(&usr->uni_home_dir, home_dir);
5455 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5457 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5458 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5460 copy_unistr2(&usr->uni_logon_script, log_scr);
5461 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5463 copy_unistr2(&usr->uni_profile_path, prof_path);
5464 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5466 copy_unistr2(&usr->uni_acct_desc, desc);
5467 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5469 copy_unistr2(&usr->uni_workstations, wkstas);
5470 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5472 copy_unistr2(&usr->uni_unknown_str, unk_str);
5473 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5475 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5476 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5478 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5481 /*************************************************************************
5482 init_sam_user_info23
5484 unknown_6 = 0x0000 04ec
5486 *************************************************************************/
5488 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5489 NTTIME * logoff_time, /* all zeros */
5490 NTTIME * kickoff_time, /* all zeros */
5491 NTTIME * pass_last_set_time, /* all zeros */
5492 NTTIME * pass_can_change_time, /* all zeros */
5493 NTTIME * pass_must_change_time, /* all zeros */
5494 char *user_name, /* NULL */
5495 char *full_name,
5496 char *home_dir, char *dir_drive, char *log_scr,
5497 char *prof_path, const char *desc, char *wkstas,
5498 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5499 uint32 group_rid, uint32 acb_info,
5500 uint32 fields_present, uint16 logon_divs,
5501 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5502 char newpass[516])
5504 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5506 usr->logon_time = *logon_time; /* all zeros */
5507 usr->logoff_time = *logoff_time; /* all zeros */
5508 usr->kickoff_time = *kickoff_time; /* all zeros */
5509 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5510 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5511 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5513 ZERO_STRUCT(usr->nt_pwd);
5514 ZERO_STRUCT(usr->lm_pwd);
5516 usr->user_rid = user_rid; /* 0x0000 0000 */
5517 usr->group_rid = group_rid;
5518 usr->acb_info = acb_info;
5519 usr->fields_present = fields_present; /* 09f8 27fa */
5521 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5522 usr->ptr_logon_hrs = hrs ? 1 : 0;
5524 if (nt_time_is_zero(pass_must_change_time)) {
5525 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5526 } else {
5527 usr->passmustchange=0;
5530 ZERO_STRUCT(usr->padding1);
5531 ZERO_STRUCT(usr->padding2);
5533 usr->bad_password_count = bad_password_count;
5534 usr->logon_count = logon_count;
5536 memcpy(usr->pass, newpass, sizeof(usr->pass));
5538 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5539 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5541 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5542 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5544 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5545 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5547 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5548 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5550 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5551 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5553 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5554 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5556 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5557 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5559 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5560 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5562 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5563 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5565 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5566 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5568 data_blob_free(&blob);
5570 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5573 /*******************************************************************
5574 reads or writes a structure.
5575 ********************************************************************/
5577 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5578 prs_struct *ps, int depth)
5580 if (usr == NULL)
5581 return False;
5583 prs_debug(ps, depth, desc, "sam_io_user_info23");
5584 depth++;
5586 if(!prs_align(ps))
5587 return False;
5589 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5590 return False;
5591 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5592 return False;
5593 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5594 return False;
5595 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5596 return False;
5597 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5598 return False;
5599 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5600 return False;
5602 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5603 return False;
5604 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5605 return False;
5606 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5607 return False;
5608 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5609 return False;
5610 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5611 return False;
5612 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5613 return False;
5614 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5615 return False;
5616 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5617 return False;
5618 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5619 return False;
5620 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5621 return False;
5623 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5624 return False;
5625 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5626 return False;
5628 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5629 return False;
5630 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5631 return False;
5632 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5633 return False;
5635 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5636 return False;
5637 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5638 return False;
5639 if(!prs_align(ps))
5640 return False;
5641 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5642 return False;
5644 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5645 return False;
5646 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5647 return False;
5649 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5650 return False;
5651 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5652 return False;
5653 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5654 return False;
5657 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5658 return False;
5660 /* here begins pointed-to data */
5662 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5663 return False;
5665 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5666 return False;
5668 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5669 return False;
5671 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5672 return False;
5674 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5675 return False;
5677 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5678 return False;
5680 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5681 return False;
5683 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5684 return False;
5686 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5687 return False;
5689 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5690 return False;
5692 /* ok, this is only guess-work (as usual) */
5693 if (usr->ptr_logon_hrs) {
5694 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5695 return False;
5698 return True;
5701 /*******************************************************************
5702 reads or writes a structure.
5703 NB. This structure is *definately* incorrect. It's my best guess
5704 currently for W2K SP2. The password field is encrypted in a different
5705 way than normal... And there are definately other problems. JRA.
5706 ********************************************************************/
5708 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5710 if (usr == NULL)
5711 return False;
5713 prs_debug(ps, depth, desc, "sam_io_user_info25");
5714 depth++;
5716 if(!prs_align(ps))
5717 return False;
5719 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5720 return False;
5721 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5722 return False;
5723 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5724 return False;
5725 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5726 return False;
5727 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5728 return False;
5729 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5730 return False;
5732 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5733 return False;
5734 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5735 return False;
5736 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5737 return False;
5738 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5739 return False;
5740 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5741 return False;
5742 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5743 return False;
5744 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5745 return False;
5746 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5747 return False;
5748 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5749 return False;
5750 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5751 return False;
5753 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5754 return False;
5755 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5756 return False;
5758 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5759 return False;
5760 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5761 return False;
5762 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5763 return False;
5765 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5766 return False;
5768 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5769 return False;
5771 /* here begins pointed-to data */
5773 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5774 return False;
5776 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5777 return False;
5779 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5780 return False;
5782 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5783 return False;
5785 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5786 return False;
5788 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5789 return False;
5791 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5792 return False;
5794 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5795 return False;
5797 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5798 return False;
5800 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5801 return False;
5803 #if 0 /* JRA - unknown... */
5804 /* ok, this is only guess-work (as usual) */
5805 if (usr->ptr_logon_hrs) {
5806 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5807 return False;
5809 #endif
5811 return True;
5815 /*************************************************************************
5816 init_sam_user_info21W
5818 unknown_6 = 0x0000 04ec
5820 *************************************************************************/
5822 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5823 NTTIME * logon_time,
5824 NTTIME * logoff_time,
5825 NTTIME * kickoff_time,
5826 NTTIME * pass_last_set_time,
5827 NTTIME * pass_can_change_time,
5828 NTTIME * pass_must_change_time,
5829 UNISTR2 *user_name,
5830 UNISTR2 *full_name,
5831 UNISTR2 *home_dir,
5832 UNISTR2 *dir_drive,
5833 UNISTR2 *log_scr,
5834 UNISTR2 *prof_path,
5835 UNISTR2 *desc,
5836 UNISTR2 *wkstas,
5837 UNISTR2 *unk_str,
5838 UNISTR2 *mung_dial,
5839 uchar lm_pwd[16],
5840 uchar nt_pwd[16],
5841 uint32 user_rid,
5842 uint32 group_rid,
5843 uint32 acb_info,
5844 uint32 fields_present,
5845 uint16 logon_divs,
5846 LOGON_HRS * hrs,
5847 uint16 bad_password_count,
5848 uint16 logon_count)
5850 usr->logon_time = *logon_time;
5851 usr->logoff_time = *logoff_time;
5852 usr->kickoff_time = *kickoff_time;
5853 usr->pass_last_set_time = *pass_last_set_time;
5854 usr->pass_can_change_time = *pass_can_change_time;
5855 usr->pass_must_change_time = *pass_must_change_time;
5857 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5858 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5860 usr->user_rid = user_rid;
5861 usr->group_rid = group_rid;
5862 usr->acb_info = acb_info;
5863 usr->fields_present = fields_present; /* 0x00ff ffff */
5865 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5866 usr->ptr_logon_hrs = hrs ? 1 : 0;
5867 usr->bad_password_count = bad_password_count;
5868 usr->logon_count = logon_count;
5870 if (nt_time_is_zero(pass_must_change_time)) {
5871 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5872 } else {
5873 usr->passmustchange=0;
5876 ZERO_STRUCT(usr->padding1);
5877 ZERO_STRUCT(usr->padding2);
5879 copy_unistr2(&usr->uni_user_name, user_name);
5880 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5882 copy_unistr2(&usr->uni_full_name, full_name);
5883 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5885 copy_unistr2(&usr->uni_home_dir, home_dir);
5886 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5888 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5889 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5891 copy_unistr2(&usr->uni_logon_script, log_scr);
5892 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5894 copy_unistr2(&usr->uni_profile_path, prof_path);
5895 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5897 copy_unistr2(&usr->uni_acct_desc, desc);
5898 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5900 copy_unistr2(&usr->uni_workstations, wkstas);
5901 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5903 copy_unistr2(&usr->uni_unknown_str, unk_str);
5904 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5906 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5907 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5909 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5912 /*************************************************************************
5913 init_sam_user_info21
5915 unknown_6 = 0x0000 04ec
5917 *************************************************************************/
5919 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5921 NTTIME logon_time, logoff_time, kickoff_time,
5922 pass_last_set_time, pass_can_change_time,
5923 pass_must_change_time;
5925 const char* user_name = pdb_get_username(pw);
5926 const char* full_name = pdb_get_fullname(pw);
5927 const char* home_dir = pdb_get_homedir(pw);
5928 const char* dir_drive = pdb_get_dir_drive(pw);
5929 const char* logon_script = pdb_get_logon_script(pw);
5930 const char* profile_path = pdb_get_profile_path(pw);
5931 const char* description = pdb_get_acct_desc(pw);
5932 const char* workstations = pdb_get_workstations(pw);
5933 const char* munged_dial = pdb_get_munged_dial(pw);
5934 DATA_BLOB munged_dial_blob;
5936 uint32 user_rid;
5937 const DOM_SID *user_sid;
5939 uint32 group_rid;
5940 const DOM_SID *group_sid;
5942 if (munged_dial) {
5943 munged_dial_blob = base64_decode_data_blob(munged_dial);
5944 } else {
5945 munged_dial_blob = data_blob(NULL, 0);
5948 /* Create NTTIME structs */
5949 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5950 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5951 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5952 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5953 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5954 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5956 /* structure assignment */
5957 usr->logon_time = logon_time;
5958 usr->logoff_time = logoff_time;
5959 usr->kickoff_time = kickoff_time;
5960 usr->pass_last_set_time = pass_last_set_time;
5961 usr->pass_can_change_time = pass_can_change_time;
5962 usr->pass_must_change_time = pass_must_change_time;
5964 ZERO_STRUCT(usr->nt_pwd);
5965 ZERO_STRUCT(usr->lm_pwd);
5967 user_sid = pdb_get_user_sid(pw);
5969 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
5970 fstring user_sid_string;
5971 fstring domain_sid_string;
5972 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5973 "the domain sid %s. Failing operation.\n",
5974 user_name,
5975 sid_to_string(user_sid_string, user_sid),
5976 sid_to_string(domain_sid_string, domain_sid)));
5977 data_blob_free(&munged_dial_blob);
5978 return NT_STATUS_UNSUCCESSFUL;
5981 group_sid = pdb_get_group_sid(pw);
5983 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
5984 fstring group_sid_string;
5985 fstring domain_sid_string;
5986 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
5987 "which conflicts with the domain sid %s. Failing operation.\n",
5988 user_name,
5989 sid_to_string(group_sid_string, group_sid),
5990 sid_to_string(domain_sid_string, domain_sid)));
5991 data_blob_free(&munged_dial_blob);
5992 return NT_STATUS_UNSUCCESSFUL;
5995 usr->user_rid = user_rid;
5996 usr->group_rid = group_rid;
5997 usr->acb_info = pdb_get_acct_ctrl(pw);
6000 Look at a user on a real NT4 PDC with usrmgr, press
6001 'ok'. Then you will see that fields_present is set to
6002 0x08f827fa. Look at the user immediately after that again,
6003 and you will see that 0x00fffff is returned. This solves
6004 the problem that you get access denied after having looked
6005 at the user.
6006 -- Volker
6008 usr->fields_present = pdb_build_fields_present(pw);
6010 usr->logon_divs = pdb_get_logon_divs(pw);
6011 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6012 usr->bad_password_count = pdb_get_bad_password_count(pw);
6013 usr->logon_count = pdb_get_logon_count(pw);
6015 if (pdb_get_pass_must_change_time(pw) == 0) {
6016 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6017 } else {
6018 usr->passmustchange=0;
6021 ZERO_STRUCT(usr->padding1);
6022 ZERO_STRUCT(usr->padding2);
6024 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6025 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6027 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6028 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6030 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6031 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6033 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6034 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6036 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6037 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6039 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6040 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6042 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6043 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6045 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6046 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6048 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6049 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6051 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6052 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6053 data_blob_free(&munged_dial_blob);
6055 if (pdb_get_hours(pw)) {
6056 usr->logon_hrs.max_len = 1260;
6057 usr->logon_hrs.offset = 0;
6058 usr->logon_hrs.len = pdb_get_hours_len(pw);
6059 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6060 } else {
6061 usr->logon_hrs.max_len = 1260;
6062 usr->logon_hrs.offset = 0;
6063 usr->logon_hrs.len = 0;
6064 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6067 return NT_STATUS_OK;
6070 /*******************************************************************
6071 reads or writes a structure.
6072 ********************************************************************/
6074 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6075 prs_struct *ps, int depth)
6077 if (usr == NULL)
6078 return False;
6080 prs_debug(ps, depth, desc, "sam_io_user_info21");
6081 depth++;
6083 if(!prs_align(ps))
6084 return False;
6086 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6087 return False;
6088 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6089 return False;
6090 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6091 return False;
6092 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6093 return False;
6094 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6095 return False;
6096 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6097 return False;
6099 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6100 return False;
6101 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6102 return False;
6103 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6104 return False;
6105 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6106 return False;
6107 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6108 return False;
6109 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6110 return False;
6111 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6112 return False;
6113 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6114 return False;
6115 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6116 return False;
6117 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6118 return False;
6120 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6121 return False;
6122 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6123 return False;
6125 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6126 return False;
6127 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6128 return False;
6129 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6130 return False;
6132 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6133 return False;
6134 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6135 return False;
6136 if(!prs_align(ps))
6137 return False;
6138 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6139 return False;
6141 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6142 return False;
6143 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6144 return False;
6146 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6147 return False;
6148 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6149 return False;
6150 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6151 return False;
6153 /* here begins pointed-to data */
6155 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6156 return False;
6157 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6158 return False;
6159 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6160 return False;
6161 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6162 return False;
6163 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6164 return False;
6165 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6166 return False;
6167 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6168 return False;
6169 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6170 return False;
6171 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6172 return False;
6173 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6174 return False;
6176 /* ok, this is only guess-work (as usual) */
6177 if (usr->ptr_logon_hrs) {
6178 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6179 return False;
6182 return True;
6185 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6187 const char *munged_dial = pdb_get_munged_dial(pw);
6188 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6190 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6191 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6192 data_blob_free(&blob);
6195 /*******************************************************************
6196 reads or writes a structure.
6197 ********************************************************************/
6199 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6200 prs_struct *ps, int depth)
6202 if (usr == NULL)
6203 return False;
6205 prs_debug(ps, depth, desc, "sam_io_user_info20");
6206 depth++;
6208 if(!prs_align(ps))
6209 return False;
6211 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6212 return False;
6214 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6215 return False;
6217 return True;
6220 /*******************************************************************
6221 inits a SAM_USERINFO_CTR structure.
6222 ********************************************************************/
6224 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6225 uint16 switch_value,
6226 SAM_USER_INFO_21 * usr)
6228 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6230 ctr->switch_value = switch_value;
6231 ctr->info.id = NULL;
6233 switch (switch_value) {
6234 case 16:
6235 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6236 if (ctr->info.id16 == NULL)
6237 return NT_STATUS_NO_MEMORY;
6239 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6240 break;
6241 #if 0
6242 /* whoops - got this wrong. i think. or don't understand what's happening. */
6243 case 17:
6245 NTTIME expire;
6246 info = (void *)&id11;
6248 expire.low = 0xffffffff;
6249 expire.high = 0x7fffffff;
6251 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6252 init_sam_user_info11(ctr->info.id17, &expire,
6253 "BROOKFIELDS$", /* name */
6254 0x03ef, /* user rid */
6255 0x201, /* group rid */
6256 0x0080); /* acb info */
6258 break;
6260 #endif
6261 case 18:
6262 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6263 if (ctr->info.id18 == NULL)
6264 return NT_STATUS_NO_MEMORY;
6266 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6267 break;
6268 case 21:
6270 SAM_USER_INFO_21 *cusr;
6271 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6272 ctr->info.id21 = cusr;
6273 if (ctr->info.id21 == NULL)
6274 return NT_STATUS_NO_MEMORY;
6275 memcpy(cusr, usr, sizeof(*usr));
6276 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6277 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6278 break;
6280 default:
6281 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6282 return NT_STATUS_INVALID_INFO_CLASS;
6285 return NT_STATUS_OK;
6288 /*******************************************************************
6289 inits a SAM_USERINFO_CTR structure.
6290 ********************************************************************/
6292 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6293 uint16 switch_value, void *info)
6295 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6297 ctr->switch_value = switch_value;
6298 ctr->info.id = info;
6300 switch (switch_value) {
6301 case 0x18:
6302 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6303 dump_data(100, (char *)sess_key->data, sess_key->length);
6304 dump_data(100, (char *)ctr->info.id24->pass, 516);
6305 break;
6306 case 0x17:
6307 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6308 dump_data(100, (char *)sess_key->data, sess_key->length);
6309 dump_data(100, (char *)ctr->info.id23->pass, 516);
6310 break;
6311 case 0x07:
6312 break;
6313 default:
6314 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6318 /*******************************************************************
6319 reads or writes a structure.
6320 ********************************************************************/
6322 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6323 prs_struct *ps, int depth)
6325 BOOL ret;
6326 SAM_USERINFO_CTR *ctr;
6328 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6329 depth++;
6331 if (UNMARSHALLING(ps)) {
6332 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6333 if (ctr == NULL)
6334 return False;
6335 *ppctr = ctr;
6336 } else {
6337 ctr = *ppctr;
6340 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6342 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6343 return False;
6344 if(!prs_align(ps))
6345 return False;
6347 ret = False;
6349 switch (ctr->switch_value) {
6350 case 7:
6351 if (UNMARSHALLING(ps))
6352 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6353 if (ctr->info.id7 == NULL) {
6354 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6355 return False;
6357 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6358 break;
6359 case 16:
6360 if (UNMARSHALLING(ps))
6361 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6362 if (ctr->info.id16 == NULL) {
6363 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6364 return False;
6366 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6367 break;
6368 case 17:
6369 if (UNMARSHALLING(ps))
6370 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6372 if (ctr->info.id17 == NULL) {
6373 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6374 return False;
6376 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6377 break;
6378 case 18:
6379 if (UNMARSHALLING(ps))
6380 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6382 if (ctr->info.id18 == NULL) {
6383 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6384 return False;
6386 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6387 break;
6388 case 20:
6389 if (UNMARSHALLING(ps))
6390 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6392 if (ctr->info.id20 == NULL) {
6393 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6394 return False;
6396 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6397 break;
6398 case 21:
6399 if (UNMARSHALLING(ps))
6400 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6402 if (ctr->info.id21 == NULL) {
6403 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6404 return False;
6406 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6407 break;
6408 case 23:
6409 if (UNMARSHALLING(ps))
6410 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6412 if (ctr->info.id23 == NULL) {
6413 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6414 return False;
6416 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6417 break;
6418 case 24:
6419 if (UNMARSHALLING(ps))
6420 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6422 if (ctr->info.id24 == NULL) {
6423 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6424 return False;
6426 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6427 break;
6428 case 25:
6429 if (UNMARSHALLING(ps))
6430 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6432 if (ctr->info.id25 == NULL) {
6433 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6434 return False;
6436 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6437 break;
6438 default:
6439 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6440 ret = False;
6441 break;
6444 return ret;
6447 /*******************************************************************
6448 inits a SAMR_R_QUERY_USERINFO structure.
6449 ********************************************************************/
6451 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6452 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6454 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6456 r_u->ptr = 0;
6457 r_u->ctr = NULL;
6459 if (NT_STATUS_IS_OK(status)) {
6460 r_u->ptr = 1;
6461 r_u->ctr = ctr;
6464 r_u->status = status; /* return status */
6467 /*******************************************************************
6468 reads or writes a structure.
6469 ********************************************************************/
6471 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6472 prs_struct *ps, int depth)
6474 if (r_u == NULL)
6475 return False;
6477 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6478 depth++;
6480 if(!prs_align(ps))
6481 return False;
6483 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6484 return False;
6486 if (r_u->ptr != 0) {
6487 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6488 return False;
6491 if(!prs_align(ps))
6492 return False;
6493 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6494 return False;
6496 return True;
6499 /*******************************************************************
6500 inits a SAMR_Q_SET_USERINFO structure.
6501 ********************************************************************/
6503 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6504 POLICY_HND *hnd, DATA_BLOB *sess_key,
6505 uint16 switch_value, void *info)
6507 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6509 q_u->pol = *hnd;
6510 q_u->switch_value = switch_value;
6511 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6514 /*******************************************************************
6515 reads or writes a structure.
6516 ********************************************************************/
6518 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6519 prs_struct *ps, int depth)
6521 if (q_u == NULL)
6522 return False;
6524 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6525 depth++;
6527 if(!prs_align(ps))
6528 return False;
6530 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6532 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6533 return False;
6534 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6535 return False;
6537 return True;
6540 /*******************************************************************
6541 inits a SAMR_R_SET_USERINFO structure.
6542 ********************************************************************/
6544 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6546 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6548 r_u->status = status; /* return status */
6551 /*******************************************************************
6552 reads or writes a structure.
6553 ********************************************************************/
6555 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6556 prs_struct *ps, int depth)
6558 if (r_u == NULL)
6559 return False;
6561 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6562 depth++;
6564 if(!prs_align(ps))
6565 return False;
6567 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6568 return False;
6570 return True;
6573 /*******************************************************************
6574 inits a SAMR_Q_SET_USERINFO2 structure.
6575 ********************************************************************/
6577 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6578 POLICY_HND *hnd, DATA_BLOB *sess_key,
6579 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6581 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6583 q_u->pol = *hnd;
6584 q_u->switch_value = switch_value;
6585 q_u->ctr = ctr;
6587 if (q_u->ctr != NULL)
6588 q_u->ctr->switch_value = switch_value;
6590 switch (switch_value) {
6591 case 18:
6592 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6593 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6594 dump_data(100, (char *)sess_key->data, sess_key->length);
6595 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6596 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6597 break;
6601 /*******************************************************************
6602 reads or writes a structure.
6603 ********************************************************************/
6605 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6606 prs_struct *ps, int depth)
6608 if (q_u == NULL)
6609 return False;
6611 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6612 depth++;
6614 if(!prs_align(ps))
6615 return False;
6617 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6618 return False;
6620 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6621 return False;
6622 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6623 return False;
6625 return True;
6628 /*******************************************************************
6629 inits a SAMR_R_SET_USERINFO2 structure.
6630 ********************************************************************/
6632 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6634 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6636 r_u->status = status; /* return status */
6639 /*******************************************************************
6640 reads or writes a structure.
6641 ********************************************************************/
6643 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6644 prs_struct *ps, int depth)
6646 if (r_u == NULL)
6647 return False;
6649 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6650 depth++;
6652 if(!prs_align(ps))
6653 return False;
6655 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6656 return False;
6658 return True;
6661 /*******************************************************************
6662 inits a SAMR_Q_CONNECT structure.
6663 ********************************************************************/
6665 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6666 char *srv_name, uint32 access_mask)
6668 DEBUG(5, ("init_samr_q_connect\n"));
6670 /* make PDC server name \\server */
6671 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6672 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6674 /* example values: 0x0000 0002 */
6675 q_u->access_mask = access_mask;
6678 /*******************************************************************
6679 reads or writes a structure.
6680 ********************************************************************/
6682 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6683 prs_struct *ps, int depth)
6685 if (q_u == NULL)
6686 return False;
6688 prs_debug(ps, depth, desc, "samr_io_q_connect");
6689 depth++;
6691 if(!prs_align(ps))
6692 return False;
6694 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6695 return False;
6696 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6697 return False;
6699 if(!prs_align(ps))
6700 return False;
6701 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6702 return False;
6704 return True;
6707 /*******************************************************************
6708 reads or writes a structure.
6709 ********************************************************************/
6711 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6712 prs_struct *ps, int depth)
6714 if (r_u == NULL)
6715 return False;
6717 prs_debug(ps, depth, desc, "samr_io_r_connect");
6718 depth++;
6720 if(!prs_align(ps))
6721 return False;
6723 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6724 return False;
6726 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6727 return False;
6729 return True;
6732 /*******************************************************************
6733 inits a SAMR_Q_CONNECT4 structure.
6734 ********************************************************************/
6736 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6737 char *srv_name, uint32 access_mask)
6739 DEBUG(5, ("init_samr_q_connect\n"));
6741 /* make PDC server name \\server */
6742 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6743 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6745 /* Only value we've seen, possibly an address type ? */
6746 q_u->unk_0 = 2;
6748 /* example values: 0x0000 0002 */
6749 q_u->access_mask = access_mask;
6752 /*******************************************************************
6753 reads or writes a structure.
6754 ********************************************************************/
6756 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6757 prs_struct *ps, int depth)
6759 if (q_u == NULL)
6760 return False;
6762 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6763 depth++;
6765 if(!prs_align(ps))
6766 return False;
6768 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6769 return False;
6770 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6771 return False;
6773 if(!prs_align(ps))
6774 return False;
6775 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6776 return False;
6777 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6778 return False;
6780 return True;
6783 /*******************************************************************
6784 reads or writes a structure.
6785 ********************************************************************/
6787 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6788 prs_struct *ps, int depth)
6790 if (r_u == NULL)
6791 return False;
6793 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6794 depth++;
6796 if(!prs_align(ps))
6797 return False;
6799 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6800 return False;
6802 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6803 return False;
6805 return True;
6808 /*******************************************************************
6809 inits a SAMR_Q_CONNECT_ANON structure.
6810 ********************************************************************/
6812 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6814 DEBUG(5, ("init_samr_q_connect_anon\n"));
6816 q_u->ptr = 1;
6817 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6818 q_u->unknown_1 = 0x01;
6819 q_u->access_mask = 0x20;
6822 /*******************************************************************
6823 reads or writes a structure.
6824 ********************************************************************/
6826 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6827 prs_struct *ps, int depth)
6829 if (q_u == NULL)
6830 return False;
6832 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6833 depth++;
6835 if(!prs_align(ps))
6836 return False;
6838 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6839 return False;
6840 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6841 return False;
6842 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6843 return False;
6844 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6845 return False;
6847 return True;
6850 /*******************************************************************
6851 reads or writes a structure.
6852 ********************************************************************/
6854 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6855 prs_struct *ps, int depth)
6857 if (r_u == NULL)
6858 return False;
6860 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6861 depth++;
6863 if(!prs_align(ps))
6864 return False;
6866 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6867 return False;
6869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6870 return False;
6872 return True;
6875 /*******************************************************************
6876 inits a SAMR_Q_GET_DOM_PWINFO structure.
6877 ********************************************************************/
6879 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6880 char *srv_name)
6882 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6884 q_u->ptr = 1;
6885 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
6886 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
6889 /*******************************************************************
6890 reads or writes a structure.
6891 ********************************************************************/
6893 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6894 prs_struct *ps, int depth)
6896 if (q_u == NULL)
6897 return False;
6899 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6900 depth++;
6902 if(!prs_align(ps))
6903 return False;
6905 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6906 return False;
6907 if (q_u->ptr != 0) {
6908 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6909 return False;
6910 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6911 return False;
6914 return True;
6917 /*******************************************************************
6918 reads or writes a structure.
6919 ********************************************************************/
6921 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6922 prs_struct *ps, int depth)
6924 if (r_u == NULL)
6925 return False;
6927 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6928 depth++;
6930 if(!prs_align(ps))
6931 return False;
6934 * see the Samba4 IDL for what these actually are.
6937 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0))
6938 return False;
6939 if(!prs_align(ps))
6940 return False;
6941 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6942 return False;
6944 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6945 return False;
6947 return True;
6950 /*******************************************************************
6951 make a SAMR_ENC_PASSWD structure.
6952 ********************************************************************/
6954 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
6956 ZERO_STRUCTP(pwd);
6958 if (pass == NULL) {
6959 pwd->ptr = 0;
6960 } else {
6961 pwd->ptr = 1;
6962 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6966 /*******************************************************************
6967 reads or writes a SAMR_ENC_PASSWD structure.
6968 ********************************************************************/
6970 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
6971 prs_struct *ps, int depth)
6973 if (pwd == NULL)
6974 return False;
6976 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6977 depth++;
6979 if(!prs_align(ps))
6980 return False;
6982 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6983 return False;
6985 if (pwd->ptr != 0) {
6986 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6987 return False;
6990 return True;
6993 /*******************************************************************
6994 inits a SAMR_ENC_HASH structure.
6995 ********************************************************************/
6997 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
6999 ZERO_STRUCTP(hsh);
7001 if (hash == NULL) {
7002 hsh->ptr = 0;
7003 } else {
7004 hsh->ptr = 1;
7005 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7009 /*******************************************************************
7010 reads or writes a SAMR_ENC_HASH structure.
7011 ********************************************************************/
7013 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7014 prs_struct *ps, int depth)
7016 if (hsh == NULL)
7017 return False;
7019 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7020 depth++;
7022 if(!prs_align(ps))
7023 return False;
7025 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7026 return False;
7027 if (hsh->ptr != 0) {
7028 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7029 return False;
7032 return True;
7035 /*******************************************************************
7036 inits a SAMR_R_GET_DOM_PWINFO structure.
7037 ********************************************************************/
7039 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7040 const char *dest_host, const char *user_name,
7041 const char nt_newpass[516],
7042 const uchar nt_oldhash[16],
7043 const char lm_newpass[516],
7044 const uchar lm_oldhash[16])
7046 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7048 q_u->ptr_0 = 1;
7049 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7050 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7052 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7053 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7055 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7056 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7058 q_u->unknown = 0x01;
7060 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7061 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7064 /*******************************************************************
7065 reads or writes a structure.
7066 ********************************************************************/
7068 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7069 prs_struct *ps, int depth)
7071 if (q_u == NULL)
7072 return False;
7074 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7075 depth++;
7077 if(!prs_align(ps))
7078 return False;
7080 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7081 return False;
7083 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7084 return False;
7085 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7086 return False;
7088 if(!prs_align(ps))
7089 return False;
7090 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7091 return False;
7092 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7093 return False;
7095 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7096 return False;
7097 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7098 return False;
7100 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7101 return False;
7103 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7104 return False;
7105 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7106 return False;
7108 return True;
7111 /*******************************************************************
7112 inits a SAMR_R_CHGPASSWD_USER structure.
7113 ********************************************************************/
7115 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7117 DEBUG(5, ("init_r_chgpasswd_user\n"));
7119 r_u->status = status;
7122 /*******************************************************************
7123 reads or writes a structure.
7124 ********************************************************************/
7126 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7127 prs_struct *ps, int depth)
7129 if (r_u == NULL)
7130 return False;
7132 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7133 depth++;
7135 if(!prs_align(ps))
7136 return False;
7138 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7139 return False;
7141 return True;
7144 /*******************************************************************
7145 reads or writes a structure.
7146 ********************************************************************/
7148 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7149 POLICY_HND *domain_pol, uint16 switch_value)
7151 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7153 q_u->domain_pol = *domain_pol;
7154 q_u->switch_value = switch_value;
7157 /*******************************************************************
7158 reads or writes a structure.
7159 ********************************************************************/
7161 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7162 prs_struct *ps, int depth)
7164 if (q_u == NULL)
7165 return False;
7167 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7168 depth++;
7170 if(!prs_align(ps))
7171 return False;
7173 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7174 return False;
7176 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7177 return False;
7179 return True;
7182 /*******************************************************************
7183 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7184 ********************************************************************/
7186 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7187 uint16 switch_value, SAM_UNK_CTR * ctr,
7188 NTSTATUS status)
7190 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7192 r_u->ptr_0 = 0;
7193 r_u->switch_value = 0;
7194 r_u->status = status; /* return status */
7196 if (NT_STATUS_IS_OK(status)) {
7197 r_u->switch_value = switch_value;
7198 r_u->ptr_0 = 1;
7199 r_u->ctr = ctr;
7203 /*******************************************************************
7204 reads or writes a structure.
7205 ********************************************************************/
7207 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7208 prs_struct *ps, int depth)
7210 if (r_u == NULL)
7211 return False;
7213 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7214 depth++;
7216 if(!prs_align(ps))
7217 return False;
7219 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7220 return False;
7222 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7223 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7224 return False;
7225 if(!prs_align(ps))
7226 return False;
7228 switch (r_u->switch_value) {
7229 case 0x0c:
7230 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7231 return False;
7232 break;
7233 case 0x07:
7234 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7235 return False;
7236 break;
7237 case 0x06:
7238 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7239 return False;
7240 break;
7241 case 0x05:
7242 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7243 return False;
7244 break;
7245 case 0x03:
7246 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7247 return False;
7248 break;
7249 case 0x02:
7250 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7251 return False;
7252 break;
7253 case 0x01:
7254 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7255 return False;
7256 break;
7257 default:
7258 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7259 r_u->switch_value));
7260 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7261 return False;
7265 if(!prs_align(ps))
7266 return False;
7268 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7269 return False;
7271 return True;
7275 /*******************************************************************
7276 reads or writes a structure.
7277 ********************************************************************/
7279 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7280 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7282 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7284 q_u->domain_pol = *domain_pol;
7285 q_u->switch_value0 = switch_value;
7287 q_u->switch_value = switch_value;
7288 q_u->ctr = ctr;
7292 /*******************************************************************
7293 reads or writes a structure.
7294 ********************************************************************/
7296 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7297 prs_struct *ps, int depth)
7299 if (q_u == NULL)
7300 return False;
7302 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7303 depth++;
7305 if(!prs_align(ps))
7306 return False;
7308 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7309 return False;
7311 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7312 return False;
7314 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7315 return False;
7317 if(!prs_align(ps))
7318 return False;
7320 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7321 return False;
7323 switch (q_u->switch_value) {
7325 case 0x0c:
7326 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7327 return False;
7328 break;
7329 case 0x07:
7330 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7331 return False;
7332 break;
7333 case 0x06:
7334 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7335 return False;
7336 break;
7337 case 0x05:
7338 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7339 return False;
7340 break;
7341 case 0x03:
7342 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7343 return False;
7344 break;
7345 case 0x02:
7346 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7347 return False;
7348 break;
7349 case 0x01:
7350 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7351 return False;
7352 break;
7353 default:
7354 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7355 q_u->switch_value));
7356 return False;
7359 return True;
7362 /*******************************************************************
7363 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7364 ********************************************************************/
7366 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7368 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7370 r_u->status = status; /* return status */
7373 /*******************************************************************
7374 reads or writes a structure.
7375 ********************************************************************/
7377 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7378 prs_struct *ps, int depth)
7380 if (r_u == NULL)
7381 return False;
7383 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7384 depth++;
7386 if(!prs_align(ps))
7387 return False;
7389 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7390 return False;
7392 return True;