Add SAMR 0x3e, which is samr_connect4. Seems to be the same as our
[Samba/gebeck_regimport.git] / source3 / rpc_parse / parse_samr.c
blob5131f3b4f2301e9383871b319df60c1ed1cbd358
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) Anthony Liguori 2002,
11 * Copyright (C) Jim McDonough 2002.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "includes.h"
29 #include "rpc_parse.h"
30 #include "nterr.h"
32 #undef DBGC_CLASS
33 #define DBGC_CLASS DBGC_RPC_PARSE
35 /*******************************************************************
36 inits a SAMR_Q_CLOSE_HND structure.
37 ********************************************************************/
39 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
41 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 q_c->pol = *hnd;
46 /*******************************************************************
47 reads or writes a structure.
48 ********************************************************************/
50 BOOL samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND * q_u,
51 prs_struct *ps, int depth)
53 if (q_u == NULL)
54 return False;
56 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
57 depth++;
59 if(!prs_align(ps))
60 return False;
62 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
65 /*******************************************************************
66 reads or writes a structure.
67 ********************************************************************/
69 BOOL samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND * r_u,
70 prs_struct *ps, int depth)
72 if (r_u == NULL)
73 return False;
75 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
76 depth++;
78 if(!prs_align(ps))
79 return False;
81 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
82 return False;
84 if(!prs_ntstatus("status", ps, depth, &r_u->status))
85 return False;
87 return True;
90 /*******************************************************************
91 inits a SAMR_Q_LOOKUP_DOMAIN structure.
92 ********************************************************************/
94 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
95 POLICY_HND *pol, char *dom_name)
97 int len_name = strlen(dom_name);
99 DEBUG(5, ("init_samr_q_lookup_domain\n"));
101 q_u->connect_pol = *pol;
103 init_uni_hdr(&q_u->hdr_domain, len_name);
104 init_unistr2(&q_u->uni_domain, dom_name, len_name);
107 /*******************************************************************
108 reads or writes a structure.
109 ********************************************************************/
110 BOOL samr_io_q_lookup_domain(char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
111 prs_struct *ps, int depth)
113 if (q_u == NULL)
114 return False;
116 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
117 depth++;
119 if(!prs_align(ps))
120 return False;
122 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
123 return False;
125 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
126 return False;
128 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
129 return False;
131 return True;
134 /*******************************************************************
135 inits a SAMR_R_LOOKUP_DOMAIN structure.
136 ********************************************************************/
138 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
139 DOM_SID *dom_sid, NTSTATUS status)
141 DEBUG(5, ("init_samr_r_lookup_domain\n"));
143 r_u->status = status;
144 r_u->ptr_sid = 0;
145 if (NT_STATUS_IS_OK(status)) {
146 r_u->ptr_sid = 1;
147 init_dom_sid2(&r_u->dom_sid, dom_sid);
151 /*******************************************************************
152 reads or writes a structure.
153 ********************************************************************/
155 BOOL samr_io_r_lookup_domain(char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
156 prs_struct *ps, int depth)
158 if (r_u == NULL)
159 return False;
161 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
162 depth++;
164 if(!prs_align(ps))
165 return False;
167 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
168 return False;
170 if (r_u->ptr_sid != 0) {
171 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
172 return False;
173 if(!prs_align(ps))
174 return False;
177 if(!prs_ntstatus("status", ps, depth, &r_u->status))
178 return False;
180 return True;
183 /*******************************************************************
184 reads or writes a structure.
185 ********************************************************************/
187 void init_samr_q_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
189 DEBUG(5, ("samr_init_samr_q_unknown_2d\n"));
191 q_u->dom_pol = *dom_pol;
192 init_dom_sid2(&q_u->sid, sid);
195 /*******************************************************************
196 reads or writes a structure.
197 ********************************************************************/
199 BOOL samr_io_q_unknown_2d(char *desc, SAMR_Q_UNKNOWN_2D * q_u,
200 prs_struct *ps, int depth)
202 if (q_u == NULL)
203 return False;
205 prs_debug(ps, depth, desc, "samr_io_q_unknown_2d");
206 depth++;
208 if(!prs_align(ps))
209 return False;
211 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
212 return False;
214 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
215 return False;
217 if(!prs_align(ps))
218 return False;
220 return True;
223 /*******************************************************************
224 reads or writes a structure.
225 ********************************************************************/
227 BOOL samr_io_r_unknown_2d(char *desc, SAMR_R_UNKNOWN_2D * r_u,
228 prs_struct *ps, int depth)
230 if (r_u == NULL)
231 return False;
233 prs_debug(ps, depth, desc, "samr_io_r_unknown_2d");
234 depth++;
236 if(!prs_align(ps))
237 return False;
239 if(!prs_ntstatus("status", ps, depth, &r_u->status))
240 return False;
242 return True;
245 /*******************************************************************
246 reads or writes a structure.
247 ********************************************************************/
249 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
250 POLICY_HND *pol, uint32 flags,
251 const DOM_SID *sid)
253 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
255 q_u->pol = *pol;
256 q_u->flags = flags;
257 init_dom_sid2(&q_u->dom_sid, sid);
260 /*******************************************************************
261 reads or writes a structure.
262 ********************************************************************/
264 BOOL samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
265 prs_struct *ps, int depth)
267 if (q_u == NULL)
268 return False;
270 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
271 depth++;
273 if(!prs_align(ps))
274 return False;
276 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
277 return False;
279 if(!prs_uint32("flags", ps, depth, &q_u->flags))
280 return False;
282 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
283 return False;
285 return True;
288 /*******************************************************************
289 reads or writes a structure.
290 ********************************************************************/
292 BOOL samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN * r_u,
293 prs_struct *ps, int depth)
295 if (r_u == NULL)
296 return False;
298 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
299 depth++;
301 if(!prs_align(ps))
302 return False;
304 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
305 return False;
307 if(!prs_ntstatus("status", ps, depth, &r_u->status))
308 return False;
310 return True;
313 /*******************************************************************
314 reads or writes a structure.
315 ********************************************************************/
317 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
318 POLICY_HND *user_pol)
320 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
322 q_u->user_pol = *user_pol;
325 /*******************************************************************
326 reads or writes a structure.
327 ********************************************************************/
329 BOOL samr_io_q_get_usrdom_pwinfo(char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
330 prs_struct *ps, int depth)
332 if (q_u == NULL)
333 return False;
335 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
336 depth++;
338 if(!prs_align(ps))
339 return False;
341 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
344 /*******************************************************************
345 Init.
346 ********************************************************************/
348 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
350 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
352 r_u->unknown_0 = 0x0000;
355 * used to be
356 * r_u->unknown_1 = 0x0015;
357 * but for trusts.
359 r_u->unknown_1 = 0x01D1;
360 r_u->unknown_1 = 0x0015;
362 r_u->unknown_2 = 0x00000000;
364 r_u->status = status;
367 /*******************************************************************
368 reads or writes a structure.
369 ********************************************************************/
371 BOOL samr_io_r_get_usrdom_pwinfo(char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
372 prs_struct *ps, int depth)
374 if (r_u == NULL)
375 return False;
377 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
378 depth++;
380 if(!prs_align(ps))
381 return False;
383 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
384 return False;
385 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
386 return False;
387 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
388 return False;
389 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
390 return False;
392 return True;
396 /*******************************************************************
397 reads or writes a structure.
398 ********************************************************************/
400 BOOL samr_io_q_set_sec_obj(char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
401 prs_struct *ps, int depth)
403 if (q_u == NULL)
404 return False;
406 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
407 depth++;
409 if(!prs_align(ps))
410 return False;
412 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
413 return False;
415 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
416 return False;
418 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
419 return False;
421 return True;
425 /*******************************************************************
426 reads or writes a structure.
427 ********************************************************************/
429 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
430 POLICY_HND *user_pol, uint32 sec_info)
432 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
434 q_u->user_pol = *user_pol;
435 q_u->sec_info = sec_info;
439 /*******************************************************************
440 reads or writes a structure.
441 ********************************************************************/
443 BOOL samr_io_q_query_sec_obj(char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
444 prs_struct *ps, int depth)
446 if (q_u == NULL)
447 return False;
449 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
450 depth++;
452 if(!prs_align(ps))
453 return False;
455 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
456 return False;
458 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
459 return False;
461 return True;
464 /*******************************************************************
465 reads or writes a structure.
466 ********************************************************************/
468 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
469 POLICY_HND *domain_pol, uint16 switch_value)
471 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
473 q_u->domain_pol = *domain_pol;
474 q_u->switch_value = switch_value;
477 /*******************************************************************
478 reads or writes a structure.
479 ********************************************************************/
481 BOOL samr_io_q_query_dom_info(char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
482 prs_struct *ps, int depth)
484 if (q_u == NULL)
485 return False;
487 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
488 depth++;
490 if(!prs_align(ps))
491 return False;
493 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
494 return False;
496 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
497 return False;
499 return True;
503 /*******************************************************************
504 inits a structure.
505 ********************************************************************/
507 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
509 u_3->logout.low = nt_logout.low;
510 u_3->logout.high = nt_logout.high;
513 /*******************************************************************
514 reads or writes a structure.
515 ********************************************************************/
517 static BOOL sam_io_unk_info3(char *desc, SAM_UNK_INFO_3 * u_3,
518 prs_struct *ps, int depth)
520 if (u_3 == NULL)
521 return False;
523 prs_debug(ps, depth, desc, "sam_io_unk_info3");
524 depth++;
526 if(!smb_io_time("logout", &u_3->logout, ps, depth))
527 return False;
529 return True;
532 /*******************************************************************
533 inits a structure.
534 ********************************************************************/
536 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
538 u_6->unknown_0 = 0x00000000;
539 u_6->ptr_0 = 1;
540 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
543 /*******************************************************************
544 reads or writes a structure.
545 ********************************************************************/
547 static BOOL sam_io_unk_info6(char *desc, SAM_UNK_INFO_6 * u_6,
548 prs_struct *ps, int depth)
550 if (u_6 == NULL)
551 return False;
553 prs_debug(ps, depth, desc, "sam_io_unk_info6");
554 depth++;
556 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
557 return False;
558 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
559 return False;
560 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
561 return False;
563 return True;
566 /*******************************************************************
567 inits a structure.
568 ********************************************************************/
570 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
572 u_7->unknown_0 = 0x0003;
575 /*******************************************************************
576 reads or writes a structure.
577 ********************************************************************/
579 static BOOL sam_io_unk_info7(char *desc, SAM_UNK_INFO_7 * u_7,
580 prs_struct *ps, int depth)
582 if (u_7 == NULL)
583 return False;
585 prs_debug(ps, depth, desc, "sam_io_unk_info7");
586 depth++;
588 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
589 return False;
591 return True;
594 /*******************************************************************
595 inits a structure.
596 ********************************************************************/
598 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
600 u_12->duration.low = nt_lock_duration.low;
601 u_12->duration.high = nt_lock_duration.high;
602 u_12->reset_count.low = nt_reset_time.low;
603 u_12->reset_count.high = nt_reset_time.high;
605 u_12->bad_attempt_lockout = lockout;
608 /*******************************************************************
609 reads or writes a structure.
610 ********************************************************************/
612 static BOOL sam_io_unk_info12(char *desc, SAM_UNK_INFO_12 * u_12,
613 prs_struct *ps, int depth)
615 if (u_12 == NULL)
616 return False;
618 prs_debug(ps, depth, desc, "sam_io_unk_info12");
619 depth++;
621 if(!smb_io_time("duration", &u_12->duration, ps, depth))
622 return False;
623 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
624 return False;
625 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
626 return False;
628 return True;
631 /*******************************************************************
632 inits a structure.
633 ********************************************************************/
634 void init_unk_info5(SAM_UNK_INFO_5 * u_5,char *server)
636 int len_server = strlen(server);
638 init_uni_hdr(&u_5->hdr_server, len_server);
640 init_unistr2(&u_5->uni_server, server, len_server);
643 /*******************************************************************
644 reads or writes a structure.
645 ********************************************************************/
647 static BOOL sam_io_unk_info5(char *desc, SAM_UNK_INFO_5 * u_5,
648 prs_struct *ps, int depth)
650 if (u_5 == NULL)
651 return False;
653 prs_debug(ps, depth, desc, "sam_io_unk_info5");
654 depth++;
656 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
657 return False;
659 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
660 return False;
662 return True;
665 /*******************************************************************
666 inits a structure.
667 ********************************************************************/
668 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
669 char *domain, char *server,
670 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
672 int len_domain = strlen(domain);
673 int len_server = strlen(server);
675 u_2->unknown_0 = 0x00000000;
676 u_2->unknown_1 = 0x80000000;
677 u_2->unknown_2 = 0x00000000;
679 u_2->ptr_0 = 1;
680 init_uni_hdr(&u_2->hdr_domain, len_domain);
681 init_uni_hdr(&u_2->hdr_server, len_server);
683 u_2->seq_num = seq_num;
684 u_2->unknown_3 = 0x00000000;
686 u_2->unknown_4 = 0x00000001;
687 u_2->unknown_5 = 0x00000003;
688 u_2->unknown_6 = 0x00000001;
689 u_2->num_domain_usrs = num_users;
690 u_2->num_domain_grps = num_groups;
691 u_2->num_local_grps = num_alias;
693 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
695 init_unistr2(&u_2->uni_domain, domain, len_domain);
696 init_unistr2(&u_2->uni_server, server, len_server);
699 /*******************************************************************
700 reads or writes a structure.
701 ********************************************************************/
703 static BOOL sam_io_unk_info2(char *desc, SAM_UNK_INFO_2 * u_2,
704 prs_struct *ps, int depth)
706 if (u_2 == NULL)
707 return False;
709 prs_debug(ps, depth, desc, "sam_io_unk_info2");
710 depth++;
712 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
713 return False;
714 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
715 return False;
716 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
717 return False;
719 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
720 return False;
721 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
722 return False;
723 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
724 return False;
726 /* put all the data in here, at the moment, including what the above
727 pointer is referring to
730 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
731 return False;
732 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
733 return False;
735 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
736 return False;
737 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
738 return False;
739 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
740 return False;
741 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
742 return False;
743 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
744 return False;
745 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
746 return False;
748 if(!prs_uint8s(False, "padding", ps, depth, u_2->padding,sizeof(u_2->padding)))
749 return False;
751 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
752 return False;
753 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
754 return False;
756 return True;
759 /*******************************************************************
760 inits a structure.
761 ********************************************************************/
763 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
764 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
766 u_1->min_length_password = min_pass_len;
767 u_1->password_history = pass_hist;
768 u_1->flag = flag;
770 /* password never expire */
771 u_1->expire.high = nt_expire.high;
772 u_1->expire.low = nt_expire.low;
774 /* can change the password now */
775 u_1->min_passwordage.high = nt_min_age.high;
776 u_1->min_passwordage.low = nt_min_age.low;
780 /*******************************************************************
781 reads or writes a structure.
782 ********************************************************************/
784 static BOOL sam_io_unk_info1(char *desc, SAM_UNK_INFO_1 * u_1,
785 prs_struct *ps, int depth)
787 if (u_1 == NULL)
788 return False;
790 prs_debug(ps, depth, desc, "sam_io_unk_info1");
791 depth++;
793 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
794 return False;
795 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
796 return False;
797 if(!prs_uint32("flag", ps, depth, &u_1->flag))
798 return False;
799 if(!smb_io_time("expire", &u_1->expire, ps, depth))
800 return False;
801 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
802 return False;
804 return True;
807 /*******************************************************************
808 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
809 ********************************************************************/
811 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
812 uint16 switch_value, SAM_UNK_CTR * ctr,
813 NTSTATUS status)
815 DEBUG(5, ("init_samr_r_query_dom_info\n"));
817 r_u->ptr_0 = 0;
818 r_u->switch_value = 0;
819 r_u->status = status; /* return status */
821 if (NT_STATUS_IS_OK(status)) {
822 r_u->switch_value = switch_value;
823 r_u->ptr_0 = 1;
824 r_u->ctr = ctr;
828 /*******************************************************************
829 reads or writes a structure.
830 ********************************************************************/
832 BOOL samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
833 prs_struct *ps, int depth)
835 if (r_u == NULL)
836 return False;
838 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
839 depth++;
841 if(!prs_align(ps))
842 return False;
844 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
845 return False;
847 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
848 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
849 return False;
850 if(!prs_align(ps))
851 return False;
853 switch (r_u->switch_value) {
854 case 0x0c:
855 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
856 return False;
857 break;
858 case 0x07:
859 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
860 return False;
861 break;
862 case 0x06:
863 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
864 return False;
865 break;
866 case 0x05:
867 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
868 return False;
869 break;
870 case 0x03:
871 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
872 return False;
873 break;
874 case 0x02:
875 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
876 return False;
877 break;
878 case 0x01:
879 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
880 return False;
881 break;
882 default:
883 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
884 r_u->switch_value));
885 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
886 return False;
890 if(!prs_align(ps))
891 return False;
893 if(!prs_ntstatus("status", ps, depth, &r_u->status))
894 return False;
896 return True;
899 /*******************************************************************
900 reads or writes a SAMR_R_SET_SEC_OBJ structure.
901 ********************************************************************/
903 BOOL samr_io_r_set_sec_obj(char *desc, SAMR_R_SET_SEC_OBJ * r_u,
904 prs_struct *ps, int depth)
906 if (r_u == NULL)
907 return False;
909 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
910 depth++;
912 if(!prs_align(ps))
913 return False;
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
916 return False;
918 return True;
921 /*******************************************************************
922 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
923 ********************************************************************/
925 BOOL samr_io_r_query_sec_obj(char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
926 prs_struct *ps, int depth)
928 if (r_u == NULL)
929 return False;
931 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
932 depth++;
934 if(!prs_align(ps))
935 return False;
937 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
938 return False;
939 if (r_u->ptr != 0) {
940 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
941 return False;
944 if(!prs_ntstatus("status", ps, depth, &r_u->status))
945 return False;
947 return True;
950 /*******************************************************************
951 reads or writes a SAM_STR1 structure.
952 ********************************************************************/
954 static BOOL sam_io_sam_str1(char *desc, SAM_STR1 * sam, uint32 acct_buf,
955 uint32 name_buf, uint32 desc_buf,
956 prs_struct *ps, int depth)
958 if (sam == NULL)
959 return False;
961 prs_debug(ps, depth, desc, "sam_io_sam_str1");
962 depth++;
964 if(!prs_align(ps))
965 return False;
966 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
967 return False;
969 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
970 return False;
972 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
973 return False;
975 return True;
978 /*******************************************************************
979 inits a SAM_ENTRY1 structure.
980 ********************************************************************/
982 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
983 uint32 len_sam_name, uint32 len_sam_full,
984 uint32 len_sam_desc, uint32 rid_user,
985 uint16 acb_info)
987 DEBUG(5, ("init_sam_entry1\n"));
989 ZERO_STRUCTP(sam);
991 sam->user_idx = user_idx;
992 sam->rid_user = rid_user;
993 sam->acb_info = acb_info;
995 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
996 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
997 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
1000 /*******************************************************************
1001 reads or writes a SAM_ENTRY1 structure.
1002 ********************************************************************/
1004 static BOOL sam_io_sam_entry1(char *desc, SAM_ENTRY1 * sam,
1005 prs_struct *ps, int depth)
1007 if (sam == NULL)
1008 return False;
1010 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1011 depth++;
1013 if(!prs_align(ps))
1014 return False;
1016 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1017 return False;
1019 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1020 return False;
1021 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1022 return False;
1024 if(!prs_align(ps))
1025 return False;
1027 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1028 return False;
1029 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1030 return False;
1031 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1032 return False;
1034 return True;
1037 /*******************************************************************
1038 reads or writes a SAM_STR2 structure.
1039 ********************************************************************/
1041 static BOOL sam_io_sam_str2(char *desc, SAM_STR2 * sam, uint32 acct_buf,
1042 uint32 desc_buf, prs_struct *ps, int depth)
1044 if (sam == NULL)
1045 return False;
1047 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1048 depth++;
1050 if(!prs_align(ps))
1051 return False;
1053 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1054 return False;
1055 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1056 return False;
1058 return True;
1061 /*******************************************************************
1062 inits a SAM_ENTRY2 structure.
1063 ********************************************************************/
1064 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1065 uint32 len_sam_name, uint32 len_sam_desc,
1066 uint32 rid_user, uint16 acb_info)
1068 DEBUG(5, ("init_sam_entry2\n"));
1070 sam->user_idx = user_idx;
1071 sam->rid_user = rid_user;
1072 sam->acb_info = acb_info;
1074 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1075 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1078 /*******************************************************************
1079 reads or writes a SAM_ENTRY2 structure.
1080 ********************************************************************/
1082 static BOOL sam_io_sam_entry2(char *desc, SAM_ENTRY2 * sam,
1083 prs_struct *ps, int depth)
1085 if (sam == NULL)
1086 return False;
1088 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1089 depth++;
1091 if(!prs_align(ps))
1092 return False;
1094 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1095 return False;
1097 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1098 return False;
1099 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1100 return False;
1102 if(!prs_align(ps))
1103 return False;
1105 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1106 return False;
1107 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1108 return False;
1110 return True;
1113 /*******************************************************************
1114 reads or writes a SAM_STR3 structure.
1115 ********************************************************************/
1117 static BOOL sam_io_sam_str3(char *desc, SAM_STR3 * sam, uint32 acct_buf,
1118 uint32 desc_buf, prs_struct *ps, int depth)
1120 if (sam == NULL)
1121 return False;
1123 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1124 depth++;
1126 if(!prs_align(ps))
1127 return False;
1129 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1130 return False;
1131 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1132 return False;
1134 return True;
1137 /*******************************************************************
1138 inits a SAM_ENTRY3 structure.
1139 ********************************************************************/
1141 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1142 uint32 len_grp_name, uint32 len_grp_desc,
1143 uint32 rid_grp)
1145 DEBUG(5, ("init_sam_entry3\n"));
1147 sam->grp_idx = grp_idx;
1148 sam->rid_grp = rid_grp;
1149 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1151 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1152 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1155 /*******************************************************************
1156 reads or writes a SAM_ENTRY3 structure.
1157 ********************************************************************/
1159 static BOOL sam_io_sam_entry3(char *desc, SAM_ENTRY3 * sam,
1160 prs_struct *ps, int depth)
1162 if (sam == NULL)
1163 return False;
1165 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1166 depth++;
1168 if(!prs_align(ps))
1169 return False;
1171 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1172 return False;
1174 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1175 return False;
1176 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1177 return False;
1179 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1180 return False;
1181 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1182 return False;
1184 return True;
1187 /*******************************************************************
1188 inits a SAM_ENTRY4 structure.
1189 ********************************************************************/
1191 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1192 uint32 len_acct_name)
1194 DEBUG(5, ("init_sam_entry4\n"));
1196 sam->user_idx = user_idx;
1197 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1200 /*******************************************************************
1201 reads or writes a SAM_ENTRY4 structure.
1202 ********************************************************************/
1204 static BOOL sam_io_sam_entry4(char *desc, SAM_ENTRY4 * sam,
1205 prs_struct *ps, int depth)
1207 if (sam == NULL)
1208 return False;
1210 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1211 depth++;
1213 if(!prs_align(ps))
1214 return False;
1216 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1217 return False;
1218 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1219 return False;
1221 return True;
1224 /*******************************************************************
1225 inits a SAM_ENTRY5 structure.
1226 ********************************************************************/
1228 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1229 uint32 len_grp_name)
1231 DEBUG(5, ("init_sam_entry5\n"));
1233 sam->grp_idx = grp_idx;
1234 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1235 len_grp_name != 0);
1238 /*******************************************************************
1239 reads or writes a SAM_ENTRY5 structure.
1240 ********************************************************************/
1242 static BOOL sam_io_sam_entry5(char *desc, SAM_ENTRY5 * sam,
1243 prs_struct *ps, int depth)
1245 if (sam == NULL)
1246 return False;
1248 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1249 depth++;
1251 if(!prs_align(ps))
1252 return False;
1254 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1255 return False;
1256 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1257 return False;
1259 return True;
1262 /*******************************************************************
1263 inits a SAM_ENTRY structure.
1264 ********************************************************************/
1266 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1268 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1270 sam->rid = rid;
1271 init_uni_hdr(&sam->hdr_name, len_sam_name);
1274 /*******************************************************************
1275 reads or writes a SAM_ENTRY structure.
1276 ********************************************************************/
1278 static BOOL sam_io_sam_entry(char *desc, SAM_ENTRY * sam,
1279 prs_struct *ps, int depth)
1281 if (sam == NULL)
1282 return False;
1284 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1285 depth++;
1287 if(!prs_align(ps))
1288 return False;
1289 if(!prs_uint32("rid", ps, depth, &sam->rid))
1290 return False;
1291 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1292 return False;
1294 return True;
1297 /*******************************************************************
1298 inits a SAMR_Q_ENUM_DOM_USERS structure.
1299 ********************************************************************/
1301 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1302 uint32 start_idx,
1303 uint16 acb_mask, uint16 unk_1, uint32 size)
1305 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1307 q_e->pol = *pol;
1309 q_e->start_idx = start_idx; /* zero indicates lots */
1310 q_e->acb_mask = acb_mask;
1311 q_e->unknown_1 = unk_1;
1312 q_e->max_size = size;
1315 /*******************************************************************
1316 reads or writes a structure.
1317 ********************************************************************/
1319 BOOL samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1320 prs_struct *ps, int depth)
1322 if (q_e == NULL)
1323 return False;
1325 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1326 depth++;
1328 if(!prs_align(ps))
1329 return False;
1331 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1332 return False;
1334 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1335 return False;
1336 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1337 return False;
1338 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1339 return False;
1341 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1342 return False;
1344 return True;
1348 /*******************************************************************
1349 inits a SAMR_R_ENUM_DOM_USERS structure.
1350 ********************************************************************/
1352 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1353 uint32 next_idx, uint32 num_sam_entries)
1355 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1357 r_u->next_idx = next_idx;
1359 if (num_sam_entries != 0) {
1360 r_u->ptr_entries1 = 1;
1361 r_u->ptr_entries2 = 1;
1362 r_u->num_entries2 = num_sam_entries;
1363 r_u->num_entries3 = num_sam_entries;
1365 r_u->num_entries4 = num_sam_entries;
1366 } else {
1367 r_u->ptr_entries1 = 0;
1368 r_u->num_entries2 = num_sam_entries;
1369 r_u->ptr_entries2 = 1;
1373 /*******************************************************************
1374 reads or writes a structure.
1375 ********************************************************************/
1377 BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1378 prs_struct *ps, int depth)
1380 uint32 i;
1382 if (r_u == NULL)
1383 return False;
1385 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1386 depth++;
1388 if(!prs_align(ps))
1389 return False;
1391 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1392 return False;
1393 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1394 return False;
1396 if (r_u->ptr_entries1 != 0) {
1397 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1398 return False;
1399 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1400 return False;
1401 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1402 return False;
1404 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1405 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1406 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1409 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1410 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1411 r_u->num_entries4 = 0;
1412 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1413 return False;
1416 for (i = 0; i < r_u->num_entries2; i++) {
1417 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1418 return False;
1421 for (i = 0; i < r_u->num_entries2; i++) {
1422 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1423 return False;
1428 if(!prs_align(ps))
1429 return False;
1431 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1432 return False;
1433 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1434 return False;
1436 return True;
1439 /*******************************************************************
1440 inits a SAMR_Q_QUERY_DISPINFO structure.
1441 ********************************************************************/
1443 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1444 uint16 switch_level, uint32 start_idx,
1445 uint32 max_entries)
1447 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1449 q_e->domain_pol = *pol;
1451 q_e->switch_level = switch_level;
1453 q_e->start_idx = start_idx;
1454 q_e->max_entries = max_entries;
1455 q_e->max_size = 0xffff; /* Not especially useful */
1458 /*******************************************************************
1459 reads or writes a structure.
1460 ********************************************************************/
1462 BOOL samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1463 prs_struct *ps, int depth)
1465 if (q_e == NULL)
1466 return False;
1468 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1469 depth++;
1471 if(!prs_align(ps))
1472 return False;
1474 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1475 return False;
1477 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1478 return False;
1479 if(!prs_align(ps))
1480 return False;
1482 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1483 return False;
1484 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1485 return False;
1486 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1487 return False;
1489 return True;
1492 /*******************************************************************
1493 inits a SAM_DISPINFO_1 structure.
1494 ********************************************************************/
1496 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1497 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1498 DOM_SID *domain_sid)
1500 uint32 len_sam_name, len_sam_full, len_sam_desc;
1501 uint32 i;
1503 SAM_ACCOUNT *pwd = NULL;
1504 ZERO_STRUCTP(sam);
1506 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1508 if (num_entries==0)
1509 return NT_STATUS_OK;
1511 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1512 if (!sam->sam)
1513 return NT_STATUS_NO_MEMORY;
1515 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1516 if (!sam->str)
1517 return NT_STATUS_NO_MEMORY;
1519 ZERO_STRUCTP(sam->sam);
1520 ZERO_STRUCTP(sam->str);
1522 for (i = 0; i < num_entries ; i++) {
1523 const char *username;
1524 const char *fullname;
1525 const char *acct_desc;
1526 uint32 user_rid;
1527 const DOM_SID *user_sid;
1528 fstring user_sid_string, domain_sid_string;
1530 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1532 pwd=disp_user_info[i+start_idx].sam;
1534 username = pdb_get_username(pwd);
1535 fullname = pdb_get_fullname(pwd);
1536 acct_desc = pdb_get_acct_desc(pwd);
1538 if (!username)
1539 username = "";
1541 if (!fullname)
1542 fullname = "";
1544 if (!acct_desc)
1545 acct_desc = "";
1547 user_sid = pdb_get_user_sid(pwd);
1549 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1550 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1551 "the domain sid %s. Failing operation.\n",
1552 username,
1553 sid_to_string(user_sid_string, user_sid),
1554 sid_to_string(domain_sid_string, domain_sid)));
1555 return NT_STATUS_UNSUCCESSFUL;
1558 len_sam_name = strlen(username);
1559 len_sam_full = strlen(fullname);
1560 len_sam_desc = strlen(acct_desc);
1562 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1563 len_sam_name, len_sam_full, len_sam_desc,
1564 user_rid, pdb_get_acct_ctrl(pwd));
1566 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1567 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1568 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1570 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1571 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1572 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1575 return NT_STATUS_OK;
1578 /*******************************************************************
1579 reads or writes a structure.
1580 ********************************************************************/
1582 static BOOL sam_io_sam_dispinfo_1(char *desc, SAM_DISPINFO_1 * sam,
1583 uint32 num_entries,
1584 prs_struct *ps, int depth)
1586 uint32 i;
1588 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1589 depth++;
1591 if(!prs_align(ps))
1592 return False;
1594 if (UNMARSHALLING(ps) && num_entries > 0) {
1596 if ((sam->sam = (SAM_ENTRY1 *)
1597 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1598 num_entries)) == NULL) {
1599 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1600 return False;
1603 if ((sam->str = (SAM_STR1 *)
1604 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1605 num_entries)) == NULL) {
1606 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1607 return False;
1611 for (i = 0; i < num_entries; i++) {
1612 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1613 return False;
1616 for (i = 0; i < num_entries; i++) {
1617 if(!sam_io_sam_str1("", &sam->str[i],
1618 sam->sam[i].hdr_acct_name.buffer,
1619 sam->sam[i].hdr_user_name.buffer,
1620 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1621 return False;
1624 return True;
1627 /*******************************************************************
1628 inits a SAM_DISPINFO_2 structure.
1629 ********************************************************************/
1631 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1632 uint32 start_idx, DISP_USER_INFO *disp_user_info,
1633 DOM_SID *domain_sid )
1635 uint32 len_sam_name, len_sam_desc;
1636 uint32 i;
1638 SAM_ACCOUNT *pwd = NULL;
1639 ZERO_STRUCTP(sam);
1641 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1643 if (num_entries==0)
1644 return NT_STATUS_OK;
1646 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1647 return NT_STATUS_NO_MEMORY;
1649 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1650 return NT_STATUS_NO_MEMORY;
1652 ZERO_STRUCTP(sam->sam);
1653 ZERO_STRUCTP(sam->str);
1655 for (i = 0; i < num_entries; i++) {
1656 uint32 user_rid;
1657 const DOM_SID *user_sid;
1658 const char *username;
1659 const char *acct_desc;
1660 fstring user_sid_string, domain_sid_string;
1662 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1663 pwd=disp_user_info[i+start_idx].sam;
1665 username = pdb_get_username(pwd);
1666 acct_desc = pdb_get_acct_desc(pwd);
1667 user_sid = pdb_get_user_sid(pwd);
1669 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1670 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1671 "the domain sid %s. Failing operation.\n",
1672 username,
1673 sid_to_string(user_sid_string, user_sid),
1674 sid_to_string(domain_sid_string, domain_sid)));
1675 return NT_STATUS_UNSUCCESSFUL;
1678 len_sam_name = strlen(username);
1679 len_sam_desc = strlen(acct_desc);
1681 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1682 len_sam_name, len_sam_desc,
1683 user_rid, pdb_get_acct_ctrl(pwd));
1685 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1686 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1688 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1689 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1692 return NT_STATUS_OK;
1695 /*******************************************************************
1696 reads or writes a structure.
1697 ********************************************************************/
1699 static BOOL sam_io_sam_dispinfo_2(char *desc, SAM_DISPINFO_2 * sam,
1700 uint32 num_entries,
1701 prs_struct *ps, int depth)
1703 uint32 i;
1705 if (sam == NULL)
1706 return False;
1708 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1709 depth++;
1711 if(!prs_align(ps))
1712 return False;
1714 if (UNMARSHALLING(ps) && num_entries > 0) {
1716 if ((sam->sam = (SAM_ENTRY2 *)
1717 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1718 num_entries)) == NULL) {
1719 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1720 return False;
1723 if ((sam->str = (SAM_STR2 *)
1724 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1725 num_entries)) == NULL) {
1726 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1727 return False;
1731 for (i = 0; i < num_entries; i++) {
1732 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1733 return False;
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_str2("", &sam->str[i],
1738 sam->sam[i].hdr_srv_name.buffer,
1739 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1740 return False;
1743 return True;
1746 /*******************************************************************
1747 inits a SAM_DISPINFO_3 structure.
1748 ********************************************************************/
1750 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1751 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1753 uint32 len_sam_name, len_sam_desc;
1754 uint32 i;
1756 ZERO_STRUCTP(sam);
1758 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1760 if (num_entries==0)
1761 return NT_STATUS_OK;
1763 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1764 return NT_STATUS_NO_MEMORY;
1766 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1767 return NT_STATUS_NO_MEMORY;
1769 ZERO_STRUCTP(sam->sam);
1770 ZERO_STRUCTP(sam->str);
1772 for (i = 0; i < num_entries; i++) {
1773 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1775 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1777 len_sam_name = strlen(grp->name);
1778 len_sam_desc = strlen(grp->comment);
1780 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1782 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1783 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1786 return NT_STATUS_OK;
1789 /*******************************************************************
1790 reads or writes a structure.
1791 ********************************************************************/
1793 static BOOL sam_io_sam_dispinfo_3(char *desc, SAM_DISPINFO_3 * sam,
1794 uint32 num_entries,
1795 prs_struct *ps, int depth)
1797 uint32 i;
1799 if (sam == NULL)
1800 return False;
1802 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1803 depth++;
1805 if(!prs_align(ps))
1806 return False;
1808 if (UNMARSHALLING(ps) && num_entries > 0) {
1810 if ((sam->sam = (SAM_ENTRY3 *)
1811 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1812 num_entries)) == NULL) {
1813 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1814 return False;
1817 if ((sam->str = (SAM_STR3 *)
1818 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1819 num_entries)) == NULL) {
1820 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1821 return False;
1825 for (i = 0; i < num_entries; i++) {
1826 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1827 return False;
1830 for (i = 0; i < num_entries; i++) {
1831 if(!sam_io_sam_str3("", &sam->str[i],
1832 sam->sam[i].hdr_grp_name.buffer,
1833 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1834 return False;
1837 return True;
1840 /*******************************************************************
1841 inits a SAM_DISPINFO_4 structure.
1842 ********************************************************************/
1844 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1845 uint32 start_idx, DISP_USER_INFO *disp_user_info)
1847 uint32 len_sam_name;
1848 uint32 i;
1850 SAM_ACCOUNT *pwd = NULL;
1851 ZERO_STRUCTP(sam);
1853 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1855 if (num_entries==0)
1856 return NT_STATUS_OK;
1858 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1859 return NT_STATUS_NO_MEMORY;
1861 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1862 return NT_STATUS_NO_MEMORY;
1864 ZERO_STRUCTP(sam->sam);
1865 ZERO_STRUCTP(sam->str);
1867 for (i = 0; i < num_entries; i++) {
1868 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1869 pwd=disp_user_info[i+start_idx].sam;
1871 len_sam_name = strlen(pdb_get_username(pwd));
1873 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1875 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1878 return NT_STATUS_OK;
1881 /*******************************************************************
1882 reads or writes a structure.
1883 ********************************************************************/
1885 static BOOL sam_io_sam_dispinfo_4(char *desc, SAM_DISPINFO_4 * sam,
1886 uint32 num_entries,
1887 prs_struct *ps, int depth)
1889 uint32 i;
1891 if (sam == NULL)
1892 return False;
1894 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1895 depth++;
1897 if(!prs_align(ps))
1898 return False;
1900 if (UNMARSHALLING(ps) && num_entries > 0) {
1902 if ((sam->sam = (SAM_ENTRY4 *)
1903 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1904 num_entries)) == NULL) {
1905 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1906 return False;
1909 if ((sam->str = (SAM_STR4 *)
1910 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1911 num_entries)) == NULL) {
1912 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1913 return False;
1917 for (i = 0; i < num_entries; i++) {
1918 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1919 return False;
1922 for (i = 0; i < num_entries; i++) {
1923 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1924 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1925 return False;
1928 return True;
1931 /*******************************************************************
1932 inits a SAM_DISPINFO_5 structure.
1933 ********************************************************************/
1935 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1936 uint32 start_idx, DISP_GROUP_INFO *disp_group_info)
1938 uint32 len_sam_name;
1939 uint32 i;
1941 ZERO_STRUCTP(sam);
1943 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1945 if (num_entries==0)
1946 return NT_STATUS_OK;
1948 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1949 return NT_STATUS_NO_MEMORY;
1951 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1952 return NT_STATUS_NO_MEMORY;
1954 ZERO_STRUCTP(sam->sam);
1955 ZERO_STRUCTP(sam->str);
1957 for (i = 0; i < num_entries; i++) {
1958 DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp;
1960 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1962 len_sam_name = strlen(grp->name);
1964 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1965 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1968 return NT_STATUS_OK;
1971 /*******************************************************************
1972 reads or writes a structure.
1973 ********************************************************************/
1975 static BOOL sam_io_sam_dispinfo_5(char *desc, SAM_DISPINFO_5 * sam,
1976 uint32 num_entries,
1977 prs_struct *ps, int depth)
1979 uint32 i;
1981 if (sam == NULL)
1982 return False;
1984 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1985 depth++;
1987 if(!prs_align(ps))
1988 return False;
1990 if (UNMARSHALLING(ps) && num_entries > 0) {
1992 if ((sam->sam = (SAM_ENTRY5 *)
1993 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1994 num_entries)) == NULL) {
1995 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1996 return False;
1999 if ((sam->str = (SAM_STR5 *)
2000 prs_alloc_mem(ps, sizeof(SAM_STR5) *
2001 num_entries)) == NULL) {
2002 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2003 return False;
2007 for (i = 0; i < num_entries; i++) {
2008 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2009 return False;
2012 for (i = 0; i < num_entries; i++) {
2013 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2014 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2015 return False;
2018 return True;
2021 /*******************************************************************
2022 inits a SAMR_R_QUERY_DISPINFO structure.
2023 ********************************************************************/
2025 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2026 uint32 num_entries, uint32 total_size, uint32 data_size,
2027 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2028 NTSTATUS status)
2030 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2032 r_u->total_size = total_size;
2034 r_u->data_size = data_size;
2036 r_u->switch_level = switch_level;
2037 r_u->num_entries = num_entries;
2039 if (num_entries==0)
2040 r_u->ptr_entries = 0;
2041 else
2042 r_u->ptr_entries = 1;
2044 r_u->num_entries2 = num_entries;
2045 r_u->ctr = ctr;
2047 r_u->status = status;
2050 /*******************************************************************
2051 reads or writes a structure.
2052 ********************************************************************/
2054 BOOL samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2055 prs_struct *ps, int depth)
2057 if (r_u == NULL)
2058 return False;
2060 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2061 depth++;
2063 if(!prs_align(ps))
2064 return False;
2066 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2067 return False;
2068 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2069 return False;
2070 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2071 return False;
2072 if(!prs_align(ps))
2073 return False;
2075 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2076 return False;
2077 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2078 return False;
2080 if (r_u->ptr_entries==0) {
2081 if(!prs_align(ps))
2082 return False;
2083 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2084 return False;
2086 return True;
2089 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2090 return False;
2092 switch (r_u->switch_level) {
2093 case 0x1:
2094 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2095 r_u->num_entries, ps, depth))
2096 return False;
2097 break;
2098 case 0x2:
2099 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2100 r_u->num_entries, ps, depth))
2101 return False;
2102 break;
2103 case 0x3:
2104 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2105 r_u->num_entries, ps, depth))
2106 return False;
2107 break;
2108 case 0x4:
2109 if(!sam_io_sam_dispinfo_4("user list",
2110 r_u->ctr->sam.info4,
2111 r_u->num_entries, ps, depth))
2112 return False;
2113 break;
2114 case 0x5:
2115 if(!sam_io_sam_dispinfo_5("group list",
2116 r_u->ctr->sam.info5,
2117 r_u->num_entries, ps, depth))
2118 return False;
2119 break;
2120 default:
2121 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2122 break;
2125 if(!prs_align(ps))
2126 return False;
2127 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2128 return False;
2130 return True;
2133 /*******************************************************************
2134 inits a SAMR_Q_OPEN_GROUP structure.
2135 ********************************************************************/
2137 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2138 POLICY_HND *hnd,
2139 uint32 access_mask, uint32 rid)
2141 DEBUG(5, ("init_samr_q_open_group\n"));
2143 q_c->domain_pol = *hnd;
2144 q_c->access_mask = access_mask;
2145 q_c->rid_group = rid;
2148 /*******************************************************************
2149 reads or writes a structure.
2150 ********************************************************************/
2152 BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP * q_u,
2153 prs_struct *ps, int depth)
2155 if (q_u == NULL)
2156 return False;
2158 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2159 depth++;
2161 if(!prs_align(ps))
2162 return False;
2164 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2165 return False;
2167 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2168 return False;
2169 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2170 return False;
2172 return True;
2175 /*******************************************************************
2176 reads or writes a structure.
2177 ********************************************************************/
2179 BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP * r_u,
2180 prs_struct *ps, int depth)
2182 if (r_u == NULL)
2183 return False;
2185 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2186 depth++;
2188 if(!prs_align(ps))
2189 return False;
2191 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2192 return False;
2194 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2195 return False;
2197 return True;
2200 /*******************************************************************
2201 inits a GROUP_INFO1 structure.
2202 ********************************************************************/
2204 void init_samr_group_info1(GROUP_INFO1 * gr1,
2205 char *acct_name, char *acct_desc,
2206 uint32 num_members)
2208 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2209 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2211 DEBUG(5, ("init_samr_group_info1\n"));
2213 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2215 gr1->unknown_1 = 0x3;
2216 gr1->num_members = num_members;
2218 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2220 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2221 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2224 /*******************************************************************
2225 reads or writes a structure.
2226 ********************************************************************/
2228 BOOL samr_io_group_info1(char *desc, GROUP_INFO1 * gr1,
2229 prs_struct *ps, int depth)
2231 if (gr1 == NULL)
2232 return False;
2234 prs_debug(ps, depth, desc, "samr_io_group_info1");
2235 depth++;
2237 if(!prs_align(ps))
2238 return False;
2240 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2241 return False;
2243 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2244 return False;
2245 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2246 return False;
2248 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2249 return False;
2251 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2252 gr1->hdr_acct_name.buffer, ps, depth))
2253 return False;
2255 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2256 gr1->hdr_acct_desc.buffer, ps, depth))
2257 return False;
2259 return True;
2262 /*******************************************************************
2263 inits a GROUP_INFO3 structure.
2264 ********************************************************************/
2266 void init_samr_group_info3(GROUP_INFO3 *gr3)
2268 DEBUG(5, ("init_samr_group_info3\n"));
2270 gr3->unknown_1 = 0x3;
2273 /*******************************************************************
2274 reads or writes a structure.
2275 ********************************************************************/
2277 BOOL samr_io_group_info3(char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2279 if (gr3 == NULL)
2280 return False;
2282 prs_debug(ps, depth, desc, "samr_io_group_info3");
2283 depth++;
2285 if(!prs_align(ps))
2286 return False;
2288 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2289 return False;
2291 return True;
2294 /*******************************************************************
2295 inits a GROUP_INFO4 structure.
2296 ********************************************************************/
2298 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2300 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2302 DEBUG(5, ("init_samr_group_info4\n"));
2304 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2305 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2308 /*******************************************************************
2309 reads or writes a structure.
2310 ********************************************************************/
2312 BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
2313 prs_struct *ps, int depth)
2315 if (gr4 == NULL)
2316 return False;
2318 prs_debug(ps, depth, desc, "samr_io_group_info4");
2319 depth++;
2321 if(!prs_align(ps))
2322 return False;
2324 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2325 return False;
2326 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2327 gr4->hdr_acct_desc.buffer, ps, depth))
2328 return False;
2330 return True;
2333 /*******************************************************************
2334 reads or writes a structure.
2335 ********************************************************************/
2337 static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
2338 prs_struct *ps, int depth)
2340 if (UNMARSHALLING(ps))
2341 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2343 if (*ctr == NULL)
2344 return False;
2346 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2347 depth++;
2349 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2350 return False;
2352 switch ((*ctr)->switch_value1) {
2353 case 1:
2354 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2355 return False;
2356 break;
2357 case 3:
2358 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2359 return False;
2360 break;
2361 case 4:
2362 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2363 return False;
2364 break;
2365 default:
2366 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2367 break;
2370 return True;
2373 /*******************************************************************
2374 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2375 ********************************************************************/
2377 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2378 POLICY_HND *pol, char *acct_desc,
2379 uint32 access_mask)
2381 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2383 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2385 q_e->pol = *pol;
2387 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2388 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2390 q_e->access_mask = access_mask;
2393 /*******************************************************************
2394 reads or writes a structure.
2395 ********************************************************************/
2397 BOOL samr_io_q_create_dom_group(char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2398 prs_struct *ps, int depth)
2400 if (q_e == NULL)
2401 return False;
2403 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2404 depth++;
2406 if(!prs_align(ps))
2407 return False;
2409 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2410 return False;
2412 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2413 return False;
2414 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2415 q_e->hdr_acct_desc.buffer, ps, depth))
2416 return False;
2418 if(!prs_align(ps))
2419 return False;
2420 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2421 return False;
2423 return True;
2426 /*******************************************************************
2427 reads or writes a structure.
2428 ********************************************************************/
2430 BOOL samr_io_r_create_dom_group(char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2431 prs_struct *ps, int depth)
2433 if (r_u == NULL)
2434 return False;
2436 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2437 depth++;
2439 if(!prs_align(ps))
2440 return False;
2442 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2443 return False;
2445 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2446 return False;
2447 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2448 return False;
2450 return True;
2453 /*******************************************************************
2454 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2455 ********************************************************************/
2457 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2458 POLICY_HND *hnd)
2460 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2462 q_c->group_pol = *hnd;
2465 /*******************************************************************
2466 reads or writes a structure.
2467 ********************************************************************/
2469 BOOL samr_io_q_delete_dom_group(char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2470 prs_struct *ps, int depth)
2472 if (q_u == NULL)
2473 return False;
2475 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2476 depth++;
2478 if(!prs_align(ps))
2479 return False;
2481 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2482 return False;
2484 return True;
2487 /*******************************************************************
2488 reads or writes a structure.
2489 ********************************************************************/
2491 BOOL samr_io_r_delete_dom_group(char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2492 prs_struct *ps, int depth)
2494 if (r_u == NULL)
2495 return False;
2497 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2498 depth++;
2500 if(!prs_align(ps))
2501 return False;
2503 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2504 return False;
2506 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2507 return False;
2509 return True;
2512 /*******************************************************************
2513 inits a SAMR_Q_DEL_GROUPMEM structure.
2514 ********************************************************************/
2516 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2517 POLICY_HND *pol, uint32 rid)
2519 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2521 q_e->pol = *pol;
2522 q_e->rid = rid;
2525 /*******************************************************************
2526 reads or writes a structure.
2527 ********************************************************************/
2529 BOOL samr_io_q_del_groupmem(char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2530 prs_struct *ps, int depth)
2532 if (q_e == NULL)
2533 return False;
2535 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2536 depth++;
2538 if(!prs_align(ps))
2539 return False;
2541 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2542 return False;
2544 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2545 return False;
2547 return True;
2550 /*******************************************************************
2551 inits a SAMR_R_DEL_GROUPMEM structure.
2552 ********************************************************************/
2554 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2555 NTSTATUS status)
2557 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2559 r_u->status = status;
2562 /*******************************************************************
2563 reads or writes a structure.
2564 ********************************************************************/
2566 BOOL samr_io_r_del_groupmem(char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2567 prs_struct *ps, int depth)
2569 if (r_u == NULL)
2570 return False;
2572 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2573 depth++;
2575 if(!prs_align(ps))
2576 return False;
2578 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2579 return False;
2581 return True;
2584 /*******************************************************************
2585 inits a SAMR_Q_ADD_GROUPMEM structure.
2586 ********************************************************************/
2588 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2589 POLICY_HND *pol, uint32 rid)
2591 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2593 q_e->pol = *pol;
2594 q_e->rid = rid;
2595 q_e->unknown = 0x0005;
2598 /*******************************************************************
2599 reads or writes a structure.
2600 ********************************************************************/
2602 BOOL samr_io_q_add_groupmem(char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2603 prs_struct *ps, int depth)
2605 if (q_e == NULL)
2606 return False;
2608 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2609 depth++;
2611 if(!prs_align(ps))
2612 return False;
2614 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2615 return False;
2617 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2618 return False;
2619 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2620 return False;
2622 return True;
2625 /*******************************************************************
2626 inits a SAMR_R_ADD_GROUPMEM structure.
2627 ********************************************************************/
2629 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2630 NTSTATUS status)
2632 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2634 r_u->status = status;
2637 /*******************************************************************
2638 reads or writes a structure.
2639 ********************************************************************/
2641 BOOL samr_io_r_add_groupmem(char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2642 prs_struct *ps, int depth)
2644 if (r_u == NULL)
2645 return False;
2647 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2648 depth++;
2650 if(!prs_align(ps))
2651 return False;
2653 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2654 return False;
2656 return True;
2659 /*******************************************************************
2660 inits a SAMR_Q_SET_GROUPINFO structure.
2661 ********************************************************************/
2663 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2664 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2666 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2668 q_e->pol = *pol;
2669 q_e->ctr = ctr;
2672 /*******************************************************************
2673 reads or writes a structure.
2674 ********************************************************************/
2676 BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2677 prs_struct *ps, int depth)
2679 if (q_e == NULL)
2680 return False;
2682 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2683 depth++;
2685 if(!prs_align(ps))
2686 return False;
2688 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2689 return False;
2691 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2692 return False;
2694 return True;
2697 /*******************************************************************
2698 inits a SAMR_R_SET_GROUPINFO structure.
2699 ********************************************************************/
2701 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2703 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2705 r_u->status = status;
2708 /*******************************************************************
2709 reads or writes a structure.
2710 ********************************************************************/
2712 BOOL samr_io_r_set_groupinfo(char *desc, SAMR_R_SET_GROUPINFO * r_u,
2713 prs_struct *ps, int depth)
2715 if (r_u == NULL)
2716 return False;
2718 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2719 depth++;
2721 if(!prs_align(ps))
2722 return False;
2724 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2725 return False;
2727 return True;
2730 /*******************************************************************
2731 inits a SAMR_Q_QUERY_GROUPINFO structure.
2732 ********************************************************************/
2734 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2735 POLICY_HND *pol, uint16 switch_level)
2737 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2739 q_e->pol = *pol;
2741 q_e->switch_level = switch_level;
2744 /*******************************************************************
2745 reads or writes a structure.
2746 ********************************************************************/
2748 BOOL samr_io_q_query_groupinfo(char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2749 prs_struct *ps, int depth)
2751 if (q_e == NULL)
2752 return False;
2754 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2755 depth++;
2757 if(!prs_align(ps))
2758 return False;
2760 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2761 return False;
2763 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2764 return False;
2766 return True;
2769 /*******************************************************************
2770 inits a SAMR_R_QUERY_GROUPINFO structure.
2771 ********************************************************************/
2773 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2774 GROUP_INFO_CTR * ctr, NTSTATUS status)
2776 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2778 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2779 r_u->ctr = ctr;
2780 r_u->status = status;
2783 /*******************************************************************
2784 reads or writes a structure.
2785 ********************************************************************/
2787 BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2788 prs_struct *ps, int depth)
2790 if (r_u == NULL)
2791 return False;
2793 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2794 depth++;
2796 if(!prs_align(ps))
2797 return False;
2799 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2800 return False;
2802 if (r_u->ptr != 0) {
2803 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2804 return False;
2807 if(!prs_align(ps))
2808 return False;
2809 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2810 return False;
2812 return True;
2815 /*******************************************************************
2816 inits a SAMR_Q_QUERY_GROUPMEM structure.
2817 ********************************************************************/
2819 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2821 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2823 q_c->group_pol = *hnd;
2826 /*******************************************************************
2827 reads or writes a structure.
2828 ********************************************************************/
2830 BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2831 prs_struct *ps, int depth)
2833 if (q_u == NULL)
2834 return False;
2836 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2837 depth++;
2839 if(!prs_align(ps))
2840 return False;
2842 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2843 return False;
2845 return True;
2848 /*******************************************************************
2849 inits a SAMR_R_QUERY_GROUPMEM structure.
2850 ********************************************************************/
2852 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2853 uint32 num_entries, uint32 *rid,
2854 uint32 *attr, NTSTATUS status)
2856 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2858 if (NT_STATUS_IS_OK(status)) {
2859 r_u->ptr = 1;
2860 r_u->num_entries = num_entries;
2862 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2863 r_u->ptr_rids = rid != NULL ? 1 : 0;
2865 r_u->num_rids = num_entries;
2866 r_u->rid = rid;
2868 r_u->num_attrs = num_entries;
2869 r_u->attr = attr;
2870 } else {
2871 r_u->ptr = 0;
2872 r_u->num_entries = 0;
2875 r_u->status = status;
2878 /*******************************************************************
2879 reads or writes a structure.
2880 ********************************************************************/
2882 BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2883 prs_struct *ps, int depth)
2885 uint32 i;
2887 if (r_u == NULL)
2888 return False;
2890 if (UNMARSHALLING(ps))
2891 ZERO_STRUCTP(r_u);
2893 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2894 depth++;
2896 if(!prs_align(ps))
2897 return False;
2899 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2900 return False;
2901 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2902 return False;
2904 if (r_u->ptr != 0) {
2905 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2906 return False;
2907 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2908 return False;
2910 if (r_u->ptr_rids != 0) {
2911 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2912 return False;
2913 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2914 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2915 if (r_u->rid == NULL)
2916 return False;
2919 for (i = 0; i < r_u->num_rids; i++) {
2920 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2921 return False;
2925 if (r_u->ptr_attrs != 0) {
2926 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2927 return False;
2929 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2930 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2931 if (r_u->attr == NULL)
2932 return False;
2935 for (i = 0; i < r_u->num_attrs; i++) {
2936 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2937 return False;
2942 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2943 return False;
2945 return True;
2948 /*******************************************************************
2949 inits a SAMR_Q_QUERY_USERGROUPS structure.
2950 ********************************************************************/
2952 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2953 POLICY_HND *hnd)
2955 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2957 q_u->pol = *hnd;
2960 /*******************************************************************
2961 reads or writes a structure.
2962 ********************************************************************/
2964 BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2965 prs_struct *ps, int depth)
2967 if (q_u == NULL)
2968 return False;
2970 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2971 depth++;
2973 if(!prs_align(ps))
2974 return False;
2976 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2977 return False;
2979 return True;
2982 /*******************************************************************
2983 inits a SAMR_R_QUERY_USERGROUPS structure.
2984 ********************************************************************/
2986 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2987 uint32 num_gids, DOM_GID * gid,
2988 NTSTATUS status)
2990 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2992 if (NT_STATUS_IS_OK(status)) {
2993 r_u->ptr_0 = 1;
2994 r_u->num_entries = num_gids;
2995 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
2996 r_u->num_entries2 = num_gids;
2998 r_u->gid = gid;
2999 } else {
3000 r_u->ptr_0 = 0;
3001 r_u->num_entries = 0;
3002 r_u->ptr_1 = 0;
3003 r_u->gid = NULL;
3006 r_u->status = status;
3009 /*******************************************************************
3010 reads or writes a structure.
3011 ********************************************************************/
3013 BOOL samr_io_gids(char *desc, uint32 *num_gids, DOM_GID ** gid,
3014 prs_struct *ps, int depth)
3016 uint32 i;
3017 if (gid == NULL)
3018 return False;
3020 prs_debug(ps, depth, desc, "samr_io_gids");
3021 depth++;
3023 if(!prs_align(ps))
3024 return False;
3026 if(!prs_uint32("num_gids", ps, depth, num_gids))
3027 return False;
3029 if ((*num_gids) != 0) {
3030 if (UNMARSHALLING(ps)) {
3031 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3034 if ((*gid) == NULL) {
3035 return False;
3038 for (i = 0; i < (*num_gids); i++) {
3039 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3040 return False;
3044 return True;
3047 /*******************************************************************
3048 reads or writes a structure.
3049 ********************************************************************/
3051 BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3052 prs_struct *ps, int depth)
3054 if (r_u == NULL)
3055 return False;
3057 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3058 depth++;
3060 if(!prs_align(ps))
3061 return False;
3063 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3064 return False;
3066 if (r_u->ptr_0 != 0) {
3067 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3068 return False;
3069 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3070 return False;
3072 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3073 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3074 return False;
3078 if(!prs_align(ps))
3079 return False;
3080 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3081 return False;
3083 return True;
3086 /*******************************************************************
3087 inits a SAMR_Q_ENUM_DOMAINS structure.
3088 ********************************************************************/
3090 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3091 POLICY_HND *pol,
3092 uint32 start_idx, uint32 size)
3094 DEBUG(5, ("init_samr_q_enum_domains\n"));
3096 q_e->pol = *pol;
3098 q_e->start_idx = start_idx;
3099 q_e->max_size = size;
3102 /*******************************************************************
3103 reads or writes a structure.
3104 ********************************************************************/
3106 BOOL samr_io_q_enum_domains(char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3107 prs_struct *ps, int depth)
3109 if (q_e == NULL)
3110 return False;
3112 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3113 depth++;
3115 if(!prs_align(ps))
3116 return False;
3118 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3119 return False;
3121 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3122 return False;
3123 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3124 return False;
3126 return True;
3129 /*******************************************************************
3130 inits a SAMR_R_ENUM_DOMAINS structure.
3131 ********************************************************************/
3133 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3134 uint32 next_idx, uint32 num_sam_entries)
3136 DEBUG(5, ("init_samr_r_enum_domains\n"));
3138 r_u->next_idx = next_idx;
3140 if (num_sam_entries != 0) {
3141 r_u->ptr_entries1 = 1;
3142 r_u->ptr_entries2 = 1;
3143 r_u->num_entries2 = num_sam_entries;
3144 r_u->num_entries3 = num_sam_entries;
3146 r_u->num_entries4 = num_sam_entries;
3147 } else {
3148 r_u->ptr_entries1 = 0;
3149 r_u->num_entries2 = num_sam_entries;
3150 r_u->ptr_entries2 = 1;
3154 /*******************************************************************
3155 reads or writes a structure.
3156 ********************************************************************/
3158 BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3159 prs_struct *ps, int depth)
3161 uint32 i;
3163 if (r_u == NULL)
3164 return False;
3166 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3167 depth++;
3169 if(!prs_align(ps))
3170 return False;
3172 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3173 return False;
3174 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3175 return False;
3177 if (r_u->ptr_entries1 != 0) {
3178 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3179 return False;
3180 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3181 return False;
3182 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3183 return False;
3185 if (UNMARSHALLING(ps)) {
3186 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3187 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3190 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3191 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3192 r_u->num_entries4 = 0;
3193 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3194 return False;
3197 for (i = 0; i < r_u->num_entries2; i++) {
3198 fstring tmp;
3199 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3200 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3201 return False;
3204 for (i = 0; i < r_u->num_entries2; i++) {
3205 fstring tmp;
3206 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3207 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3208 r_u->sam[i].hdr_name.buffer, ps,
3209 depth))
3210 return False;
3215 if(!prs_align(ps))
3216 return False;
3217 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3218 return False;
3219 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3220 return False;
3222 return True;
3225 /*******************************************************************
3226 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3227 ********************************************************************/
3229 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3230 POLICY_HND *pol,
3231 uint32 start_idx, uint32 size)
3233 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3235 q_e->pol = *pol;
3237 q_e->start_idx = start_idx;
3238 q_e->max_size = size;
3241 /*******************************************************************
3242 reads or writes a structure.
3243 ********************************************************************/
3245 BOOL samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3246 prs_struct *ps, int depth)
3248 if (q_e == NULL)
3249 return False;
3251 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3252 depth++;
3254 if(!prs_align(ps))
3255 return False;
3257 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3258 return False;
3260 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3261 return False;
3262 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3263 return False;
3265 return True;
3268 /*******************************************************************
3269 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3270 ********************************************************************/
3272 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3273 uint32 next_idx, uint32 num_sam_entries)
3275 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3277 r_u->next_idx = next_idx;
3279 if (num_sam_entries != 0) {
3280 r_u->ptr_entries1 = 1;
3281 r_u->ptr_entries2 = 1;
3282 r_u->num_entries2 = num_sam_entries;
3283 r_u->num_entries3 = num_sam_entries;
3285 r_u->num_entries4 = num_sam_entries;
3286 } else {
3287 r_u->ptr_entries1 = 0;
3288 r_u->num_entries2 = num_sam_entries;
3289 r_u->ptr_entries2 = 1;
3293 /*******************************************************************
3294 reads or writes a structure.
3295 ********************************************************************/
3297 BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3298 prs_struct *ps, int depth)
3300 uint32 i;
3302 if (r_u == NULL)
3303 return False;
3305 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3306 depth++;
3308 if(!prs_align(ps))
3309 return False;
3311 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3312 return False;
3313 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3314 return False;
3316 if (r_u->ptr_entries1 != 0) {
3317 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3318 return False;
3319 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3320 return False;
3321 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3322 return False;
3324 if (UNMARSHALLING(ps)) {
3325 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3326 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3329 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3330 DEBUG(0,
3331 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3332 r_u->num_entries4 = 0;
3333 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3334 return False;
3337 for (i = 0; i < r_u->num_entries2; i++) {
3338 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3339 return False;
3342 for (i = 0; i < r_u->num_entries2; i++) {
3343 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3344 r_u->sam[i].hdr_name.buffer, ps, depth))
3345 return False;
3349 if(!prs_align(ps))
3350 return False;
3351 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3352 return False;
3353 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3354 return False;
3356 return True;
3359 /*******************************************************************
3360 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3361 ********************************************************************/
3363 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3364 POLICY_HND *pol, uint32 start_idx,
3365 uint32 size)
3367 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3369 q_e->pol = *pol;
3371 q_e->start_idx = start_idx;
3372 q_e->max_size = size;
3376 /*******************************************************************
3377 reads or writes a structure.
3378 ********************************************************************/
3380 BOOL samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3381 prs_struct *ps, int depth)
3383 if (q_e == NULL)
3384 return False;
3386 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3387 depth++;
3389 if(!prs_align(ps))
3390 return False;
3392 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3393 return False;
3395 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3396 return False;
3397 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3398 return False;
3400 return True;
3403 /*******************************************************************
3404 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3405 ********************************************************************/
3407 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3409 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3411 r_u->next_idx = next_idx;
3413 if (num_sam_entries != 0) {
3414 r_u->ptr_entries1 = 1;
3415 r_u->ptr_entries2 = 1;
3416 r_u->num_entries2 = num_sam_entries;
3417 r_u->num_entries3 = num_sam_entries;
3419 r_u->num_entries4 = num_sam_entries;
3420 } else {
3421 r_u->ptr_entries1 = 0;
3422 r_u->num_entries2 = num_sam_entries;
3423 r_u->ptr_entries2 = 1;
3427 /*******************************************************************
3428 reads or writes a structure.
3429 ********************************************************************/
3431 BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3432 prs_struct *ps, int depth)
3434 uint32 i;
3436 if (r_u == NULL)
3437 return False;
3439 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3440 depth++;
3442 if(!prs_align(ps))
3443 return False;
3445 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3446 return False;
3447 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3448 return False;
3450 if (r_u->ptr_entries1 != 0) {
3451 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3452 return False;
3453 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3454 return False;
3455 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3456 return False;
3458 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3459 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3460 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3463 if (r_u->num_entries2 != 0 &&
3464 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3465 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3466 r_u->num_entries4 = 0;
3467 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3468 return False;
3471 for (i = 0; i < r_u->num_entries2; i++) {
3472 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3473 return False;
3476 for (i = 0; i < r_u->num_entries2; i++) {
3477 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3478 r_u->sam[i].hdr_name.buffer, ps,
3479 depth))
3480 return False;
3484 if(!prs_align(ps))
3485 return False;
3486 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3487 return False;
3488 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3489 return False;
3491 return True;
3494 /*******************************************************************
3495 inits a ALIAS_INFO1 structure.
3496 ********************************************************************/
3498 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3500 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3501 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3503 DEBUG(5, ("init_samr_alias_info1\n"));
3505 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3506 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3508 al1->num_member=num_member;
3510 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3511 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3514 /*******************************************************************
3515 reads or writes a structure.
3516 ********************************************************************/
3518 BOOL samr_io_alias_info1(char *desc, ALIAS_INFO1 * al1,
3519 prs_struct *ps, int depth)
3521 if (al1 == NULL)
3522 return False;
3524 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3525 depth++;
3527 if(!prs_align(ps))
3528 return False;
3530 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3531 return False;
3532 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3533 return False;
3534 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3535 return False;
3537 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3538 al1->hdr_acct_name.buffer, ps, depth))
3539 return False;
3541 if(!prs_align(ps))
3542 return False;
3544 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3545 al1->hdr_acct_desc.buffer, ps, depth))
3546 return False;
3548 return True;
3551 /*******************************************************************
3552 inits a ALIAS_INFO3 structure.
3553 ********************************************************************/
3555 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3557 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3559 DEBUG(5, ("init_samr_alias_info3\n"));
3561 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3562 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3565 /*******************************************************************
3566 reads or writes a structure.
3567 ********************************************************************/
3569 BOOL samr_io_alias_info3(char *desc, ALIAS_INFO3 * al3,
3570 prs_struct *ps, int depth)
3572 if (al3 == NULL)
3573 return False;
3575 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3576 depth++;
3578 if(!prs_align(ps))
3579 return False;
3581 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3582 return False;
3583 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3584 al3->hdr_acct_desc.buffer, ps, depth))
3585 return False;
3587 return True;
3590 /*******************************************************************
3591 reads or writes a structure.
3592 ********************************************************************/
3594 BOOL samr_alias_info_ctr(char *desc, ALIAS_INFO_CTR * ctr,
3595 prs_struct *ps, int depth)
3597 if (ctr == NULL)
3598 return False;
3600 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3601 depth++;
3603 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3604 return False;
3605 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3606 return False;
3608 switch (ctr->switch_value1) {
3609 case 1:
3610 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3611 return False;
3612 break;
3613 case 3:
3614 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3615 return False;
3616 break;
3617 default:
3618 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3619 break;
3622 return True;
3625 /*******************************************************************
3626 inits a SAMR_Q_QUERY_ALIASINFO structure.
3627 ********************************************************************/
3629 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3630 POLICY_HND *pol, uint16 switch_level)
3632 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3634 q_e->pol = *pol;
3635 q_e->switch_level = switch_level;
3638 /*******************************************************************
3639 reads or writes a structure.
3640 ********************************************************************/
3642 BOOL samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3643 prs_struct *ps, int depth)
3645 if (q_e == NULL)
3646 return False;
3648 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3649 depth++;
3651 if(!prs_align(ps))
3652 return False;
3654 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3655 return False;
3657 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3658 return False;
3660 return True;
3663 /*******************************************************************
3664 inits a SAMR_R_QUERY_ALIASINFO structure.
3665 ********************************************************************/
3667 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3668 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3670 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3672 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3673 r_u->ctr = *ctr;
3674 r_u->status = status;
3677 /*******************************************************************
3678 reads or writes a structure.
3679 ********************************************************************/
3681 BOOL samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3682 prs_struct *ps, int depth)
3684 if (r_u == NULL)
3685 return False;
3687 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3688 depth++;
3690 if(!prs_align(ps))
3691 return False;
3693 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3694 return False;
3696 if (r_u->ptr != 0) {
3697 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3698 return False;
3701 if(!prs_align(ps))
3702 return False;
3703 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3704 return False;
3706 return True;
3709 /*******************************************************************
3710 inits a SAMR_Q_SET_ALIASINFO structure.
3711 ********************************************************************/
3713 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3714 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3716 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3718 q_u->alias_pol = *hnd;
3719 q_u->ctr = *ctr;
3722 /*******************************************************************
3723 reads or writes a structure.
3724 ********************************************************************/
3726 BOOL samr_io_q_set_aliasinfo(char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3727 prs_struct *ps, int depth)
3729 if (q_u == NULL)
3730 return False;
3732 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3733 depth++;
3735 if(!prs_align(ps))
3736 return False;
3738 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3739 return False;
3740 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3741 return False;
3743 return True;
3746 /*******************************************************************
3747 reads or writes a structure.
3748 ********************************************************************/
3750 BOOL samr_io_r_set_aliasinfo(char *desc, SAMR_R_SET_ALIASINFO * r_u,
3751 prs_struct *ps, int depth)
3753 if (r_u == NULL)
3754 return False;
3756 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3757 depth++;
3759 if(!prs_align(ps))
3760 return False;
3761 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3762 return False;
3764 return True;
3767 /*******************************************************************
3768 inits a SAMR_Q_QUERY_USERALIASES structure.
3769 ********************************************************************/
3771 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3772 POLICY_HND *hnd,
3773 uint32 num_sids,
3774 uint32 *ptr_sid, DOM_SID2 * sid)
3776 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3778 q_u->pol = *hnd;
3780 q_u->num_sids1 = num_sids;
3781 q_u->ptr = 1;
3782 q_u->num_sids2 = num_sids;
3784 q_u->ptr_sid = ptr_sid;
3785 q_u->sid = sid;
3788 /*******************************************************************
3789 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3790 ********************************************************************/
3792 BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3793 prs_struct *ps, int depth)
3795 fstring tmp;
3796 uint32 i;
3798 if (q_u == NULL)
3799 return False;
3801 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3802 depth++;
3804 if(!prs_align(ps))
3805 return False;
3807 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3808 return False;
3810 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3811 return False;
3812 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3813 return False;
3815 if (q_u->ptr==0)
3816 return True;
3818 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3819 return False;
3821 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3822 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3823 if (q_u->ptr_sid == NULL)
3824 return False;
3826 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3827 if (q_u->sid == NULL)
3828 return False;
3831 for (i = 0; i < q_u->num_sids2; i++) {
3832 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3833 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3834 return False;
3837 for (i = 0; i < q_u->num_sids2; i++) {
3838 if (q_u->ptr_sid[i] != 0) {
3839 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3840 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3841 return False;
3845 return True;
3848 /*******************************************************************
3849 inits a SAMR_R_QUERY_USERALIASES structure.
3850 ********************************************************************/
3852 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3853 uint32 num_rids, uint32 *rid,
3854 NTSTATUS status)
3856 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3858 if (NT_STATUS_IS_OK(status)) {
3859 r_u->num_entries = num_rids;
3860 r_u->ptr = 1;
3861 r_u->num_entries2 = num_rids;
3863 r_u->rid = rid;
3864 } else {
3865 r_u->num_entries = 0;
3866 r_u->ptr = 0;
3867 r_u->num_entries2 = 0;
3870 r_u->status = status;
3873 /*******************************************************************
3874 reads or writes a structure.
3875 ********************************************************************/
3877 BOOL samr_io_rids(char *desc, uint32 *num_rids, uint32 **rid,
3878 prs_struct *ps, int depth)
3880 fstring tmp;
3881 uint32 i;
3882 if (rid == NULL)
3883 return False;
3885 prs_debug(ps, depth, desc, "samr_io_rids");
3886 depth++;
3888 if(!prs_align(ps))
3889 return False;
3891 if(!prs_uint32("num_rids", ps, depth, num_rids))
3892 return False;
3894 if ((*num_rids) != 0) {
3895 if (UNMARSHALLING(ps)) {
3896 /* reading */
3897 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3899 if ((*rid) == NULL)
3900 return False;
3902 for (i = 0; i < (*num_rids); i++) {
3903 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3904 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3905 return False;
3909 return True;
3912 /*******************************************************************
3913 reads or writes a structure.
3914 ********************************************************************/
3916 BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3917 prs_struct *ps, int depth)
3919 if (r_u == NULL)
3920 return False;
3922 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3923 depth++;
3925 if(!prs_align(ps))
3926 return False;
3928 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3929 return False;
3930 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3931 return False;
3933 if (r_u->ptr != 0) {
3934 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3935 return False;
3938 if(!prs_align(ps))
3939 return False;
3940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3941 return False;
3943 return True;
3946 /*******************************************************************
3947 inits a SAMR_Q_OPEN_ALIAS structure.
3948 ********************************************************************/
3950 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3951 uint32 access_mask, uint32 rid)
3953 DEBUG(5, ("init_samr_q_open_alias\n"));
3955 q_u->dom_pol = *pol;
3956 q_u->access_mask = access_mask;
3957 q_u->rid_alias = rid;
3960 /*******************************************************************
3961 reads or writes a structure.
3962 ********************************************************************/
3964 BOOL samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3965 prs_struct *ps, int depth)
3967 if (q_u == NULL)
3968 return False;
3970 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3971 depth++;
3973 if(!prs_align(ps))
3974 return False;
3976 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3977 return False;
3979 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3980 return False;
3981 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3982 return False;
3984 return True;
3987 /*******************************************************************
3988 reads or writes a structure.
3989 ********************************************************************/
3991 BOOL samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS * r_u,
3992 prs_struct *ps, int depth)
3994 if (r_u == NULL)
3995 return False;
3997 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
3998 depth++;
4000 if(!prs_align(ps))
4001 return False;
4003 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4004 return False;
4006 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4007 return False;
4009 return True;
4012 /*******************************************************************
4013 inits a SAMR_Q_LOOKUP_RIDS structure.
4014 ********************************************************************/
4016 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4017 POLICY_HND *pol, uint32 flags,
4018 uint32 num_rids, uint32 *rid)
4020 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4022 q_u->pol = *pol;
4024 q_u->num_rids1 = num_rids;
4025 q_u->flags = flags;
4026 q_u->ptr = 0;
4027 q_u->num_rids2 = num_rids;
4028 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4029 if (q_u->rid == NULL) {
4030 q_u->num_rids1 = 0;
4031 q_u->num_rids2 = 0;
4032 } else {
4033 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4037 /*******************************************************************
4038 reads or writes a structure.
4039 ********************************************************************/
4041 BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4042 prs_struct *ps, int depth)
4044 uint32 i;
4045 fstring tmp;
4047 if (q_u == NULL)
4048 return False;
4050 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4051 depth++;
4053 if (UNMARSHALLING(ps))
4054 ZERO_STRUCTP(q_u);
4056 if(!prs_align(ps))
4057 return False;
4059 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4060 return False;
4062 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4063 return False;
4064 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4065 return False;
4066 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4067 return False;
4068 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4069 return False;
4071 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4072 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4073 if (q_u->rid == NULL)
4074 return False;
4077 for (i = 0; i < q_u->num_rids2; i++) {
4078 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4079 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4080 return False;
4083 return True;
4086 /*******************************************************************
4087 inits a SAMR_R_LOOKUP_RIDS structure.
4088 ********************************************************************/
4090 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4091 uint32 num_names, UNIHDR * hdr_name,
4092 UNISTR2 *uni_name, uint32 *type)
4094 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4096 r_u->hdr_name = NULL;
4097 r_u->uni_name = NULL;
4098 r_u->type = NULL;
4100 if (num_names != 0) {
4101 r_u->num_names1 = num_names;
4102 r_u->ptr_names = 1;
4103 r_u->num_names2 = num_names;
4105 r_u->num_types1 = num_names;
4106 r_u->ptr_types = 1;
4107 r_u->num_types2 = num_names;
4109 r_u->hdr_name = hdr_name;
4110 r_u->uni_name = uni_name;
4111 r_u->type = type;
4112 } else {
4113 r_u->num_names1 = num_names;
4114 r_u->ptr_names = 0;
4115 r_u->num_names2 = num_names;
4117 r_u->num_types1 = num_names;
4118 r_u->ptr_types = 0;
4119 r_u->num_types2 = num_names;
4123 /*******************************************************************
4124 reads or writes a structure.
4125 ********************************************************************/
4127 BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4128 prs_struct *ps, int depth)
4130 uint32 i;
4131 fstring tmp;
4132 if (r_u == NULL)
4133 return False;
4135 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4136 depth++;
4138 if(!prs_align(ps))
4139 return False;
4141 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4142 return False;
4143 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4144 return False;
4146 if (r_u->ptr_names != 0) {
4148 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4149 return False;
4152 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4153 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4154 if (r_u->hdr_name == NULL)
4155 return False;
4157 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4158 if (r_u->uni_name == NULL)
4159 return False;
4162 for (i = 0; i < r_u->num_names2; i++) {
4163 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4164 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4165 return False;
4167 for (i = 0; i < r_u->num_names2; i++) {
4168 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4169 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4170 return False;
4175 if(!prs_align(ps))
4176 return False;
4177 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4178 return False;
4179 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4180 return False;
4182 if (r_u->ptr_types != 0) {
4184 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4185 return False;
4187 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4188 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4189 if (r_u->type == NULL)
4190 return False;
4193 for (i = 0; i < r_u->num_types2; i++) {
4194 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4195 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4196 return False;
4200 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4201 return False;
4203 return True;
4206 /*******************************************************************
4207 inits a SAMR_Q_OPEN_ALIAS structure.
4208 ********************************************************************/
4210 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4212 DEBUG(5, ("init_samr_q_delete_alias\n"));
4214 q_u->alias_pol = *hnd;
4217 /*******************************************************************
4218 reads or writes a structure.
4219 ********************************************************************/
4221 BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4222 prs_struct *ps, int depth)
4224 if (q_u == NULL)
4225 return False;
4227 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4228 depth++;
4230 if(!prs_align(ps))
4231 return False;
4233 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4234 return False;
4236 return True;
4239 /*******************************************************************
4240 reads or writes a structure.
4241 ********************************************************************/
4243 BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4244 prs_struct *ps, int depth)
4246 if (r_u == NULL)
4247 return False;
4249 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4250 depth++;
4252 if(!prs_align(ps))
4253 return False;
4255 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4256 return False;
4257 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4258 return False;
4260 return True;
4263 /*******************************************************************
4264 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4265 ********************************************************************/
4267 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4268 POLICY_HND *hnd, char *acct_desc)
4270 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4272 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4274 q_u->dom_pol = *hnd;
4276 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4277 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4279 q_u->access_mask = 0x001f000f;
4282 /*******************************************************************
4283 reads or writes a structure.
4284 ********************************************************************/
4286 BOOL samr_io_q_create_dom_alias(char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4287 prs_struct *ps, int depth)
4289 if (q_u == NULL)
4290 return False;
4292 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4293 depth++;
4295 if(!prs_align(ps))
4296 return False;
4298 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4299 return False;
4301 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4302 return False;
4303 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4304 q_u->hdr_acct_desc.buffer, ps, depth))
4305 return False;
4307 if(!prs_align(ps))
4308 return False;
4309 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4310 return False;
4312 return True;
4315 /*******************************************************************
4316 reads or writes a structure.
4317 ********************************************************************/
4319 BOOL samr_io_r_create_dom_alias(char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4320 prs_struct *ps, int depth)
4322 if (r_u == NULL)
4323 return False;
4325 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4326 depth++;
4328 if(!prs_align(ps))
4329 return False;
4331 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4332 return False;
4334 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4335 return False;
4337 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4338 return False;
4340 return True;
4343 /*******************************************************************
4344 inits a SAMR_Q_ADD_ALIASMEM structure.
4345 ********************************************************************/
4347 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4348 DOM_SID *sid)
4350 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4352 q_u->alias_pol = *hnd;
4353 init_dom_sid2(&q_u->sid, sid);
4356 /*******************************************************************
4357 reads or writes a structure.
4358 ********************************************************************/
4360 BOOL samr_io_q_add_aliasmem(char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4361 prs_struct *ps, int depth)
4363 if (q_u == NULL)
4364 return False;
4366 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4367 depth++;
4369 if(!prs_align(ps))
4370 return False;
4372 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4373 return False;
4374 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4375 return False;
4377 return True;
4380 /*******************************************************************
4381 reads or writes a structure.
4382 ********************************************************************/
4384 BOOL samr_io_r_add_aliasmem(char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4385 prs_struct *ps, int depth)
4387 if (r_u == NULL)
4388 return False;
4390 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4391 depth++;
4393 if(!prs_align(ps))
4394 return False;
4396 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4397 return False;
4399 return True;
4402 /*******************************************************************
4403 inits a SAMR_Q_DEL_ALIASMEM structure.
4404 ********************************************************************/
4406 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4407 DOM_SID *sid)
4409 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4411 q_u->alias_pol = *hnd;
4412 init_dom_sid2(&q_u->sid, sid);
4415 /*******************************************************************
4416 reads or writes a structure.
4417 ********************************************************************/
4419 BOOL samr_io_q_del_aliasmem(char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4420 prs_struct *ps, int depth)
4422 if (q_u == NULL)
4423 return False;
4425 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4426 depth++;
4428 if(!prs_align(ps))
4429 return False;
4431 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4432 return False;
4433 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4434 return False;
4436 return True;
4439 /*******************************************************************
4440 reads or writes a structure.
4441 ********************************************************************/
4443 BOOL samr_io_r_del_aliasmem(char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4444 prs_struct *ps, int depth)
4446 if (r_u == NULL)
4447 return False;
4449 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4450 depth++;
4452 if(!prs_align(ps))
4453 return False;
4455 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4456 return False;
4458 return True;
4461 /*******************************************************************
4462 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4463 ********************************************************************/
4465 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4466 POLICY_HND *hnd)
4468 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4470 q_c->alias_pol = *hnd;
4473 /*******************************************************************
4474 reads or writes a structure.
4475 ********************************************************************/
4477 BOOL samr_io_q_delete_dom_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4478 prs_struct *ps, int depth)
4480 if (q_u == NULL)
4481 return False;
4483 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4484 depth++;
4486 if(!prs_align(ps))
4487 return False;
4489 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4490 return False;
4492 return True;
4495 /*******************************************************************
4496 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4497 ********************************************************************/
4499 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4500 NTSTATUS status)
4502 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4504 r_u->status = status;
4507 /*******************************************************************
4508 reads or writes a structure.
4509 ********************************************************************/
4511 BOOL samr_io_r_delete_dom_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4512 prs_struct *ps, int depth)
4514 if (r_u == NULL)
4515 return False;
4517 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4518 depth++;
4520 if(!prs_align(ps))
4521 return False;
4523 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4524 return False;
4526 return True;
4529 /*******************************************************************
4530 inits a SAMR_Q_QUERY_ALIASMEM structure.
4531 ********************************************************************/
4533 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4534 POLICY_HND *hnd)
4536 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4538 q_c->alias_pol = *hnd;
4541 /*******************************************************************
4542 reads or writes a structure.
4543 ********************************************************************/
4545 BOOL samr_io_q_query_aliasmem(char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4546 prs_struct *ps, int depth)
4548 if (q_u == NULL)
4549 return False;
4551 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4552 depth++;
4554 if(!prs_align(ps))
4555 return False;
4557 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4558 return False;
4560 return True;
4563 /*******************************************************************
4564 inits a SAMR_R_QUERY_ALIASMEM structure.
4565 ********************************************************************/
4567 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4568 uint32 num_sids, DOM_SID2 * sid,
4569 NTSTATUS status)
4571 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4573 if (NT_STATUS_IS_OK(status)) {
4574 r_u->num_sids = num_sids;
4575 r_u->ptr = (num_sids != 0) ? 1 : 0;
4576 r_u->num_sids1 = num_sids;
4578 r_u->sid = sid;
4579 } else {
4580 r_u->ptr = 0;
4581 r_u->num_sids = 0;
4584 r_u->status = status;
4587 /*******************************************************************
4588 reads or writes a structure.
4589 ********************************************************************/
4591 BOOL samr_io_r_query_aliasmem(char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4592 prs_struct *ps, int depth)
4594 uint32 i;
4595 uint32 ptr_sid[MAX_LOOKUP_SIDS];
4597 if (r_u == NULL)
4598 return False;
4600 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4601 depth++;
4603 if(!prs_align(ps))
4604 return False;
4606 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4607 return False;
4608 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4609 return False;
4611 if (r_u->ptr != 0) {
4612 SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids);
4614 if (r_u->num_sids != 0) {
4615 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4616 return False;
4618 for (i = 0; i < r_u->num_sids1; i++) {
4619 ptr_sid[i] = 1;
4620 if(!prs_uint32("", ps, depth, &ptr_sid[i]))
4621 return False;
4624 for (i = 0; i < r_u->num_sids1; i++) {
4625 if (ptr_sid[i] != 0) {
4626 if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth))
4627 return False;
4633 if(!prs_align(ps))
4634 return False;
4635 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4636 return False;
4638 return True;
4641 /*******************************************************************
4642 inits a SAMR_Q_LOOKUP_NAMES structure.
4643 ********************************************************************/
4645 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4646 POLICY_HND *pol, uint32 flags,
4647 uint32 num_names, const char **name)
4649 uint32 i;
4651 DEBUG(5, ("init_samr_q_lookup_names\n"));
4653 q_u->pol = *pol;
4655 q_u->num_names1 = num_names;
4656 q_u->flags = flags;
4657 q_u->ptr = 0;
4658 q_u->num_names2 = num_names;
4660 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4661 return NT_STATUS_NO_MEMORY;
4663 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4664 return NT_STATUS_NO_MEMORY;
4666 for (i = 0; i < num_names; i++) {
4667 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4668 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4669 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4672 return NT_STATUS_OK;
4675 /*******************************************************************
4676 reads or writes a structure.
4677 ********************************************************************/
4679 BOOL samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4680 prs_struct *ps, int depth)
4682 uint32 i;
4684 if (q_u == NULL)
4685 return False;
4687 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4688 depth++;
4690 if (UNMARSHALLING(ps))
4691 ZERO_STRUCTP(q_u);
4693 if(!prs_align(ps))
4694 return False;
4696 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4697 return False;
4699 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4700 return False;
4701 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4702 return False;
4703 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4704 return False;
4705 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4706 return False;
4708 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4709 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4710 q_u->num_names2);
4711 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4712 q_u->num_names2);
4713 if (!q_u->hdr_name || !q_u->uni_name)
4714 return False;
4717 for (i = 0; i < q_u->num_names2; i++) {
4718 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4719 return False;
4722 for (i = 0; i < q_u->num_names2; i++) {
4723 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4724 return False;
4727 return True;
4730 /*******************************************************************
4731 inits a SAMR_R_LOOKUP_NAMES structure.
4732 ********************************************************************/
4734 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4735 uint32 num_rids,
4736 uint32 *rid, uint32 *type,
4737 NTSTATUS status)
4739 DEBUG(5, ("init_samr_r_lookup_names\n"));
4741 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4742 uint32 i;
4744 r_u->num_types1 = num_rids;
4745 r_u->ptr_types = 1;
4746 r_u->num_types2 = num_rids;
4748 r_u->num_rids1 = num_rids;
4749 r_u->ptr_rids = 1;
4750 r_u->num_rids2 = num_rids;
4752 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4753 return NT_STATUS_NO_MEMORY;
4754 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4755 return NT_STATUS_NO_MEMORY;
4757 if (!r_u->rids || !r_u->types)
4758 goto empty;
4760 for (i = 0; i < num_rids; i++) {
4761 r_u->rids[i] = rid[i];
4762 r_u->types[i] = type[i];
4764 } else {
4766 empty:
4767 r_u->num_types1 = 0;
4768 r_u->ptr_types = 0;
4769 r_u->num_types2 = 0;
4771 r_u->num_rids1 = 0;
4772 r_u->ptr_rids = 0;
4773 r_u->num_rids2 = 0;
4775 r_u->rids = NULL;
4776 r_u->types = NULL;
4779 r_u->status = status;
4781 return NT_STATUS_OK;
4784 /*******************************************************************
4785 reads or writes a structure.
4786 ********************************************************************/
4788 BOOL samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4789 prs_struct *ps, int depth)
4791 uint32 i;
4792 fstring tmp;
4794 if (r_u == NULL)
4795 return False;
4797 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4798 depth++;
4800 if (UNMARSHALLING(ps))
4801 ZERO_STRUCTP(r_u);
4803 if(!prs_align(ps))
4804 return False;
4806 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4807 return False;
4808 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4809 return False;
4811 if (r_u->ptr_rids != 0) {
4812 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4813 return False;
4815 if (r_u->num_rids2 != r_u->num_rids1) {
4816 /* RPC fault */
4817 return False;
4820 if (UNMARSHALLING(ps))
4821 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4823 if (!r_u->rids) {
4824 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4825 return False;
4828 for (i = 0; i < r_u->num_rids2; i++) {
4829 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4830 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4831 return False;
4835 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4836 return False;
4837 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4838 return False;
4840 if (r_u->ptr_types != 0) {
4841 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4842 return False;
4844 if (r_u->num_types2 != r_u->num_types1) {
4845 /* RPC fault */
4846 return False;
4849 if (UNMARSHALLING(ps))
4850 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4852 if (!r_u->types) {
4853 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4854 return False;
4857 for (i = 0; i < r_u->num_types2; i++) {
4858 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4859 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4860 return False;
4864 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4865 return False;
4867 return True;
4870 /*******************************************************************
4871 inits a SAMR_Q_DELETE_DOM_USER structure.
4872 ********************************************************************/
4874 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4875 POLICY_HND *hnd)
4877 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4879 q_c->user_pol = *hnd;
4882 /*******************************************************************
4883 reads or writes a structure.
4884 ********************************************************************/
4886 BOOL samr_io_q_delete_dom_user(char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4887 prs_struct *ps, int depth)
4889 if (q_u == NULL)
4890 return False;
4892 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4893 depth++;
4895 if(!prs_align(ps))
4896 return False;
4898 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4899 return False;
4901 return True;
4904 /*******************************************************************
4905 reads or writes a structure.
4906 ********************************************************************/
4908 BOOL samr_io_r_delete_dom_user(char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4909 prs_struct *ps, int depth)
4911 if (r_u == NULL)
4912 return False;
4914 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4915 depth++;
4917 if(!prs_align(ps))
4918 return False;
4920 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4921 return False;
4922 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4923 return False;
4925 return True;
4928 /*******************************************************************
4929 reads or writes a structure.
4930 ********************************************************************/
4932 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4933 POLICY_HND *pol,
4934 uint32 access_mask, uint32 rid)
4936 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4938 q_u->domain_pol = *pol;
4939 q_u->access_mask = access_mask;
4940 q_u->user_rid = rid;
4943 /*******************************************************************
4944 reads or writes a structure.
4945 ********************************************************************/
4947 BOOL samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER * q_u,
4948 prs_struct *ps, int depth)
4950 if (q_u == NULL)
4951 return False;
4953 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4954 depth++;
4956 if(!prs_align(ps))
4957 return False;
4959 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4960 return False;
4962 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4963 return False;
4964 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4965 return False;
4967 return True;
4970 /*******************************************************************
4971 reads or writes a structure.
4972 ********************************************************************/
4974 BOOL samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER * r_u,
4975 prs_struct *ps, int depth)
4977 if (r_u == NULL)
4978 return False;
4980 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4981 depth++;
4983 if(!prs_align(ps))
4984 return False;
4986 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4987 return False;
4989 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4990 return False;
4992 return True;
4996 /*******************************************************************
4997 reads or writes a structure.
4998 ********************************************************************/
5000 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5001 POLICY_HND *pol,
5002 const char *name,
5003 uint32 acb_info, uint32 access_mask)
5005 int len_name;
5006 len_name = strlen(name);
5008 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5010 q_u->domain_pol = *pol;
5012 init_uni_hdr(&q_u->hdr_name, len_name);
5013 init_unistr2(&q_u->uni_name, name, len_name);
5015 q_u->acb_info = acb_info;
5016 q_u->access_mask = access_mask;
5019 /*******************************************************************
5020 reads or writes a structure.
5021 ********************************************************************/
5023 BOOL samr_io_q_create_user(char *desc, SAMR_Q_CREATE_USER * q_u,
5024 prs_struct *ps, int depth)
5026 if (q_u == NULL)
5027 return False;
5029 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5030 depth++;
5032 if(!prs_align(ps))
5033 return False;
5035 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5036 return False;
5038 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5039 return False;
5040 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5041 return False;
5043 if(!prs_align(ps))
5044 return False;
5045 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5046 return False;
5047 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5048 return False;
5050 return True;
5053 /*******************************************************************
5054 reads or writes a structure.
5055 ********************************************************************/
5057 BOOL samr_io_r_create_user(char *desc, SAMR_R_CREATE_USER * r_u,
5058 prs_struct *ps, int depth)
5060 if (r_u == NULL)
5061 return False;
5063 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5064 depth++;
5066 if(!prs_align(ps))
5067 return False;
5069 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5070 return False;
5072 if(!prs_uint32("unknown_0", ps, depth, &r_u->unknown_0))
5073 return False;
5074 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5075 return False;
5076 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5077 return False;
5079 return True;
5082 /*******************************************************************
5083 inits a SAMR_Q_QUERY_USERINFO structure.
5084 ********************************************************************/
5086 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5087 POLICY_HND *hnd, uint16 switch_value)
5089 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5091 q_u->pol = *hnd;
5092 q_u->switch_value = switch_value;
5095 /*******************************************************************
5096 reads or writes a structure.
5097 ********************************************************************/
5099 BOOL samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5100 prs_struct *ps, int depth)
5102 if (q_u == NULL)
5103 return False;
5105 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5106 depth++;
5108 if(!prs_align(ps))
5109 return False;
5111 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5112 return False;
5114 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5115 return False;
5117 return True;
5120 /*******************************************************************
5121 reads or writes a LOGON_HRS structure.
5122 ********************************************************************/
5124 static BOOL sam_io_logon_hrs(char *desc, LOGON_HRS * hrs,
5125 prs_struct *ps, int depth)
5127 if (hrs == NULL)
5128 return False;
5130 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5131 depth++;
5133 if(!prs_align(ps))
5134 return False;
5136 if(!prs_uint32("len ", ps, depth, &hrs->len))
5137 return False;
5139 if (hrs->len > sizeof(hrs->hours)) {
5140 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5141 hrs->len = sizeof(hrs->hours);
5144 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5145 return False;
5147 return True;
5150 /*******************************************************************
5151 inits a SAM_USER_INFO_12 structure.
5152 ********************************************************************/
5154 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5155 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5157 DEBUG(5, ("init_sam_user_info12\n"));
5159 usr->lm_pwd_active =
5160 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5161 usr->nt_pwd_active =
5162 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5165 /*******************************************************************
5166 reads or writes a structure.
5167 ********************************************************************/
5169 static BOOL sam_io_user_info12(char *desc, SAM_USER_INFO_12 * u,
5170 prs_struct *ps, int depth)
5172 if (u == NULL)
5173 return False;
5175 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5176 depth++;
5178 if(!prs_align(ps))
5179 return False;
5181 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5182 return False;
5183 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5184 return False;
5186 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5187 return False;
5188 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5189 return False;
5191 return True;
5194 /*******************************************************************
5195 inits a SAM_USER_INFO_10 structure.
5196 ********************************************************************/
5198 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5200 DEBUG(5, ("init_sam_user_info10\n"));
5202 usr->acb_info = acb_info;
5205 /*******************************************************************
5206 reads or writes a structure.
5207 ********************************************************************/
5209 static BOOL sam_io_user_info10(char *desc, SAM_USER_INFO_10 * usr,
5210 prs_struct *ps, int depth)
5212 if (usr == NULL)
5213 return False;
5215 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5216 depth++;
5218 if(!prs_align(ps))
5219 return False;
5221 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5222 return False;
5224 return True;
5227 /*******************************************************************
5228 inits a SAM_USER_INFO_11 structure.
5229 ********************************************************************/
5231 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5232 NTTIME * expiry,
5233 char *mach_acct,
5234 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5236 int len_mach_acct;
5238 DEBUG(5, ("init_sam_user_info11\n"));
5240 len_mach_acct = strlen(mach_acct);
5242 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5243 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5245 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5246 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5248 usr->ptr_1 = 1; /* pointer */
5249 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5250 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5252 usr->ptr_2 = 1; /* pointer */
5253 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5255 usr->ptr_3 = 1; /* pointer */
5256 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5258 usr->rid_user = rid_user;
5259 usr->rid_group = rid_group;
5261 usr->acct_ctrl = acct_ctrl;
5262 usr->unknown_3 = 0x0000;
5264 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5265 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5267 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5268 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5270 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5273 /*******************************************************************
5274 reads or writes a structure.
5275 ********************************************************************/
5277 static BOOL sam_io_user_info11(char *desc, SAM_USER_INFO_11 * usr,
5278 prs_struct *ps, int depth)
5280 if (usr == NULL)
5281 return False;
5283 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5284 depth++;
5286 if(!prs_align(ps))
5287 return False;
5289 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5290 return False;
5292 if(!smb_io_time("time", &usr->expiry, ps, depth))
5293 return False;
5295 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5296 return False;
5298 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5299 return False;
5301 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5302 return False;
5304 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5305 return False;
5306 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5307 return False;
5309 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5310 return False;
5312 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5313 return False;
5314 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5315 return False;
5317 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5318 return False;
5319 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5320 return False;
5322 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5323 return False;
5324 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5325 return False;
5326 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5327 return False;
5328 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5329 return False;
5330 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5331 return False;
5332 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5333 return False;
5335 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5336 return False;
5338 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5339 return False;
5341 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5342 return False;
5344 if(!prs_align(ps))
5345 return False;
5347 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5348 return False;
5350 return True;
5353 /*************************************************************************
5354 init_sam_user_infoa
5356 unknown_3 = 0x09f8 27fa
5357 unknown_5 = 0x0001 0000
5358 unknown_6 = 0x0000 04ec
5360 *************************************************************************/
5362 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5364 DEBUG(10, ("init_sam_user_info24:\n"));
5365 memcpy(usr->pass, newpass, sizeof(usr->pass));
5366 usr->pw_len = pw_len;
5369 /*******************************************************************
5370 reads or writes a structure.
5371 ********************************************************************/
5373 static BOOL sam_io_user_info24(char *desc, SAM_USER_INFO_24 * usr,
5374 prs_struct *ps, int depth)
5376 if (usr == NULL)
5377 return False;
5379 prs_debug(ps, depth, desc, "sam_io_user_info24");
5380 depth++;
5382 if(!prs_align(ps))
5383 return False;
5385 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5386 sizeof(usr->pass)))
5387 return False;
5389 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5390 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5391 return False;
5393 if(!prs_align(ps))
5394 return False;
5396 return True;
5399 /*************************************************************************
5400 init_sam_user_info23
5402 unknown_3 = 0x09f8 27fa
5403 unknown_5 = 0x0001 0000
5404 unknown_6 = 0x0000 04ec
5406 *************************************************************************/
5408 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5409 NTTIME * logoff_time, /* all zeros */
5410 NTTIME * kickoff_time, /* all zeros */
5411 NTTIME * pass_last_set_time, /* all zeros */
5412 NTTIME * pass_can_change_time, /* all zeros */
5413 NTTIME * pass_must_change_time, /* all zeros */
5414 UNISTR2 *user_name,
5415 UNISTR2 *full_name,
5416 UNISTR2 *home_dir,
5417 UNISTR2 *dir_drive,
5418 UNISTR2 *log_scr,
5419 UNISTR2 *prof_path,
5420 UNISTR2 *desc,
5421 UNISTR2 *wkstas,
5422 UNISTR2 *unk_str,
5423 UNISTR2 *mung_dial,
5424 uint32 user_rid, /* 0x0000 0000 */
5425 uint32 group_rid,
5426 uint32 acb_info,
5427 uint32 unknown_3,
5428 uint16 logon_divs,
5429 LOGON_HRS * hrs,
5430 uint32 unknown_5,
5431 char newpass[516], uint32 unknown_6)
5433 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5434 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5435 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5436 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5437 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5438 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5439 int len_description = desc != NULL ? desc->uni_str_len : 0;
5440 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5441 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5442 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5444 usr->logon_time = *logon_time; /* all zeros */
5445 usr->logoff_time = *logoff_time; /* all zeros */
5446 usr->kickoff_time = *kickoff_time; /* all zeros */
5447 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5448 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5449 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5451 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5452 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5453 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5454 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5455 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5456 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5457 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5458 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5459 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5460 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5462 ZERO_STRUCT(usr->nt_pwd);
5463 ZERO_STRUCT(usr->lm_pwd);
5465 usr->user_rid = user_rid; /* 0x0000 0000 */
5466 usr->group_rid = group_rid;
5467 usr->acb_info = acb_info;
5468 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5470 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5471 usr->ptr_logon_hrs = hrs ? 1 : 0;
5473 ZERO_STRUCT(usr->padding1);
5475 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5477 memcpy(usr->pass, newpass, sizeof(usr->pass));
5479 copy_unistr2(&usr->uni_user_name, user_name);
5480 copy_unistr2(&usr->uni_full_name, full_name);
5481 copy_unistr2(&usr->uni_home_dir, home_dir);
5482 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5483 copy_unistr2(&usr->uni_logon_script, log_scr);
5484 copy_unistr2(&usr->uni_profile_path, prof_path);
5485 copy_unistr2(&usr->uni_acct_desc, desc);
5486 copy_unistr2(&usr->uni_workstations, wkstas);
5487 copy_unistr2(&usr->uni_unknown_str, unk_str);
5488 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5490 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5491 usr->padding4 = 0;
5493 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5496 /*************************************************************************
5497 init_sam_user_info23
5499 unknown_3 = 0x09f8 27fa
5500 unknown_5 = 0x0001 0000
5501 unknown_6 = 0x0000 04ec
5503 *************************************************************************/
5505 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5506 NTTIME * logoff_time, /* all zeros */
5507 NTTIME * kickoff_time, /* all zeros */
5508 NTTIME * pass_last_set_time, /* all zeros */
5509 NTTIME * pass_can_change_time, /* all zeros */
5510 NTTIME * pass_must_change_time, /* all zeros */
5511 char *user_name, /* NULL */
5512 char *full_name,
5513 char *home_dir, char *dir_drive, char *log_scr,
5514 char *prof_path, char *desc, char *wkstas,
5515 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5516 uint32 group_rid, uint32 acb_info,
5517 uint32 unknown_3, uint16 logon_divs,
5518 LOGON_HRS * hrs, uint32 unknown_5,
5519 char newpass[516], uint32 unknown_6)
5521 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5522 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5523 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5524 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5525 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5526 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5527 int len_description = desc != NULL ? strlen(desc) : 0;
5528 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5529 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5530 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5532 usr->logon_time = *logon_time; /* all zeros */
5533 usr->logoff_time = *logoff_time; /* all zeros */
5534 usr->kickoff_time = *kickoff_time; /* all zeros */
5535 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5536 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5537 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5539 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5540 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5541 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5542 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5543 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5544 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5545 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5546 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5547 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5548 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5550 ZERO_STRUCT(usr->nt_pwd);
5551 ZERO_STRUCT(usr->lm_pwd);
5553 usr->user_rid = user_rid; /* 0x0000 0000 */
5554 usr->group_rid = group_rid;
5555 usr->acb_info = acb_info;
5556 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5558 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5559 usr->ptr_logon_hrs = hrs ? 1 : 0;
5561 ZERO_STRUCT(usr->padding1);
5563 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5565 memcpy(usr->pass, newpass, sizeof(usr->pass));
5567 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5568 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5569 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5570 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5571 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5572 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5573 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5574 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5575 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5576 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5578 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5579 usr->padding4 = 0;
5581 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5584 /*******************************************************************
5585 reads or writes a structure.
5586 ********************************************************************/
5588 static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
5589 prs_struct *ps, int depth)
5591 if (usr == NULL)
5592 return False;
5594 prs_debug(ps, depth, desc, "sam_io_user_info23");
5595 depth++;
5597 if(!prs_align(ps))
5598 return False;
5600 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5601 return False;
5602 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5603 return False;
5604 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5605 return False;
5606 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5607 return False;
5608 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5609 return False;
5610 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5611 return False;
5613 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5614 return False;
5615 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5616 return False;
5617 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5618 return False;
5619 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5620 return False;
5621 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5622 return False;
5623 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5624 return False;
5625 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5626 return False;
5627 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5628 return False;
5629 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5630 return False;
5631 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5632 return False;
5634 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5635 return False;
5636 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5637 return False;
5639 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5640 return False;
5641 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5642 return False;
5643 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5644 return False;
5646 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5647 return False;
5648 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5649 return False;
5650 if(!prs_align(ps))
5651 return False;
5652 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5653 return False;
5654 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5655 return False;
5656 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5657 return False;
5659 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5660 return False;
5662 /* here begins pointed-to data */
5664 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5665 return False;
5667 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5668 return False;
5670 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5671 return False;
5673 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5674 return False;
5676 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5677 return False;
5679 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5680 return False;
5682 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5683 return False;
5685 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5686 return False;
5688 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5689 return False;
5691 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5692 return False;
5694 /* ok, this is only guess-work (as usual) */
5695 if (usr->ptr_logon_hrs) {
5696 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5697 return False;
5698 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5699 return False;
5700 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5701 return False;
5702 } else if (UNMARSHALLING(ps)) {
5703 usr->unknown_6 = 0;
5704 usr->padding4 = 0;
5707 return True;
5710 /*******************************************************************
5711 reads or writes a structure.
5712 NB. This structure is *definately* incorrect. It's my best guess
5713 currently for W2K SP2. The password field is encrypted in a different
5714 way than normal... And there are definately other problems. JRA.
5715 ********************************************************************/
5717 static BOOL sam_io_user_info25(char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5719 if (usr == NULL)
5720 return False;
5722 prs_debug(ps, depth, desc, "sam_io_user_info25");
5723 depth++;
5725 if(!prs_align(ps))
5726 return False;
5728 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5729 return False;
5730 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5731 return False;
5732 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5733 return False;
5734 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5735 return False;
5736 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5737 return False;
5738 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5739 return False;
5741 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5742 return False;
5743 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5744 return False;
5745 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5746 return False;
5747 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5748 return False;
5749 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5750 return False;
5751 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5752 return False;
5753 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5754 return False;
5755 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5756 return False;
5757 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5758 return False;
5759 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5760 return False;
5762 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5763 return False;
5764 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5765 return False;
5767 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5768 return False;
5769 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5770 return False;
5771 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5772 return False;
5774 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5775 return False;
5777 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5778 return False;
5780 /* here begins pointed-to data */
5782 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5783 return False;
5785 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5786 return False;
5788 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5789 return False;
5791 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5792 return False;
5794 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5795 return False;
5797 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5798 return False;
5800 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5801 return False;
5803 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5804 return False;
5806 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5807 return False;
5809 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5810 return False;
5812 #if 0 /* JRA - unknown... */
5813 /* ok, this is only guess-work (as usual) */
5814 if (usr->ptr_logon_hrs) {
5815 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5816 return False;
5817 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5818 return False;
5819 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5820 return False;
5821 } else if (UNMARSHALLING(ps)) {
5822 usr->unknown_6 = 0;
5823 usr->padding4 = 0;
5825 #endif
5827 return True;
5831 /*************************************************************************
5832 init_sam_user_info21W
5834 unknown_3 = 0x00ff ffff
5835 unknown_5 = 0x0002 0000
5836 unknown_6 = 0x0000 04ec
5838 *************************************************************************/
5840 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5841 NTTIME * logon_time,
5842 NTTIME * logoff_time,
5843 NTTIME * kickoff_time,
5844 NTTIME * pass_last_set_time,
5845 NTTIME * pass_can_change_time,
5846 NTTIME * pass_must_change_time,
5847 UNISTR2 *user_name,
5848 UNISTR2 *full_name,
5849 UNISTR2 *home_dir,
5850 UNISTR2 *dir_drive,
5851 UNISTR2 *log_scr,
5852 UNISTR2 *prof_path,
5853 UNISTR2 *desc,
5854 UNISTR2 *wkstas,
5855 UNISTR2 *unk_str,
5856 UNISTR2 *mung_dial,
5857 uchar lm_pwd[16],
5858 uchar nt_pwd[16],
5859 uint32 user_rid,
5860 uint32 group_rid,
5861 uint32 acb_info,
5862 uint32 unknown_3,
5863 uint16 logon_divs,
5864 LOGON_HRS * hrs,
5865 uint32 unknown_5, uint32 unknown_6)
5867 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5868 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5869 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5870 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5871 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5872 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5873 int len_description = desc != NULL ? desc->uni_str_len : 0;
5874 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5875 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5876 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5878 usr->logon_time = *logon_time;
5879 usr->logoff_time = *logoff_time;
5880 usr->kickoff_time = *kickoff_time;
5881 usr->pass_last_set_time = *pass_last_set_time;
5882 usr->pass_can_change_time = *pass_can_change_time;
5883 usr->pass_must_change_time = *pass_must_change_time;
5885 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5886 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5887 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5888 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5889 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5890 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5891 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5892 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5893 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5894 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5896 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5897 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5899 usr->user_rid = user_rid;
5900 usr->group_rid = group_rid;
5901 usr->acb_info = acb_info;
5902 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5904 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5905 usr->ptr_logon_hrs = hrs ? 1 : 0;
5906 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5908 ZERO_STRUCT(usr->padding1);
5910 copy_unistr2(&usr->uni_user_name, user_name);
5911 copy_unistr2(&usr->uni_full_name, full_name);
5912 copy_unistr2(&usr->uni_home_dir, home_dir);
5913 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5914 copy_unistr2(&usr->uni_logon_script, log_scr);
5915 copy_unistr2(&usr->uni_profile_path, prof_path);
5916 copy_unistr2(&usr->uni_acct_desc, desc);
5917 copy_unistr2(&usr->uni_workstations, wkstas);
5918 copy_unistr2(&usr->uni_unknown_str, unk_str);
5919 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5921 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5922 usr->padding4 = 0;
5924 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5927 /*************************************************************************
5928 init_sam_user_info21
5930 unknown_3 = 0x00ff ffff
5931 unknown_5 = 0x0002 0000
5932 unknown_6 = 0x0000 04ec
5934 *************************************************************************/
5936 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5938 NTTIME logon_time, logoff_time, kickoff_time,
5939 pass_last_set_time, pass_can_change_time,
5940 pass_must_change_time;
5942 int len_user_name, len_full_name, len_home_dir,
5943 len_dir_drive, len_logon_script, len_profile_path,
5944 len_description, len_workstations, len_unknown_str,
5945 len_munged_dial;
5947 const char* user_name = pdb_get_username(pw);
5948 const char* full_name = pdb_get_fullname(pw);
5949 const char* home_dir = pdb_get_homedir(pw);
5950 const char* dir_drive = pdb_get_dir_drive(pw);
5951 const char* logon_script = pdb_get_logon_script(pw);
5952 const char* profile_path = pdb_get_profile_path(pw);
5953 const char* description = pdb_get_acct_desc(pw);
5954 const char* workstations = pdb_get_workstations(pw);
5955 const char* munged_dial = pdb_get_munged_dial(pw);
5957 uint32 user_rid;
5958 const DOM_SID *user_sid;
5960 uint32 group_rid;
5961 const DOM_SID *group_sid;
5963 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
5964 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
5965 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
5966 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
5967 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
5968 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
5969 len_description = description != NULL ? strlen(description )+1 : 0;
5970 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
5971 len_unknown_str = 0;
5972 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
5975 /* Create NTTIME structs */
5976 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
5977 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
5978 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
5979 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
5980 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
5981 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
5983 /* structure assignment */
5984 usr->logon_time = logon_time;
5985 usr->logoff_time = logoff_time;
5986 usr->kickoff_time = kickoff_time;
5987 usr->pass_last_set_time = pass_last_set_time;
5988 usr->pass_can_change_time = pass_can_change_time;
5989 usr->pass_must_change_time = pass_must_change_time;
5991 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5992 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5993 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5994 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5995 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5996 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5997 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5998 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5999 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6000 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6002 ZERO_STRUCT(usr->nt_pwd);
6003 ZERO_STRUCT(usr->lm_pwd);
6005 user_sid = pdb_get_user_sid(pw);
6007 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6008 fstring user_sid_string;
6009 fstring domain_sid_string;
6010 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6011 "the domain sid %s. Failing operation.\n",
6012 user_name,
6013 sid_to_string(user_sid_string, user_sid),
6014 sid_to_string(domain_sid_string, domain_sid)));
6015 return NT_STATUS_UNSUCCESSFUL;
6018 group_sid = pdb_get_group_sid(pw);
6020 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6021 fstring group_sid_string;
6022 fstring domain_sid_string;
6023 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6024 "which conflicts with the domain sid %s. Failing operation.\n",
6025 user_name,
6026 sid_to_string(group_sid_string, group_sid),
6027 sid_to_string(domain_sid_string, domain_sid)));
6028 return NT_STATUS_UNSUCCESSFUL;
6031 usr->user_rid = user_rid;
6032 usr->group_rid = group_rid;
6033 usr->acb_info = pdb_get_acct_ctrl(pw);
6034 usr->unknown_3 = pdb_get_unknown3(pw);
6036 usr->logon_divs = pdb_get_logon_divs(pw);
6037 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6038 usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
6040 ZERO_STRUCT(usr->padding1);
6042 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6043 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6044 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6045 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6046 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6047 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6048 init_unistr2(&usr->uni_acct_desc, description, len_description);
6049 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6050 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6051 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6053 usr->unknown_6 = pdb_get_unknown6(pw);
6054 usr->padding4 = 0;
6056 if (pdb_get_hours(pw)) {
6057 usr->logon_hrs.len = pdb_get_hours_len(pw);
6058 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6059 } else
6060 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6062 return NT_STATUS_OK;
6065 /*******************************************************************
6066 reads or writes a structure.
6067 ********************************************************************/
6069 static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
6070 prs_struct *ps, int depth)
6072 if (usr == NULL)
6073 return False;
6075 prs_debug(ps, depth, desc, "sam_io_user_info21");
6076 depth++;
6078 if(!prs_align(ps))
6079 return False;
6081 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6082 return False;
6083 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6084 return False;
6085 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6086 return False;
6087 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6088 return False;
6089 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6090 return False;
6091 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6092 return False;
6094 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6095 return False;
6096 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6097 return False;
6098 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6099 return False;
6100 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6101 return False;
6102 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6103 return False;
6104 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6105 return False;
6106 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6107 return False;
6108 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6109 return False;
6110 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6111 return False;
6112 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6113 return False;
6115 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6116 return False;
6117 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6118 return False;
6120 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6121 return False;
6122 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6123 return False;
6124 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6125 return False;
6127 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6128 return False;
6129 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6130 return False;
6131 if(!prs_align(ps))
6132 return False;
6133 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6134 return False;
6135 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6136 return False;
6138 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6139 return False;
6141 /* here begins pointed-to data */
6143 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6144 return False;
6145 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6146 return False;
6147 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6148 return False;
6149 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6150 return False;
6151 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6152 return False;
6153 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6154 return False;
6155 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6156 return False;
6157 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6158 return False;
6159 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6160 return False;
6161 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6162 return False;
6164 /* ok, this is only guess-work (as usual) */
6165 if (usr->ptr_logon_hrs) {
6166 if(!prs_align(ps))
6167 return False;
6168 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6169 return False;
6170 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6171 return False;
6172 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6173 return False;
6174 } else if (UNMARSHALLING(ps)) {
6175 usr->unknown_6 = 0;
6176 usr->padding4 = 0;
6179 return True;
6182 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6184 int len_munged_dial;
6185 const char* munged_dial = pdb_get_munged_dial(pw);
6187 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6188 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6189 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6193 /*******************************************************************
6194 reads or writes a structure.
6195 ********************************************************************/
6197 static BOOL sam_io_user_info20(char *desc, SAM_USER_INFO_20 *usr,
6198 prs_struct *ps, int depth)
6200 if (usr == NULL)
6201 return False;
6203 prs_debug(ps, depth, desc, "sam_io_user_info20");
6204 depth++;
6206 if(!prs_align(ps))
6207 return False;
6209 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6210 return False;
6212 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6213 return False;
6215 return True;
6218 /*******************************************************************
6219 inits a SAM_USERINFO_CTR structure.
6220 ********************************************************************/
6222 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6223 uint16 switch_value,
6224 SAM_USER_INFO_21 * usr)
6226 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6228 ctr->switch_value = switch_value;
6229 ctr->info.id = NULL;
6231 switch (switch_value) {
6232 case 0x10:
6233 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6234 if (ctr->info.id10 == NULL)
6235 return NT_STATUS_NO_MEMORY;
6237 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6238 break;
6239 #if 0
6240 /* whoops - got this wrong. i think. or don't understand what's happening. */
6241 case 0x11:
6243 NTTIME expire;
6244 info = (void *)&id11;
6246 expire.low = 0xffffffff;
6247 expire.high = 0x7fffffff;
6249 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6250 init_sam_user_info11(ctr->info.id11, &expire,
6251 "BROOKFIELDS$", /* name */
6252 0x03ef, /* user rid */
6253 0x201, /* group rid */
6254 0x0080); /* acb info */
6256 break;
6258 #endif
6259 case 0x12:
6260 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6261 if (ctr->info.id12 == NULL)
6262 return NT_STATUS_NO_MEMORY;
6264 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6265 break;
6266 case 21:
6268 SAM_USER_INFO_21 *cusr;
6269 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6270 ctr->info.id21 = cusr;
6271 if (ctr->info.id21 == NULL)
6272 return NT_STATUS_NO_MEMORY;
6273 memcpy(cusr, usr, sizeof(*usr));
6274 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6275 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6276 break;
6278 default:
6279 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6280 return NT_STATUS_INVALID_INFO_CLASS;
6283 return NT_STATUS_OK;
6286 /*******************************************************************
6287 inits a SAM_USERINFO_CTR structure.
6288 ********************************************************************/
6290 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6291 uint16 switch_value, void *info)
6293 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6295 ctr->switch_value = switch_value;
6296 ctr->info.id = info;
6298 switch (switch_value) {
6299 case 0x18:
6300 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6301 dump_data(100, (char *)sess_key, 16);
6302 dump_data(100, (char *)ctr->info.id24->pass, 516);
6303 break;
6304 case 0x17:
6305 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6306 dump_data(100, (char *)sess_key, 16);
6307 dump_data(100, (char *)ctr->info.id23->pass, 516);
6308 break;
6309 default:
6310 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6314 /*******************************************************************
6315 reads or writes a structure.
6316 ********************************************************************/
6318 static BOOL samr_io_userinfo_ctr(char *desc, SAM_USERINFO_CTR **ppctr,
6319 prs_struct *ps, int depth)
6321 BOOL ret;
6322 SAM_USERINFO_CTR *ctr;
6324 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6325 depth++;
6327 if (UNMARSHALLING(ps)) {
6328 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6329 if (ctr == NULL)
6330 return False;
6331 *ppctr = ctr;
6332 } else {
6333 ctr = *ppctr;
6336 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6338 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6339 return False;
6340 if(!prs_align(ps))
6341 return False;
6343 ret = False;
6345 switch (ctr->switch_value) {
6346 case 0x10:
6347 if (UNMARSHALLING(ps))
6348 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6349 if (ctr->info.id10 == NULL) {
6350 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6351 return False;
6353 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6354 break;
6355 case 0x11:
6356 if (UNMARSHALLING(ps))
6357 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6359 if (ctr->info.id11 == NULL) {
6360 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6361 return False;
6363 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6364 break;
6365 case 0x12:
6366 if (UNMARSHALLING(ps))
6367 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6369 if (ctr->info.id12 == NULL) {
6370 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6371 return False;
6373 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6374 break;
6375 case 20:
6376 if (UNMARSHALLING(ps))
6377 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6379 if (ctr->info.id20 == NULL) {
6380 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6381 return False;
6383 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6384 break;
6385 case 21:
6386 if (UNMARSHALLING(ps))
6387 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6389 if (ctr->info.id21 == NULL) {
6390 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6391 return False;
6393 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6394 break;
6395 case 23:
6396 if (UNMARSHALLING(ps))
6397 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6399 if (ctr->info.id23 == NULL) {
6400 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6401 return False;
6403 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6404 break;
6405 case 24:
6406 if (UNMARSHALLING(ps))
6407 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6409 if (ctr->info.id24 == NULL) {
6410 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6411 return False;
6413 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6414 break;
6415 case 25:
6416 if (UNMARSHALLING(ps))
6417 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6419 if (ctr->info.id25 == NULL) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6421 return False;
6423 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6424 break;
6425 default:
6426 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6427 ret = False;
6428 break;
6431 return ret;
6434 /*******************************************************************
6435 inits a SAMR_R_QUERY_USERINFO structure.
6436 ********************************************************************/
6438 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6439 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6441 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6443 r_u->ptr = 0;
6444 r_u->ctr = NULL;
6446 if (NT_STATUS_IS_OK(status)) {
6447 r_u->ptr = 1;
6448 r_u->ctr = ctr;
6451 r_u->status = status; /* return status */
6454 /*******************************************************************
6455 reads or writes a structure.
6456 ********************************************************************/
6458 BOOL samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO * r_u,
6459 prs_struct *ps, int depth)
6461 if (r_u == NULL)
6462 return False;
6464 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6465 depth++;
6467 if(!prs_align(ps))
6468 return False;
6470 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6471 return False;
6473 if (r_u->ptr != 0) {
6474 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6475 return False;
6478 if(!prs_align(ps))
6479 return False;
6480 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6481 return False;
6483 return True;
6486 /*******************************************************************
6487 inits a SAMR_Q_SET_USERINFO structure.
6488 ********************************************************************/
6490 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6491 POLICY_HND *hnd, unsigned char sess_key[16],
6492 uint16 switch_value, void *info)
6494 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6496 q_u->pol = *hnd;
6497 q_u->switch_value = switch_value;
6498 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6501 /*******************************************************************
6502 reads or writes a structure.
6503 ********************************************************************/
6505 BOOL samr_io_q_set_userinfo(char *desc, SAMR_Q_SET_USERINFO * q_u,
6506 prs_struct *ps, int depth)
6508 if (q_u == NULL)
6509 return False;
6511 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6512 depth++;
6514 if(!prs_align(ps))
6515 return False;
6517 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6519 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6520 return False;
6521 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6522 return False;
6524 return True;
6527 /*******************************************************************
6528 inits a SAMR_R_SET_USERINFO structure.
6529 ********************************************************************/
6531 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6533 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6535 r_u->status = status; /* return status */
6538 /*******************************************************************
6539 reads or writes a structure.
6540 ********************************************************************/
6542 BOOL samr_io_r_set_userinfo(char *desc, SAMR_R_SET_USERINFO * r_u,
6543 prs_struct *ps, int depth)
6545 if (r_u == NULL)
6546 return False;
6548 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6549 depth++;
6551 if(!prs_align(ps))
6552 return False;
6554 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6555 return False;
6557 return True;
6560 /*******************************************************************
6561 inits a SAMR_Q_SET_USERINFO2 structure.
6562 ********************************************************************/
6564 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6565 POLICY_HND *hnd, unsigned char sess_key[16],
6566 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6568 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6570 q_u->pol = *hnd;
6571 q_u->switch_value = switch_value;
6572 q_u->ctr = ctr;
6574 if (q_u->ctr != NULL)
6575 q_u->ctr->switch_value = switch_value;
6577 switch (switch_value) {
6578 case 0x12:
6579 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6580 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6581 dump_data(100, (char *)sess_key, 16);
6582 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6583 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6584 break;
6588 /*******************************************************************
6589 reads or writes a structure.
6590 ********************************************************************/
6592 BOOL samr_io_q_set_userinfo2(char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6593 prs_struct *ps, int depth)
6595 if (q_u == NULL)
6596 return False;
6598 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6599 depth++;
6601 if(!prs_align(ps))
6602 return False;
6604 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6605 return False;
6607 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6608 return False;
6609 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6610 return False;
6612 return True;
6615 /*******************************************************************
6616 inits a SAMR_R_SET_USERINFO2 structure.
6617 ********************************************************************/
6619 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6621 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6623 r_u->status = status; /* return status */
6626 /*******************************************************************
6627 reads or writes a structure.
6628 ********************************************************************/
6630 BOOL samr_io_r_set_userinfo2(char *desc, SAMR_R_SET_USERINFO2 * r_u,
6631 prs_struct *ps, int depth)
6633 if (r_u == NULL)
6634 return False;
6636 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6637 depth++;
6639 if(!prs_align(ps))
6640 return False;
6642 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6643 return False;
6645 return True;
6648 /*******************************************************************
6649 inits a SAMR_Q_CONNECT structure.
6650 ********************************************************************/
6652 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6653 char *srv_name, uint32 access_mask)
6655 int len_srv_name = strlen(srv_name);
6657 DEBUG(5, ("init_samr_q_connect\n"));
6659 /* make PDC server name \\server */
6660 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6661 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6663 /* example values: 0x0000 0002 */
6664 q_u->access_mask = access_mask;
6667 /*******************************************************************
6668 reads or writes a structure.
6669 ********************************************************************/
6671 BOOL samr_io_q_connect(char *desc, SAMR_Q_CONNECT * q_u,
6672 prs_struct *ps, int depth)
6674 if (q_u == NULL)
6675 return False;
6677 prs_debug(ps, depth, desc, "samr_io_q_connect");
6678 depth++;
6680 if(!prs_align(ps))
6681 return False;
6683 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6684 return False;
6685 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6686 return False;
6688 if(!prs_align(ps))
6689 return False;
6690 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6691 return False;
6693 return True;
6696 /*******************************************************************
6697 reads or writes a structure.
6698 ********************************************************************/
6700 BOOL samr_io_r_connect(char *desc, SAMR_R_CONNECT * r_u,
6701 prs_struct *ps, int depth)
6703 if (r_u == NULL)
6704 return False;
6706 prs_debug(ps, depth, desc, "samr_io_r_connect");
6707 depth++;
6709 if(!prs_align(ps))
6710 return False;
6712 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6713 return False;
6715 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6716 return False;
6718 return True;
6721 /*******************************************************************
6722 reads or writes a structure.
6723 ********************************************************************/
6725 BOOL samr_io_q_connect4(char *desc, SAMR_Q_CONNECT4 * q_u,
6726 prs_struct *ps, int depth)
6728 if (q_u == NULL)
6729 return False;
6731 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6732 depth++;
6734 if(!prs_align(ps))
6735 return False;
6737 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6738 return False;
6739 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6740 return False;
6742 if(!prs_align(ps))
6743 return False;
6744 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6745 return False;
6746 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6747 return False;
6749 return True;
6752 /*******************************************************************
6753 reads or writes a structure.
6754 ********************************************************************/
6756 BOOL samr_io_r_connect4(char *desc, SAMR_R_CONNECT4 * r_u,
6757 prs_struct *ps, int depth)
6759 if (r_u == NULL)
6760 return False;
6762 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6763 depth++;
6765 if(!prs_align(ps))
6766 return False;
6768 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6769 return False;
6771 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6772 return False;
6774 return True;
6777 /*******************************************************************
6778 inits a SAMR_Q_CONNECT_ANON structure.
6779 ********************************************************************/
6781 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6783 DEBUG(5, ("init_samr_q_connect_anon\n"));
6785 q_u->ptr = 1;
6786 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6787 q_u->unknown_1 = 0x01;
6788 q_u->access_mask = 0x20;
6791 /*******************************************************************
6792 reads or writes a structure.
6793 ********************************************************************/
6795 BOOL samr_io_q_connect_anon(char *desc, SAMR_Q_CONNECT_ANON * q_u,
6796 prs_struct *ps, int depth)
6798 if (q_u == NULL)
6799 return False;
6801 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6802 depth++;
6804 if(!prs_align(ps))
6805 return False;
6807 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6808 return False;
6809 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6810 return False;
6811 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6812 return False;
6813 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6814 return False;
6816 return True;
6819 /*******************************************************************
6820 reads or writes a structure.
6821 ********************************************************************/
6823 BOOL samr_io_r_connect_anon(char *desc, SAMR_R_CONNECT_ANON * r_u,
6824 prs_struct *ps, int depth)
6826 if (r_u == NULL)
6827 return False;
6829 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6830 depth++;
6832 if(!prs_align(ps))
6833 return False;
6835 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6836 return False;
6838 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6839 return False;
6841 return True;
6844 /*******************************************************************
6845 inits a SAMR_Q_GET_DOM_PWINFO structure.
6846 ********************************************************************/
6848 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6849 char *srv_name)
6851 int len_srv_name = strlen(srv_name);
6853 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6855 q_u->ptr = 1;
6856 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6857 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6860 /*******************************************************************
6861 reads or writes a structure.
6862 ********************************************************************/
6864 BOOL samr_io_q_get_dom_pwinfo(char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6865 prs_struct *ps, int depth)
6867 if (q_u == NULL)
6868 return False;
6870 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6871 depth++;
6873 if(!prs_align(ps))
6874 return False;
6876 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6877 return False;
6878 if (q_u->ptr != 0) {
6879 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6880 return False;
6881 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6882 return False;
6885 return True;
6888 /*******************************************************************
6889 reads or writes a structure.
6890 ********************************************************************/
6892 BOOL samr_io_r_get_dom_pwinfo(char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6893 prs_struct *ps, int depth)
6895 if (r_u == NULL)
6896 return False;
6898 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6899 depth++;
6901 if(!prs_align(ps))
6902 return False;
6905 * We need 16 bytes here according to tests. Don't know
6906 * what they are, but the length is important for the singing
6909 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6910 return False;
6911 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6912 return False;
6913 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
6914 return False;
6916 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6917 return False;
6919 return True;
6922 /*******************************************************************
6923 make a SAMR_ENC_PASSWD structure.
6924 ********************************************************************/
6926 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
6928 ZERO_STRUCTP(pwd);
6930 if (pass == NULL) {
6931 pwd->ptr = 0;
6932 } else {
6933 pwd->ptr = 1;
6934 memcpy(pwd->pass, pass, sizeof(pwd->pass));
6938 /*******************************************************************
6939 reads or writes a SAMR_ENC_PASSWD structure.
6940 ********************************************************************/
6942 BOOL samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD * pwd,
6943 prs_struct *ps, int depth)
6945 if (pwd == NULL)
6946 return False;
6948 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
6949 depth++;
6951 if(!prs_align(ps))
6952 return False;
6954 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
6955 return False;
6957 if (pwd->ptr != 0) {
6958 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
6959 return False;
6962 return True;
6965 /*******************************************************************
6966 inits a SAMR_ENC_HASH structure.
6967 ********************************************************************/
6969 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
6971 ZERO_STRUCTP(hsh);
6973 if (hash == NULL) {
6974 hsh->ptr = 0;
6975 } else {
6976 hsh->ptr = 1;
6977 memcpy(hsh->hash, hash, sizeof(hsh->hash));
6981 /*******************************************************************
6982 reads or writes a SAMR_ENC_HASH structure.
6983 ********************************************************************/
6985 BOOL samr_io_enc_hash(char *desc, SAMR_ENC_HASH * hsh,
6986 prs_struct *ps, int depth)
6988 if (hsh == NULL)
6989 return False;
6991 prs_debug(ps, depth, desc, "samr_io_enc_hash");
6992 depth++;
6994 if(!prs_align(ps))
6995 return False;
6997 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
6998 return False;
6999 if (hsh->ptr != 0) {
7000 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7001 return False;
7004 return True;
7007 /*******************************************************************
7008 inits a SAMR_R_GET_DOM_PWINFO structure.
7009 ********************************************************************/
7011 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7012 char *dest_host, char *user_name,
7013 char nt_newpass[516],
7014 uchar nt_oldhash[16],
7015 char lm_newpass[516],
7016 uchar lm_oldhash[16])
7018 int len_dest_host = strlen(dest_host);
7019 int len_user_name = strlen(user_name);
7021 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7023 q_u->ptr_0 = 1;
7024 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7025 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7026 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7027 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7029 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7030 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7032 q_u->unknown = 0x01;
7034 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7035 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7038 /*******************************************************************
7039 reads or writes a structure.
7040 ********************************************************************/
7042 BOOL samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7043 prs_struct *ps, int depth)
7045 if (q_u == NULL)
7046 return False;
7048 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7049 depth++;
7051 if(!prs_align(ps))
7052 return False;
7054 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7055 return False;
7057 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7058 return False;
7059 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7060 return False;
7062 if(!prs_align(ps))
7063 return False;
7064 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7065 return False;
7066 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7067 return False;
7069 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7070 return False;
7071 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7072 return False;
7074 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7075 return False;
7077 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7078 return False;
7079 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7080 return False;
7082 return True;
7085 /*******************************************************************
7086 inits a SAMR_R_CHGPASSWD_USER structure.
7087 ********************************************************************/
7089 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7091 DEBUG(5, ("init_r_chgpasswd_user\n"));
7093 r_u->status = status;
7096 /*******************************************************************
7097 reads or writes a structure.
7098 ********************************************************************/
7100 BOOL samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7101 prs_struct *ps, int depth)
7103 if (r_u == NULL)
7104 return False;
7106 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7107 depth++;
7109 if(!prs_align(ps))
7110 return False;
7112 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7113 return False;
7115 return True;
7118 /*******************************************************************
7119 reads or writes a structure.
7120 ********************************************************************/
7122 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7123 POLICY_HND *domain_pol, uint16 switch_value)
7125 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7127 q_u->domain_pol = *domain_pol;
7128 q_u->switch_value = switch_value;
7131 /*******************************************************************
7132 reads or writes a structure.
7133 ********************************************************************/
7135 BOOL samr_io_q_unknown_2e(char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7136 prs_struct *ps, int depth)
7138 if (q_u == NULL)
7139 return False;
7141 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7142 depth++;
7144 if(!prs_align(ps))
7145 return False;
7147 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7148 return False;
7150 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7151 return False;
7153 return True;
7156 /*******************************************************************
7157 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7158 ********************************************************************/
7160 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7161 uint16 switch_value, SAM_UNK_CTR * ctr,
7162 NTSTATUS status)
7164 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7166 r_u->ptr_0 = 0;
7167 r_u->switch_value = 0;
7168 r_u->status = status; /* return status */
7170 if (NT_STATUS_IS_OK(status)) {
7171 r_u->switch_value = switch_value;
7172 r_u->ptr_0 = 1;
7173 r_u->ctr = ctr;
7177 /*******************************************************************
7178 reads or writes a structure.
7179 ********************************************************************/
7181 BOOL samr_io_r_samr_unknown_2e(char *desc, SAMR_R_UNKNOWN_2E * r_u,
7182 prs_struct *ps, int depth)
7184 if (r_u == NULL)
7185 return False;
7187 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7188 depth++;
7190 if(!prs_align(ps))
7191 return False;
7193 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7194 return False;
7196 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7197 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7198 return False;
7199 if(!prs_align(ps))
7200 return False;
7202 switch (r_u->switch_value) {
7203 case 0x0c:
7204 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7205 return False;
7206 break;
7207 case 0x07:
7208 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7209 return False;
7210 break;
7211 case 0x06:
7212 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7213 return False;
7214 break;
7215 case 0x05:
7216 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7217 return False;
7218 break;
7219 case 0x03:
7220 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7221 return False;
7222 break;
7223 case 0x02:
7224 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7225 return False;
7226 break;
7227 case 0x01:
7228 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7229 return False;
7230 break;
7231 default:
7232 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7233 r_u->switch_value));
7234 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7235 return False;
7239 if(!prs_align(ps))
7240 return False;
7242 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7243 return False;
7245 return True;
7249 /*******************************************************************
7250 reads or writes a structure.
7251 ********************************************************************/
7253 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7254 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7256 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7258 q_u->domain_pol = *domain_pol;
7259 q_u->switch_value0 = switch_value;
7261 q_u->switch_value = switch_value;
7262 q_u->ctr = ctr;
7266 /*******************************************************************
7267 reads or writes a structure.
7268 ********************************************************************/
7270 BOOL samr_io_q_set_domain_info(char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7271 prs_struct *ps, int depth)
7273 if (q_u == NULL)
7274 return False;
7276 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7277 depth++;
7279 if(!prs_align(ps))
7280 return False;
7282 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7283 return False;
7285 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7286 return False;
7288 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7289 return False;
7291 if(!prs_align(ps))
7292 return False;
7294 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7295 return False;
7297 switch (q_u->switch_value) {
7299 case 0x0c:
7300 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7301 return False;
7302 break;
7303 case 0x07:
7304 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7305 return False;
7306 break;
7307 case 0x06:
7308 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7309 return False;
7310 break;
7311 case 0x05:
7312 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7313 return False;
7314 break;
7315 case 0x03:
7316 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7317 return False;
7318 break;
7319 case 0x02:
7320 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7321 return False;
7322 break;
7323 case 0x01:
7324 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7325 return False;
7326 break;
7327 default:
7328 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7329 q_u->switch_value));
7330 return False;
7333 return True;
7336 /*******************************************************************
7337 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7338 ********************************************************************/
7340 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7342 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7344 r_u->status = status; /* return status */
7347 /*******************************************************************
7348 reads or writes a structure.
7349 ********************************************************************/
7351 BOOL samr_io_r_set_domain_info(char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7352 prs_struct *ps, int depth)
7354 if (r_u == NULL)
7355 return False;
7357 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7358 depth++;
7360 if(!prs_align(ps))
7361 return False;
7363 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7364 return False;
7366 return True;