Back out --with-good-getgrouplist patch
[Samba/gebeck_regimport.git] / source3 / rpc_parse / parse_samr.c
blob1fe9b3231fcc656db8ee0aca2b7985cf872143b6
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "includes.h"
28 #include "rpc_parse.h"
29 #include "nterr.h"
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
42 q_c->pol = *hnd;
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
50 prs_struct *ps, int depth)
52 if (q_u == NULL)
53 return False;
55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
56 depth++;
58 if(!prs_align(ps))
59 return False;
61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
69 prs_struct *ps, int depth)
71 if (r_u == NULL)
72 return False;
74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
75 depth++;
77 if(!prs_align(ps))
78 return False;
80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
81 return False;
83 if(!prs_ntstatus("status", ps, depth, &r_u->status))
84 return False;
86 return True;
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
94 POLICY_HND *pol, char *dom_name)
96 int len_name = strlen(dom_name);
98 DEBUG(5, ("init_samr_q_lookup_domain\n"));
100 q_u->connect_pol = *pol;
102 init_uni_hdr(&q_u->hdr_domain, len_name);
103 init_unistr2(&q_u->uni_domain, dom_name, len_name);
106 /*******************************************************************
107 reads or writes a structure.
108 ********************************************************************/
109 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
110 prs_struct *ps, int depth)
112 if (q_u == NULL)
113 return False;
115 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
116 depth++;
118 if(!prs_align(ps))
119 return False;
121 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
122 return False;
124 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
125 return False;
127 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
128 return False;
130 return True;
133 /*******************************************************************
134 inits a SAMR_R_LOOKUP_DOMAIN structure.
135 ********************************************************************/
137 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
138 DOM_SID *dom_sid, NTSTATUS status)
140 DEBUG(5, ("init_samr_r_lookup_domain\n"));
142 r_u->status = status;
143 r_u->ptr_sid = 0;
144 if (NT_STATUS_IS_OK(status)) {
145 r_u->ptr_sid = 1;
146 init_dom_sid2(&r_u->dom_sid, dom_sid);
150 /*******************************************************************
151 reads or writes a structure.
152 ********************************************************************/
154 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
155 prs_struct *ps, int depth)
157 if (r_u == NULL)
158 return False;
160 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
161 depth++;
163 if(!prs_align(ps))
164 return False;
166 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
167 return False;
169 if (r_u->ptr_sid != 0) {
170 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
171 return False;
172 if(!prs_align(ps))
173 return False;
176 if(!prs_ntstatus("status", ps, depth, &r_u->status))
177 return False;
179 return True;
182 /*******************************************************************
183 reads or writes a structure.
184 ********************************************************************/
186 void init_samr_q_remove_user_foreign_domain(SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
188 DEBUG(5, ("samr_init_samr_q_remove_user_foreign_domain\n"));
190 q_u->dom_pol = *dom_pol;
191 init_dom_sid2(&q_u->sid, sid);
194 /*******************************************************************
195 reads or writes a structure.
196 ********************************************************************/
198 BOOL samr_io_q_remove_user_foreign_domain(const char *desc, SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN * q_u,
199 prs_struct *ps, int depth)
201 if (q_u == NULL)
202 return False;
204 prs_debug(ps, depth, desc, "samr_io_q_remove_user_foreign_domain");
205 depth++;
207 if(!prs_align(ps))
208 return False;
210 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
211 return False;
213 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
214 return False;
216 if(!prs_align(ps))
217 return False;
219 return True;
222 /*******************************************************************
223 reads or writes a structure.
224 ********************************************************************/
226 BOOL samr_io_r_remove_user_foreign_domain(const char *desc, SAMR_R_REMOVE_USER_FOREIGN_DOMAIN * r_u,
227 prs_struct *ps, int depth)
229 if (r_u == NULL)
230 return False;
232 prs_debug(ps, depth, desc, "samr_io_r_remove_user_foreign_domain");
233 depth++;
235 if(!prs_align(ps))
236 return False;
238 if(!prs_ntstatus("status", ps, depth, &r_u->status))
239 return False;
241 return True;
244 /*******************************************************************
245 reads or writes a structure.
246 ********************************************************************/
248 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
249 POLICY_HND *pol, uint32 flags,
250 const DOM_SID *sid)
252 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 q_u->pol = *pol;
255 q_u->flags = flags;
256 init_dom_sid2(&q_u->dom_sid, sid);
259 /*******************************************************************
260 reads or writes a structure.
261 ********************************************************************/
263 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
264 prs_struct *ps, int depth)
266 if (q_u == NULL)
267 return False;
269 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
270 depth++;
272 if(!prs_align(ps))
273 return False;
275 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
276 return False;
278 if(!prs_uint32("flags", ps, depth, &q_u->flags))
279 return False;
281 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
282 return False;
284 return True;
287 /*******************************************************************
288 reads or writes a structure.
289 ********************************************************************/
291 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
292 prs_struct *ps, int depth)
294 if (r_u == NULL)
295 return False;
297 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
298 depth++;
300 if(!prs_align(ps))
301 return False;
303 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
304 return False;
306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
307 return False;
309 return True;
312 /*******************************************************************
313 reads or writes a structure.
314 ********************************************************************/
316 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
317 POLICY_HND *user_pol)
319 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
321 q_u->user_pol = *user_pol;
324 /*******************************************************************
325 reads or writes a structure.
326 ********************************************************************/
328 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
329 prs_struct *ps, int depth)
331 if (q_u == NULL)
332 return False;
334 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
335 depth++;
337 if(!prs_align(ps))
338 return False;
340 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
343 /*******************************************************************
344 Init.
345 ********************************************************************/
347 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
349 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
351 r_u->unknown_0 = 0x0000;
354 * used to be
355 * r_u->unknown_1 = 0x0015;
356 * but for trusts.
358 r_u->unknown_1 = 0x01D1;
359 r_u->unknown_1 = 0x0015;
361 r_u->unknown_2 = 0x00000000;
363 r_u->status = status;
366 /*******************************************************************
367 reads or writes a structure.
368 ********************************************************************/
370 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
371 prs_struct *ps, int depth)
373 if (r_u == NULL)
374 return False;
376 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
377 depth++;
379 if(!prs_align(ps))
380 return False;
382 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0))
383 return False;
384 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
385 return False;
386 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2))
387 return False;
388 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
389 return False;
391 return True;
395 /*******************************************************************
396 reads or writes a structure.
397 ********************************************************************/
399 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
400 prs_struct *ps, int depth)
402 if (q_u == NULL)
403 return False;
405 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
406 depth++;
408 if(!prs_align(ps))
409 return False;
411 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
412 return False;
414 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
415 return False;
417 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
418 return False;
420 return True;
424 /*******************************************************************
425 reads or writes a structure.
426 ********************************************************************/
428 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
429 POLICY_HND *user_pol, uint32 sec_info)
431 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
433 q_u->user_pol = *user_pol;
434 q_u->sec_info = sec_info;
438 /*******************************************************************
439 reads or writes a structure.
440 ********************************************************************/
442 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
443 prs_struct *ps, int depth)
445 if (q_u == NULL)
446 return False;
448 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
449 depth++;
451 if(!prs_align(ps))
452 return False;
454 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
455 return False;
457 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
458 return False;
460 return True;
463 /*******************************************************************
464 reads or writes a structure.
465 ********************************************************************/
467 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
468 POLICY_HND *domain_pol, uint16 switch_value)
470 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
472 q_u->domain_pol = *domain_pol;
473 q_u->switch_value = switch_value;
476 /*******************************************************************
477 reads or writes a structure.
478 ********************************************************************/
480 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
481 prs_struct *ps, int depth)
483 if (q_u == NULL)
484 return False;
486 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
487 depth++;
489 if(!prs_align(ps))
490 return False;
492 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
493 return False;
495 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
496 return False;
498 return True;
502 /*******************************************************************
503 inits a structure.
504 ********************************************************************/
506 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
508 u_3->logout.low = nt_logout.low;
509 u_3->logout.high = nt_logout.high;
512 /*******************************************************************
513 reads or writes a structure.
514 ********************************************************************/
516 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
517 prs_struct *ps, int depth)
519 if (u_3 == NULL)
520 return False;
522 prs_debug(ps, depth, desc, "sam_io_unk_info3");
523 depth++;
525 if(!smb_io_time("logout", &u_3->logout, ps, depth))
526 return False;
528 return True;
531 /*******************************************************************
532 inits a structure.
533 ********************************************************************/
535 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
537 u_6->unknown_0 = 0x00000000;
538 u_6->ptr_0 = 1;
539 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
542 /*******************************************************************
543 reads or writes a structure.
544 ********************************************************************/
546 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
547 prs_struct *ps, int depth)
549 if (u_6 == NULL)
550 return False;
552 prs_debug(ps, depth, desc, "sam_io_unk_info6");
553 depth++;
555 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
556 return False;
557 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
558 return False;
559 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
560 return False;
562 return True;
565 /*******************************************************************
566 inits a structure.
567 ********************************************************************/
569 void init_unk_info7(SAM_UNK_INFO_7 * u_7)
571 u_7->unknown_0 = 0x0003;
574 /*******************************************************************
575 reads or writes a structure.
576 ********************************************************************/
578 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
579 prs_struct *ps, int depth)
581 if (u_7 == NULL)
582 return False;
584 prs_debug(ps, depth, desc, "sam_io_unk_info7");
585 depth++;
587 if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */
588 return False;
590 return True;
593 /*******************************************************************
594 inits a structure.
595 ********************************************************************/
597 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
599 u_12->duration.low = nt_lock_duration.low;
600 u_12->duration.high = nt_lock_duration.high;
601 u_12->reset_count.low = nt_reset_time.low;
602 u_12->reset_count.high = nt_reset_time.high;
604 u_12->bad_attempt_lockout = lockout;
607 /*******************************************************************
608 reads or writes a structure.
609 ********************************************************************/
611 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
612 prs_struct *ps, int depth)
614 if (u_12 == NULL)
615 return False;
617 prs_debug(ps, depth, desc, "sam_io_unk_info12");
618 depth++;
620 if(!smb_io_time("duration", &u_12->duration, ps, depth))
621 return False;
622 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
623 return False;
624 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
625 return False;
627 return True;
630 /*******************************************************************
631 inits a structure.
632 ********************************************************************/
633 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
635 int len_server = strlen(server);
637 init_uni_hdr(&u_5->hdr_server, len_server);
639 init_unistr2(&u_5->uni_server, server, len_server);
642 /*******************************************************************
643 reads or writes a structure.
644 ********************************************************************/
646 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
647 prs_struct *ps, int depth)
649 if (u_5 == NULL)
650 return False;
652 prs_debug(ps, depth, desc, "sam_io_unk_info5");
653 depth++;
655 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth))
656 return False;
658 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth))
659 return False;
661 return True;
664 /*******************************************************************
665 inits a structure.
666 ********************************************************************/
667 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
668 const char *domain, const char *server,
669 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
671 int len_domain = strlen(domain);
672 int len_server = strlen(server);
674 u_2->unknown_0 = 0x00000000;
675 u_2->unknown_1 = 0x80000000;
676 u_2->unknown_2 = 0x00000000;
678 u_2->ptr_0 = 1;
679 init_uni_hdr(&u_2->hdr_domain, len_domain);
680 init_uni_hdr(&u_2->hdr_server, len_server);
682 u_2->seq_num = seq_num;
683 u_2->unknown_3 = 0x00000000;
685 u_2->unknown_4 = 0x00000001;
686 u_2->unknown_5 = 0x00000003;
687 u_2->unknown_6 = 0x00000001;
688 u_2->num_domain_usrs = num_users;
689 u_2->num_domain_grps = num_groups;
690 u_2->num_local_grps = num_alias;
692 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
694 init_unistr2(&u_2->uni_domain, domain, len_domain);
695 init_unistr2(&u_2->uni_server, server, len_server);
698 /*******************************************************************
699 reads or writes a structure.
700 ********************************************************************/
702 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
703 prs_struct *ps, int depth)
705 if (u_2 == NULL)
706 return False;
708 prs_debug(ps, depth, desc, "sam_io_unk_info2");
709 depth++;
711 if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */
712 return False;
713 if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */
714 return False;
715 if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */
716 return False;
718 if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0))
719 return False;
720 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
721 return False;
722 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
723 return False;
725 /* put all the data in here, at the moment, including what the above
726 pointer is referring to
729 if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */
730 return False;
731 if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */
732 return False;
734 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
735 return False;
736 if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */
737 return False;
738 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
739 return False;
740 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
741 return False;
742 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
743 return False;
744 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
745 return False;
747 if (u_2->ptr_0) {
748 /* this was originally marked as 'padding'. It isn't
749 padding, it is some sort of optional 12 byte
750 structure. When it is present it contains zeros
751 !? */
752 if(!prs_uint8s(False, "unknown", ps, depth, u_2->padding,sizeof(u_2->padding)))
753 return False;
756 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
757 return False;
758 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
759 return False;
761 return True;
764 /*******************************************************************
765 inits a structure.
766 ********************************************************************/
768 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
769 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age)
771 u_1->min_length_password = min_pass_len;
772 u_1->password_history = pass_hist;
773 u_1->flag = flag;
775 /* password never expire */
776 u_1->expire.high = nt_expire.high;
777 u_1->expire.low = nt_expire.low;
779 /* can change the password now */
780 u_1->min_passwordage.high = nt_min_age.high;
781 u_1->min_passwordage.low = nt_min_age.low;
785 /*******************************************************************
786 reads or writes a structure.
787 ********************************************************************/
789 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
790 prs_struct *ps, int depth)
792 if (u_1 == NULL)
793 return False;
795 prs_debug(ps, depth, desc, "sam_io_unk_info1");
796 depth++;
798 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
799 return False;
800 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
801 return False;
802 if(!prs_uint32("flag", ps, depth, &u_1->flag))
803 return False;
804 if(!smb_io_time("expire", &u_1->expire, ps, depth))
805 return False;
806 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
807 return False;
809 return True;
812 /*******************************************************************
813 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
814 ********************************************************************/
816 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
817 uint16 switch_value, SAM_UNK_CTR * ctr,
818 NTSTATUS status)
820 DEBUG(5, ("init_samr_r_query_dom_info\n"));
822 r_u->ptr_0 = 0;
823 r_u->switch_value = 0;
824 r_u->status = status; /* return status */
826 if (NT_STATUS_IS_OK(status)) {
827 r_u->switch_value = switch_value;
828 r_u->ptr_0 = 1;
829 r_u->ctr = ctr;
833 /*******************************************************************
834 reads or writes a structure.
835 ********************************************************************/
837 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
838 prs_struct *ps, int depth)
840 if (r_u == NULL)
841 return False;
843 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
844 depth++;
846 if(!prs_align(ps))
847 return False;
849 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
850 return False;
852 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
853 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
854 return False;
855 if(!prs_align(ps))
856 return False;
858 switch (r_u->switch_value) {
859 case 0x0c:
860 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
861 return False;
862 break;
863 case 0x07:
864 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
865 return False;
866 break;
867 case 0x06:
868 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
869 return False;
870 break;
871 case 0x05:
872 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
873 return False;
874 break;
875 case 0x03:
876 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
877 return False;
878 break;
879 case 0x02:
880 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
881 return False;
882 break;
883 case 0x01:
884 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
885 return False;
886 break;
887 default:
888 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
889 r_u->switch_value));
890 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
891 return False;
895 if(!prs_align(ps))
896 return False;
898 if(!prs_ntstatus("status", ps, depth, &r_u->status))
899 return False;
901 return True;
904 /*******************************************************************
905 reads or writes a SAMR_R_SET_SEC_OBJ structure.
906 ********************************************************************/
908 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
909 prs_struct *ps, int depth)
911 if (r_u == NULL)
912 return False;
914 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
915 depth++;
917 if(!prs_align(ps))
918 return False;
920 if(!prs_ntstatus("status", ps, depth, &r_u->status))
921 return False;
923 return True;
926 /*******************************************************************
927 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
928 ********************************************************************/
930 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
931 prs_struct *ps, int depth)
933 if (r_u == NULL)
934 return False;
936 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
937 depth++;
939 if(!prs_align(ps))
940 return False;
942 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
943 return False;
944 if (r_u->ptr != 0) {
945 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
946 return False;
949 if(!prs_ntstatus("status", ps, depth, &r_u->status))
950 return False;
952 return True;
955 /*******************************************************************
956 reads or writes a SAM_STR1 structure.
957 ********************************************************************/
959 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
960 uint32 name_buf, uint32 desc_buf,
961 prs_struct *ps, int depth)
963 if (sam == NULL)
964 return False;
966 prs_debug(ps, depth, desc, "sam_io_sam_str1");
967 depth++;
969 if(!prs_align(ps))
970 return False;
971 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
972 return False;
974 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
975 return False;
977 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
978 return False;
980 return True;
983 /*******************************************************************
984 inits a SAM_ENTRY1 structure.
985 ********************************************************************/
987 static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
988 uint32 len_sam_name, uint32 len_sam_full,
989 uint32 len_sam_desc, uint32 rid_user,
990 uint16 acb_info)
992 DEBUG(5, ("init_sam_entry1\n"));
994 ZERO_STRUCTP(sam);
996 sam->user_idx = user_idx;
997 sam->rid_user = rid_user;
998 sam->acb_info = acb_info;
1000 init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
1001 init_uni_hdr(&sam->hdr_user_name, len_sam_full);
1002 init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
1005 /*******************************************************************
1006 reads or writes a SAM_ENTRY1 structure.
1007 ********************************************************************/
1009 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1010 prs_struct *ps, int depth)
1012 if (sam == NULL)
1013 return False;
1015 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1016 depth++;
1018 if(!prs_align(ps))
1019 return False;
1021 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1022 return False;
1024 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1025 return False;
1026 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1027 return False;
1029 if(!prs_align(ps))
1030 return False;
1032 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1033 return False;
1034 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1035 return False;
1036 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1037 return False;
1039 return True;
1042 /*******************************************************************
1043 reads or writes a SAM_STR2 structure.
1044 ********************************************************************/
1046 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1047 uint32 desc_buf, prs_struct *ps, int depth)
1049 if (sam == NULL)
1050 return False;
1052 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1053 depth++;
1055 if(!prs_align(ps))
1056 return False;
1058 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1059 return False;
1060 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1061 return False;
1063 return True;
1066 /*******************************************************************
1067 inits a SAM_ENTRY2 structure.
1068 ********************************************************************/
1069 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1070 uint32 len_sam_name, uint32 len_sam_desc,
1071 uint32 rid_user, uint16 acb_info)
1073 DEBUG(5, ("init_sam_entry2\n"));
1075 sam->user_idx = user_idx;
1076 sam->rid_user = rid_user;
1077 sam->acb_info = acb_info;
1079 init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
1080 init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
1083 /*******************************************************************
1084 reads or writes a SAM_ENTRY2 structure.
1085 ********************************************************************/
1087 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1088 prs_struct *ps, int depth)
1090 if (sam == NULL)
1091 return False;
1093 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1094 depth++;
1096 if(!prs_align(ps))
1097 return False;
1099 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1100 return False;
1102 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1103 return False;
1104 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info))
1105 return False;
1107 if(!prs_align(ps))
1108 return False;
1110 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1111 return False;
1112 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1113 return False;
1115 return True;
1118 /*******************************************************************
1119 reads or writes a SAM_STR3 structure.
1120 ********************************************************************/
1122 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1123 uint32 desc_buf, prs_struct *ps, int depth)
1125 if (sam == NULL)
1126 return False;
1128 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1129 depth++;
1131 if(!prs_align(ps))
1132 return False;
1134 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1135 return False;
1136 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1137 return False;
1139 return True;
1142 /*******************************************************************
1143 inits a SAM_ENTRY3 structure.
1144 ********************************************************************/
1146 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1147 uint32 len_grp_name, uint32 len_grp_desc,
1148 uint32 rid_grp)
1150 DEBUG(5, ("init_sam_entry3\n"));
1152 sam->grp_idx = grp_idx;
1153 sam->rid_grp = rid_grp;
1154 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1156 init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
1157 init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
1160 /*******************************************************************
1161 reads or writes a SAM_ENTRY3 structure.
1162 ********************************************************************/
1164 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1165 prs_struct *ps, int depth)
1167 if (sam == NULL)
1168 return False;
1170 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1171 depth++;
1173 if(!prs_align(ps))
1174 return False;
1176 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1177 return False;
1179 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1180 return False;
1181 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1182 return False;
1184 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1185 return False;
1186 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1187 return False;
1189 return True;
1192 /*******************************************************************
1193 inits a SAM_ENTRY4 structure.
1194 ********************************************************************/
1196 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1197 uint32 len_acct_name)
1199 DEBUG(5, ("init_sam_entry4\n"));
1201 sam->user_idx = user_idx;
1202 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1205 /*******************************************************************
1206 reads or writes a SAM_ENTRY4 structure.
1207 ********************************************************************/
1209 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1210 prs_struct *ps, int depth)
1212 if (sam == NULL)
1213 return False;
1215 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1216 depth++;
1218 if(!prs_align(ps))
1219 return False;
1221 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1222 return False;
1223 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1224 return False;
1226 return True;
1229 /*******************************************************************
1230 inits a SAM_ENTRY5 structure.
1231 ********************************************************************/
1233 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1234 uint32 len_grp_name)
1236 DEBUG(5, ("init_sam_entry5\n"));
1238 sam->grp_idx = grp_idx;
1239 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1240 len_grp_name != 0);
1243 /*******************************************************************
1244 reads or writes a SAM_ENTRY5 structure.
1245 ********************************************************************/
1247 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1248 prs_struct *ps, int depth)
1250 if (sam == NULL)
1251 return False;
1253 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1254 depth++;
1256 if(!prs_align(ps))
1257 return False;
1259 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1260 return False;
1261 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1262 return False;
1264 return True;
1267 /*******************************************************************
1268 inits a SAM_ENTRY structure.
1269 ********************************************************************/
1271 void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
1273 DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
1275 sam->rid = rid;
1276 init_uni_hdr(&sam->hdr_name, len_sam_name);
1279 /*******************************************************************
1280 reads or writes a SAM_ENTRY structure.
1281 ********************************************************************/
1283 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1284 prs_struct *ps, int depth)
1286 if (sam == NULL)
1287 return False;
1289 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1290 depth++;
1292 if(!prs_align(ps))
1293 return False;
1294 if(!prs_uint32("rid", ps, depth, &sam->rid))
1295 return False;
1296 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1297 return False;
1299 return True;
1302 /*******************************************************************
1303 inits a SAMR_Q_ENUM_DOM_USERS structure.
1304 ********************************************************************/
1306 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1307 uint32 start_idx,
1308 uint16 acb_mask, uint16 unk_1, uint32 size)
1310 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1312 q_e->pol = *pol;
1314 q_e->start_idx = start_idx; /* zero indicates lots */
1315 q_e->acb_mask = acb_mask;
1316 q_e->unknown_1 = unk_1;
1317 q_e->max_size = size;
1320 /*******************************************************************
1321 reads or writes a structure.
1322 ********************************************************************/
1324 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1325 prs_struct *ps, int depth)
1327 if (q_e == NULL)
1328 return False;
1330 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1331 depth++;
1333 if(!prs_align(ps))
1334 return False;
1336 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1337 return False;
1339 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1340 return False;
1341 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask))
1342 return False;
1343 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1))
1344 return False;
1346 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1347 return False;
1349 return True;
1353 /*******************************************************************
1354 inits a SAMR_R_ENUM_DOM_USERS structure.
1355 ********************************************************************/
1357 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1358 uint32 next_idx, uint32 num_sam_entries)
1360 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1362 r_u->next_idx = next_idx;
1364 if (num_sam_entries != 0) {
1365 r_u->ptr_entries1 = 1;
1366 r_u->ptr_entries2 = 1;
1367 r_u->num_entries2 = num_sam_entries;
1368 r_u->num_entries3 = num_sam_entries;
1370 r_u->num_entries4 = num_sam_entries;
1371 } else {
1372 r_u->ptr_entries1 = 0;
1373 r_u->num_entries2 = num_sam_entries;
1374 r_u->ptr_entries2 = 1;
1378 /*******************************************************************
1379 reads or writes a structure.
1380 ********************************************************************/
1382 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1383 prs_struct *ps, int depth)
1385 uint32 i;
1387 if (r_u == NULL)
1388 return False;
1390 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1391 depth++;
1393 if(!prs_align(ps))
1394 return False;
1396 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1397 return False;
1398 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1399 return False;
1401 if (r_u->ptr_entries1 != 0) {
1402 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1403 return False;
1404 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1405 return False;
1406 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1407 return False;
1409 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1410 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
1411 r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
1414 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1415 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1416 r_u->num_entries4 = 0;
1417 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1418 return False;
1421 for (i = 0; i < r_u->num_entries2; i++) {
1422 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1423 return False;
1426 for (i = 0; i < r_u->num_entries2; i++) {
1427 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1428 return False;
1433 if(!prs_align(ps))
1434 return False;
1436 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1437 return False;
1438 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1439 return False;
1441 return True;
1444 /*******************************************************************
1445 inits a SAMR_Q_QUERY_DISPINFO structure.
1446 ********************************************************************/
1448 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1449 uint16 switch_level, uint32 start_idx,
1450 uint32 max_entries, uint32 max_size)
1452 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1454 q_e->domain_pol = *pol;
1456 q_e->switch_level = switch_level;
1458 q_e->start_idx = start_idx;
1459 q_e->max_entries = max_entries;
1460 q_e->max_size = max_size;
1463 /*******************************************************************
1464 reads or writes a structure.
1465 ********************************************************************/
1467 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1468 prs_struct *ps, int depth)
1470 if (q_e == NULL)
1471 return False;
1473 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1474 depth++;
1476 if(!prs_align(ps))
1477 return False;
1479 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1480 return False;
1482 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1483 return False;
1484 if(!prs_align(ps))
1485 return False;
1487 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1488 return False;
1489 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1490 return False;
1491 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1492 return False;
1494 return True;
1497 /*******************************************************************
1498 inits a SAM_DISPINFO_1 structure.
1499 ********************************************************************/
1501 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries,
1502 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1503 DOM_SID *domain_sid)
1505 uint32 len_sam_name, len_sam_full, len_sam_desc;
1506 uint32 i;
1508 SAM_ACCOUNT *pwd = NULL;
1509 ZERO_STRUCTP(sam);
1511 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1513 if (num_entries==0)
1514 return NT_STATUS_OK;
1516 sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1));
1517 if (!sam->sam)
1518 return NT_STATUS_NO_MEMORY;
1520 sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1));
1521 if (!sam->str)
1522 return NT_STATUS_NO_MEMORY;
1524 ZERO_STRUCTP(sam->sam);
1525 ZERO_STRUCTP(sam->str);
1527 for (i = 0; i < num_entries ; i++) {
1528 const char *username;
1529 const char *fullname;
1530 const char *acct_desc;
1531 uint32 user_rid;
1532 const DOM_SID *user_sid;
1533 fstring user_sid_string, domain_sid_string;
1535 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i));
1537 pwd=&disp_user_info[i+start_idx];
1539 username = pdb_get_username(pwd);
1540 fullname = pdb_get_fullname(pwd);
1541 acct_desc = pdb_get_acct_desc(pwd);
1543 if (!username)
1544 username = "";
1546 if (!fullname)
1547 fullname = "";
1549 if (!acct_desc)
1550 acct_desc = "";
1552 user_sid = pdb_get_user_sid(pwd);
1554 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1555 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1556 "the domain sid %s. Failing operation.\n",
1557 username,
1558 sid_to_string(user_sid_string, user_sid),
1559 sid_to_string(domain_sid_string, domain_sid)));
1560 return NT_STATUS_UNSUCCESSFUL;
1563 len_sam_name = strlen(username);
1564 len_sam_full = strlen(fullname);
1565 len_sam_desc = strlen(acct_desc);
1567 init_sam_entry1(&sam->sam[i], start_idx + i + 1,
1568 len_sam_name, len_sam_full, len_sam_desc,
1569 user_rid, pdb_get_acct_ctrl(pwd));
1571 ZERO_STRUCTP(&sam->str[i].uni_acct_name);
1572 ZERO_STRUCTP(&sam->str[i].uni_full_name);
1573 ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
1575 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
1576 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
1577 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1580 return NT_STATUS_OK;
1583 /*******************************************************************
1584 reads or writes a structure.
1585 ********************************************************************/
1587 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1588 uint32 num_entries,
1589 prs_struct *ps, int depth)
1591 uint32 i;
1593 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1594 depth++;
1596 if(!prs_align(ps))
1597 return False;
1599 if (UNMARSHALLING(ps) && num_entries > 0) {
1601 if ((sam->sam = (SAM_ENTRY1 *)
1602 prs_alloc_mem(ps, sizeof(SAM_ENTRY1) *
1603 num_entries)) == NULL) {
1604 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1605 return False;
1608 if ((sam->str = (SAM_STR1 *)
1609 prs_alloc_mem(ps, sizeof(SAM_STR1) *
1610 num_entries)) == NULL) {
1611 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1612 return False;
1616 for (i = 0; i < num_entries; i++) {
1617 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1618 return False;
1621 for (i = 0; i < num_entries; i++) {
1622 if(!sam_io_sam_str1("", &sam->str[i],
1623 sam->sam[i].hdr_acct_name.buffer,
1624 sam->sam[i].hdr_user_name.buffer,
1625 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1626 return False;
1629 return True;
1632 /*******************************************************************
1633 inits a SAM_DISPINFO_2 structure.
1634 ********************************************************************/
1636 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries,
1637 uint32 start_idx, SAM_ACCOUNT *disp_user_info,
1638 DOM_SID *domain_sid )
1640 uint32 len_sam_name, len_sam_desc;
1641 uint32 i;
1643 SAM_ACCOUNT *pwd = NULL;
1644 ZERO_STRUCTP(sam);
1646 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1648 if (num_entries==0)
1649 return NT_STATUS_OK;
1651 if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2))))
1652 return NT_STATUS_NO_MEMORY;
1654 if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2))))
1655 return NT_STATUS_NO_MEMORY;
1657 ZERO_STRUCTP(sam->sam);
1658 ZERO_STRUCTP(sam->str);
1660 for (i = 0; i < num_entries; i++) {
1661 uint32 user_rid;
1662 const DOM_SID *user_sid;
1663 const char *username;
1664 const char *acct_desc;
1665 fstring user_sid_string, domain_sid_string;
1667 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1668 pwd=&disp_user_info[i+start_idx];
1670 username = pdb_get_username(pwd);
1671 acct_desc = pdb_get_acct_desc(pwd);
1672 user_sid = pdb_get_user_sid(pwd);
1674 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
1675 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1676 "the domain sid %s. Failing operation.\n",
1677 username,
1678 sid_to_string(user_sid_string, user_sid),
1679 sid_to_string(domain_sid_string, domain_sid)));
1680 return NT_STATUS_UNSUCCESSFUL;
1683 len_sam_name = strlen(username);
1684 len_sam_desc = strlen(acct_desc);
1686 init_sam_entry2(&sam->sam[i], start_idx + i + 1,
1687 len_sam_name, len_sam_desc,
1688 user_rid, pdb_get_acct_ctrl(pwd));
1690 ZERO_STRUCTP(&sam->str[i].uni_srv_name);
1691 ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
1693 init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
1694 init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
1697 return NT_STATUS_OK;
1700 /*******************************************************************
1701 reads or writes a structure.
1702 ********************************************************************/
1704 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1705 uint32 num_entries,
1706 prs_struct *ps, int depth)
1708 uint32 i;
1710 if (sam == NULL)
1711 return False;
1713 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1714 depth++;
1716 if(!prs_align(ps))
1717 return False;
1719 if (UNMARSHALLING(ps) && num_entries > 0) {
1721 if ((sam->sam = (SAM_ENTRY2 *)
1722 prs_alloc_mem(ps, sizeof(SAM_ENTRY2) *
1723 num_entries)) == NULL) {
1724 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1725 return False;
1728 if ((sam->str = (SAM_STR2 *)
1729 prs_alloc_mem(ps, sizeof(SAM_STR2) *
1730 num_entries)) == NULL) {
1731 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1732 return False;
1736 for (i = 0; i < num_entries; i++) {
1737 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1738 return False;
1741 for (i = 0; i < num_entries; i++) {
1742 if(!sam_io_sam_str2("", &sam->str[i],
1743 sam->sam[i].hdr_srv_name.buffer,
1744 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1745 return False;
1748 return True;
1751 /*******************************************************************
1752 inits a SAM_DISPINFO_3 structure.
1753 ********************************************************************/
1755 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
1756 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1758 uint32 len_sam_name, len_sam_desc;
1759 uint32 i;
1761 ZERO_STRUCTP(sam);
1763 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1765 if (num_entries==0)
1766 return NT_STATUS_OK;
1768 if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3))))
1769 return NT_STATUS_NO_MEMORY;
1771 if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3))))
1772 return NT_STATUS_NO_MEMORY;
1774 ZERO_STRUCTP(sam->sam);
1775 ZERO_STRUCTP(sam->str);
1777 for (i = 0; i < num_entries; i++) {
1778 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1780 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1782 len_sam_name = strlen(grp->name);
1783 len_sam_desc = strlen(grp->comment);
1785 init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
1787 init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
1788 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
1791 return NT_STATUS_OK;
1794 /*******************************************************************
1795 reads or writes a structure.
1796 ********************************************************************/
1798 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1799 uint32 num_entries,
1800 prs_struct *ps, int depth)
1802 uint32 i;
1804 if (sam == NULL)
1805 return False;
1807 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1808 depth++;
1810 if(!prs_align(ps))
1811 return False;
1813 if (UNMARSHALLING(ps) && num_entries > 0) {
1815 if ((sam->sam = (SAM_ENTRY3 *)
1816 prs_alloc_mem(ps, sizeof(SAM_ENTRY3) *
1817 num_entries)) == NULL) {
1818 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1819 return False;
1822 if ((sam->str = (SAM_STR3 *)
1823 prs_alloc_mem(ps, sizeof(SAM_STR3) *
1824 num_entries)) == NULL) {
1825 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1826 return False;
1830 for (i = 0; i < num_entries; i++) {
1831 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1832 return False;
1835 for (i = 0; i < num_entries; i++) {
1836 if(!sam_io_sam_str3("", &sam->str[i],
1837 sam->sam[i].hdr_grp_name.buffer,
1838 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1839 return False;
1842 return True;
1845 /*******************************************************************
1846 inits a SAM_DISPINFO_4 structure.
1847 ********************************************************************/
1849 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries,
1850 uint32 start_idx, SAM_ACCOUNT *disp_user_info)
1852 uint32 len_sam_name;
1853 uint32 i;
1855 SAM_ACCOUNT *pwd = NULL;
1856 ZERO_STRUCTP(sam);
1858 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1860 if (num_entries==0)
1861 return NT_STATUS_OK;
1863 if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4))))
1864 return NT_STATUS_NO_MEMORY;
1866 if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4))))
1867 return NT_STATUS_NO_MEMORY;
1869 ZERO_STRUCTP(sam->sam);
1870 ZERO_STRUCTP(sam->str);
1872 for (i = 0; i < num_entries; i++) {
1873 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1874 pwd=&disp_user_info[i+start_idx];
1876 len_sam_name = strlen(pdb_get_username(pwd));
1878 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name);
1880 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name);
1883 return NT_STATUS_OK;
1886 /*******************************************************************
1887 reads or writes a structure.
1888 ********************************************************************/
1890 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1891 uint32 num_entries,
1892 prs_struct *ps, int depth)
1894 uint32 i;
1896 if (sam == NULL)
1897 return False;
1899 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1900 depth++;
1902 if(!prs_align(ps))
1903 return False;
1905 if (UNMARSHALLING(ps) && num_entries > 0) {
1907 if ((sam->sam = (SAM_ENTRY4 *)
1908 prs_alloc_mem(ps, sizeof(SAM_ENTRY4) *
1909 num_entries)) == NULL) {
1910 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1911 return False;
1914 if ((sam->str = (SAM_STR4 *)
1915 prs_alloc_mem(ps, sizeof(SAM_STR4) *
1916 num_entries)) == NULL) {
1917 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1918 return False;
1922 for (i = 0; i < num_entries; i++) {
1923 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1924 return False;
1927 for (i = 0; i < num_entries; i++) {
1928 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1929 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1930 return False;
1933 return True;
1936 /*******************************************************************
1937 inits a SAM_DISPINFO_5 structure.
1938 ********************************************************************/
1940 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries,
1941 uint32 start_idx, DOMAIN_GRP *disp_group_info)
1943 uint32 len_sam_name;
1944 uint32 i;
1946 ZERO_STRUCTP(sam);
1948 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1950 if (num_entries==0)
1951 return NT_STATUS_OK;
1953 if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5))))
1954 return NT_STATUS_NO_MEMORY;
1956 if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5))))
1957 return NT_STATUS_NO_MEMORY;
1959 ZERO_STRUCTP(sam->sam);
1960 ZERO_STRUCTP(sam->str);
1962 for (i = 0; i < num_entries; i++) {
1963 DOMAIN_GRP *grp = &disp_group_info[i+start_idx];
1965 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1967 len_sam_name = strlen(grp->name);
1969 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name);
1970 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name);
1973 return NT_STATUS_OK;
1976 /*******************************************************************
1977 reads or writes a structure.
1978 ********************************************************************/
1980 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1981 uint32 num_entries,
1982 prs_struct *ps, int depth)
1984 uint32 i;
1986 if (sam == NULL)
1987 return False;
1989 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1990 depth++;
1992 if(!prs_align(ps))
1993 return False;
1995 if (UNMARSHALLING(ps) && num_entries > 0) {
1997 if ((sam->sam = (SAM_ENTRY5 *)
1998 prs_alloc_mem(ps, sizeof(SAM_ENTRY5) *
1999 num_entries)) == NULL) {
2000 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2001 return False;
2004 if ((sam->str = (SAM_STR5 *)
2005 prs_alloc_mem(ps, sizeof(SAM_STR5) *
2006 num_entries)) == NULL) {
2007 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2008 return False;
2012 for (i = 0; i < num_entries; i++) {
2013 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2014 return False;
2017 for (i = 0; i < num_entries; i++) {
2018 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2019 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2020 return False;
2023 return True;
2026 /*******************************************************************
2027 inits a SAMR_R_QUERY_DISPINFO structure.
2028 ********************************************************************/
2030 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2031 uint32 num_entries, uint32 total_size, uint32 data_size,
2032 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2033 NTSTATUS status)
2035 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2037 r_u->total_size = total_size;
2039 r_u->data_size = data_size;
2041 r_u->switch_level = switch_level;
2042 r_u->num_entries = num_entries;
2044 if (num_entries==0)
2045 r_u->ptr_entries = 0;
2046 else
2047 r_u->ptr_entries = 1;
2049 r_u->num_entries2 = num_entries;
2050 r_u->ctr = ctr;
2052 r_u->status = status;
2055 /*******************************************************************
2056 reads or writes a structure.
2057 ********************************************************************/
2059 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2060 prs_struct *ps, int depth)
2062 if (r_u == NULL)
2063 return False;
2065 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2066 depth++;
2068 if(!prs_align(ps))
2069 return False;
2071 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2072 return False;
2073 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2074 return False;
2075 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2076 return False;
2077 if(!prs_align(ps))
2078 return False;
2080 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2081 return False;
2082 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2083 return False;
2085 if (r_u->ptr_entries==0) {
2086 if(!prs_align(ps))
2087 return False;
2088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2089 return False;
2091 return True;
2094 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2095 return False;
2097 switch (r_u->switch_level) {
2098 case 0x1:
2099 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2100 r_u->num_entries, ps, depth))
2101 return False;
2102 break;
2103 case 0x2:
2104 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2105 r_u->num_entries, ps, depth))
2106 return False;
2107 break;
2108 case 0x3:
2109 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2110 r_u->num_entries, ps, depth))
2111 return False;
2112 break;
2113 case 0x4:
2114 if(!sam_io_sam_dispinfo_4("user list",
2115 r_u->ctr->sam.info4,
2116 r_u->num_entries, ps, depth))
2117 return False;
2118 break;
2119 case 0x5:
2120 if(!sam_io_sam_dispinfo_5("group list",
2121 r_u->ctr->sam.info5,
2122 r_u->num_entries, ps, depth))
2123 return False;
2124 break;
2125 default:
2126 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2127 break;
2130 if(!prs_align(ps))
2131 return False;
2132 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2133 return False;
2135 return True;
2138 /*******************************************************************
2139 inits a SAMR_Q_OPEN_GROUP structure.
2140 ********************************************************************/
2142 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2143 POLICY_HND *hnd,
2144 uint32 access_mask, uint32 rid)
2146 DEBUG(5, ("init_samr_q_open_group\n"));
2148 q_c->domain_pol = *hnd;
2149 q_c->access_mask = access_mask;
2150 q_c->rid_group = rid;
2153 /*******************************************************************
2154 reads or writes a structure.
2155 ********************************************************************/
2157 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2158 prs_struct *ps, int depth)
2160 if (q_u == NULL)
2161 return False;
2163 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2164 depth++;
2166 if(!prs_align(ps))
2167 return False;
2169 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2170 return False;
2172 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2173 return False;
2174 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2175 return False;
2177 return True;
2180 /*******************************************************************
2181 reads or writes a structure.
2182 ********************************************************************/
2184 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2185 prs_struct *ps, int depth)
2187 if (r_u == NULL)
2188 return False;
2190 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2191 depth++;
2193 if(!prs_align(ps))
2194 return False;
2196 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2197 return False;
2199 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2200 return False;
2202 return True;
2205 /*******************************************************************
2206 inits a GROUP_INFO1 structure.
2207 ********************************************************************/
2209 void init_samr_group_info1(GROUP_INFO1 * gr1,
2210 char *acct_name, char *acct_desc,
2211 uint32 num_members)
2213 int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2214 int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
2216 DEBUG(5, ("init_samr_group_info1\n"));
2218 init_uni_hdr(&gr1->hdr_acct_name, acct_len);
2220 gr1->unknown_1 = 0x3;
2221 gr1->num_members = num_members;
2223 init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
2225 init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
2226 init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
2229 /*******************************************************************
2230 reads or writes a structure.
2231 ********************************************************************/
2233 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2234 prs_struct *ps, int depth)
2236 if (gr1 == NULL)
2237 return False;
2239 prs_debug(ps, depth, desc, "samr_io_group_info1");
2240 depth++;
2242 if(!prs_align(ps))
2243 return False;
2245 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2246 return False;
2248 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1))
2249 return False;
2250 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2251 return False;
2253 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2254 return False;
2256 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2257 gr1->hdr_acct_name.buffer, ps, depth))
2258 return False;
2260 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2261 gr1->hdr_acct_desc.buffer, ps, depth))
2262 return False;
2264 return True;
2267 /*******************************************************************
2268 inits a GROUP_INFO3 structure.
2269 ********************************************************************/
2271 void init_samr_group_info3(GROUP_INFO3 *gr3)
2273 DEBUG(5, ("init_samr_group_info3\n"));
2275 gr3->unknown_1 = 0x3;
2278 /*******************************************************************
2279 reads or writes a structure.
2280 ********************************************************************/
2282 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2284 if (gr3 == NULL)
2285 return False;
2287 prs_debug(ps, depth, desc, "samr_io_group_info3");
2288 depth++;
2290 if(!prs_align(ps))
2291 return False;
2293 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1))
2294 return False;
2296 return True;
2299 /*******************************************************************
2300 inits a GROUP_INFO4 structure.
2301 ********************************************************************/
2303 void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
2305 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2307 DEBUG(5, ("init_samr_group_info4\n"));
2309 init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
2310 init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
2313 /*******************************************************************
2314 reads or writes a structure.
2315 ********************************************************************/
2317 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2318 prs_struct *ps, int depth)
2320 if (gr4 == NULL)
2321 return False;
2323 prs_debug(ps, depth, desc, "samr_io_group_info4");
2324 depth++;
2326 if(!prs_align(ps))
2327 return False;
2329 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2330 return False;
2331 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2332 gr4->hdr_acct_desc.buffer, ps, depth))
2333 return False;
2335 return True;
2338 /*******************************************************************
2339 reads or writes a structure.
2340 ********************************************************************/
2342 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2343 prs_struct *ps, int depth)
2345 if (UNMARSHALLING(ps))
2346 *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
2348 if (*ctr == NULL)
2349 return False;
2351 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2352 depth++;
2354 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2355 return False;
2357 switch ((*ctr)->switch_value1) {
2358 case 1:
2359 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2360 return False;
2361 break;
2362 case 3:
2363 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2364 return False;
2365 break;
2366 case 4:
2367 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2368 return False;
2369 break;
2370 default:
2371 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2372 break;
2375 return True;
2378 /*******************************************************************
2379 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2380 ********************************************************************/
2382 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2383 POLICY_HND *pol, char *acct_desc,
2384 uint32 access_mask)
2386 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
2388 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2390 q_e->pol = *pol;
2392 init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
2393 init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
2395 q_e->access_mask = access_mask;
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2403 prs_struct *ps, int depth)
2405 if (q_e == NULL)
2406 return False;
2408 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2409 depth++;
2411 if(!prs_align(ps))
2412 return False;
2414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2415 return False;
2417 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2418 return False;
2419 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2420 q_e->hdr_acct_desc.buffer, ps, depth))
2421 return False;
2423 if(!prs_align(ps))
2424 return False;
2425 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2426 return False;
2428 return True;
2431 /*******************************************************************
2432 reads or writes a structure.
2433 ********************************************************************/
2435 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2436 prs_struct *ps, int depth)
2438 if (r_u == NULL)
2439 return False;
2441 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2442 depth++;
2444 if(!prs_align(ps))
2445 return False;
2447 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2448 return False;
2450 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2451 return False;
2452 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2453 return False;
2455 return True;
2458 /*******************************************************************
2459 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2460 ********************************************************************/
2462 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2463 POLICY_HND *hnd)
2465 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2467 q_c->group_pol = *hnd;
2470 /*******************************************************************
2471 reads or writes a structure.
2472 ********************************************************************/
2474 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2475 prs_struct *ps, int depth)
2477 if (q_u == NULL)
2478 return False;
2480 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2481 depth++;
2483 if(!prs_align(ps))
2484 return False;
2486 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2487 return False;
2489 return True;
2492 /*******************************************************************
2493 reads or writes a structure.
2494 ********************************************************************/
2496 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2497 prs_struct *ps, int depth)
2499 if (r_u == NULL)
2500 return False;
2502 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2503 depth++;
2505 if(!prs_align(ps))
2506 return False;
2508 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2509 return False;
2511 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2512 return False;
2514 return True;
2517 /*******************************************************************
2518 inits a SAMR_Q_DEL_GROUPMEM structure.
2519 ********************************************************************/
2521 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2522 POLICY_HND *pol, uint32 rid)
2524 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2526 q_e->pol = *pol;
2527 q_e->rid = rid;
2530 /*******************************************************************
2531 reads or writes a structure.
2532 ********************************************************************/
2534 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2535 prs_struct *ps, int depth)
2537 if (q_e == NULL)
2538 return False;
2540 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2541 depth++;
2543 if(!prs_align(ps))
2544 return False;
2546 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2547 return False;
2549 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2550 return False;
2552 return True;
2555 /*******************************************************************
2556 inits a SAMR_R_DEL_GROUPMEM structure.
2557 ********************************************************************/
2559 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2560 NTSTATUS status)
2562 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2564 r_u->status = status;
2567 /*******************************************************************
2568 reads or writes a structure.
2569 ********************************************************************/
2571 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2572 prs_struct *ps, int depth)
2574 if (r_u == NULL)
2575 return False;
2577 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2578 depth++;
2580 if(!prs_align(ps))
2581 return False;
2583 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2584 return False;
2586 return True;
2589 /*******************************************************************
2590 inits a SAMR_Q_ADD_GROUPMEM structure.
2591 ********************************************************************/
2593 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2594 POLICY_HND *pol, uint32 rid)
2596 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2598 q_e->pol = *pol;
2599 q_e->rid = rid;
2600 q_e->unknown = 0x0005;
2603 /*******************************************************************
2604 reads or writes a structure.
2605 ********************************************************************/
2607 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2608 prs_struct *ps, int depth)
2610 if (q_e == NULL)
2611 return False;
2613 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2614 depth++;
2616 if(!prs_align(ps))
2617 return False;
2619 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2620 return False;
2622 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2623 return False;
2624 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2625 return False;
2627 return True;
2630 /*******************************************************************
2631 inits a SAMR_R_ADD_GROUPMEM structure.
2632 ********************************************************************/
2634 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2635 NTSTATUS status)
2637 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2639 r_u->status = status;
2642 /*******************************************************************
2643 reads or writes a structure.
2644 ********************************************************************/
2646 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2647 prs_struct *ps, int depth)
2649 if (r_u == NULL)
2650 return False;
2652 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2653 depth++;
2655 if(!prs_align(ps))
2656 return False;
2658 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2659 return False;
2661 return True;
2664 /*******************************************************************
2665 inits a SAMR_Q_SET_GROUPINFO structure.
2666 ********************************************************************/
2668 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2669 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2671 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2673 q_e->pol = *pol;
2674 q_e->ctr = ctr;
2677 /*******************************************************************
2678 reads or writes a structure.
2679 ********************************************************************/
2681 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2682 prs_struct *ps, int depth)
2684 if (q_e == NULL)
2685 return False;
2687 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2688 depth++;
2690 if(!prs_align(ps))
2691 return False;
2693 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2694 return False;
2696 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2697 return False;
2699 return True;
2702 /*******************************************************************
2703 inits a SAMR_R_SET_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2708 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2710 r_u->status = status;
2713 /*******************************************************************
2714 reads or writes a structure.
2715 ********************************************************************/
2717 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2718 prs_struct *ps, int depth)
2720 if (r_u == NULL)
2721 return False;
2723 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2724 depth++;
2726 if(!prs_align(ps))
2727 return False;
2729 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2730 return False;
2732 return True;
2735 /*******************************************************************
2736 inits a SAMR_Q_QUERY_GROUPINFO structure.
2737 ********************************************************************/
2739 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2740 POLICY_HND *pol, uint16 switch_level)
2742 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2744 q_e->pol = *pol;
2746 q_e->switch_level = switch_level;
2749 /*******************************************************************
2750 reads or writes a structure.
2751 ********************************************************************/
2753 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2754 prs_struct *ps, int depth)
2756 if (q_e == NULL)
2757 return False;
2759 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2760 depth++;
2762 if(!prs_align(ps))
2763 return False;
2765 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2766 return False;
2768 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2769 return False;
2771 return True;
2774 /*******************************************************************
2775 inits a SAMR_R_QUERY_GROUPINFO structure.
2776 ********************************************************************/
2778 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2779 GROUP_INFO_CTR * ctr, NTSTATUS status)
2781 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2783 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2784 r_u->ctr = ctr;
2785 r_u->status = status;
2788 /*******************************************************************
2789 reads or writes a structure.
2790 ********************************************************************/
2792 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2793 prs_struct *ps, int depth)
2795 if (r_u == NULL)
2796 return False;
2798 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2799 depth++;
2801 if(!prs_align(ps))
2802 return False;
2804 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2805 return False;
2807 if (r_u->ptr != 0) {
2808 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2809 return False;
2812 if(!prs_align(ps))
2813 return False;
2814 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2815 return False;
2817 return True;
2820 /*******************************************************************
2821 inits a SAMR_Q_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2826 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2828 q_c->group_pol = *hnd;
2831 /*******************************************************************
2832 reads or writes a structure.
2833 ********************************************************************/
2835 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2836 prs_struct *ps, int depth)
2838 if (q_u == NULL)
2839 return False;
2841 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2842 depth++;
2844 if(!prs_align(ps))
2845 return False;
2847 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2848 return False;
2850 return True;
2853 /*******************************************************************
2854 inits a SAMR_R_QUERY_GROUPMEM structure.
2855 ********************************************************************/
2857 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2858 uint32 num_entries, uint32 *rid,
2859 uint32 *attr, NTSTATUS status)
2861 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2863 if (NT_STATUS_IS_OK(status)) {
2864 r_u->ptr = 1;
2865 r_u->num_entries = num_entries;
2867 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2868 r_u->ptr_rids = rid != NULL ? 1 : 0;
2870 r_u->num_rids = num_entries;
2871 r_u->rid = rid;
2873 r_u->num_attrs = num_entries;
2874 r_u->attr = attr;
2875 } else {
2876 r_u->ptr = 0;
2877 r_u->num_entries = 0;
2880 r_u->status = status;
2883 /*******************************************************************
2884 reads or writes a structure.
2885 ********************************************************************/
2887 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2888 prs_struct *ps, int depth)
2890 uint32 i;
2892 if (r_u == NULL)
2893 return False;
2895 if (UNMARSHALLING(ps))
2896 ZERO_STRUCTP(r_u);
2898 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2899 depth++;
2901 if(!prs_align(ps))
2902 return False;
2904 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2905 return False;
2906 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2907 return False;
2909 if (r_u->ptr != 0) {
2910 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2911 return False;
2912 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2913 return False;
2915 if (r_u->ptr_rids != 0) {
2916 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2917 return False;
2918 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2919 r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids);
2920 if (r_u->rid == NULL)
2921 return False;
2924 for (i = 0; i < r_u->num_rids; i++) {
2925 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2926 return False;
2930 if (r_u->ptr_attrs != 0) {
2931 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2932 return False;
2934 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2935 r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs);
2936 if (r_u->attr == NULL)
2937 return False;
2940 for (i = 0; i < r_u->num_attrs; i++) {
2941 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2942 return False;
2947 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2948 return False;
2950 return True;
2953 /*******************************************************************
2954 inits a SAMR_Q_QUERY_USERGROUPS structure.
2955 ********************************************************************/
2957 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2958 POLICY_HND *hnd)
2960 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2962 q_u->pol = *hnd;
2965 /*******************************************************************
2966 reads or writes a structure.
2967 ********************************************************************/
2969 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
2970 prs_struct *ps, int depth)
2972 if (q_u == NULL)
2973 return False;
2975 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
2976 depth++;
2978 if(!prs_align(ps))
2979 return False;
2981 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
2982 return False;
2984 return True;
2987 /*******************************************************************
2988 inits a SAMR_R_QUERY_USERGROUPS structure.
2989 ********************************************************************/
2991 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
2992 uint32 num_gids, DOM_GID * gid,
2993 NTSTATUS status)
2995 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2997 if (NT_STATUS_IS_OK(status)) {
2998 r_u->ptr_0 = 1;
2999 r_u->num_entries = num_gids;
3000 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3001 r_u->num_entries2 = num_gids;
3003 r_u->gid = gid;
3004 } else {
3005 r_u->ptr_0 = 0;
3006 r_u->num_entries = 0;
3007 r_u->ptr_1 = 0;
3008 r_u->gid = NULL;
3011 r_u->status = status;
3014 /*******************************************************************
3015 reads or writes a structure.
3016 ********************************************************************/
3018 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3019 prs_struct *ps, int depth)
3021 uint32 i;
3022 if (gid == NULL)
3023 return False;
3025 prs_debug(ps, depth, desc, "samr_io_gids");
3026 depth++;
3028 if(!prs_align(ps))
3029 return False;
3031 if(!prs_uint32("num_gids", ps, depth, num_gids))
3032 return False;
3034 if ((*num_gids) != 0) {
3035 if (UNMARSHALLING(ps)) {
3036 (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids));
3039 if ((*gid) == NULL) {
3040 return False;
3043 for (i = 0; i < (*num_gids); i++) {
3044 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3045 return False;
3049 return True;
3052 /*******************************************************************
3053 reads or writes a structure.
3054 ********************************************************************/
3056 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3057 prs_struct *ps, int depth)
3059 if (r_u == NULL)
3060 return False;
3062 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3063 depth++;
3065 if(!prs_align(ps))
3066 return False;
3068 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3069 return False;
3071 if (r_u->ptr_0 != 0) {
3072 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3073 return False;
3074 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3075 return False;
3077 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3078 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3079 return False;
3083 if(!prs_align(ps))
3084 return False;
3085 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3086 return False;
3088 return True;
3091 /*******************************************************************
3092 inits a SAMR_Q_ENUM_DOMAINS structure.
3093 ********************************************************************/
3095 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3096 POLICY_HND *pol,
3097 uint32 start_idx, uint32 size)
3099 DEBUG(5, ("init_samr_q_enum_domains\n"));
3101 q_e->pol = *pol;
3103 q_e->start_idx = start_idx;
3104 q_e->max_size = size;
3107 /*******************************************************************
3108 reads or writes a structure.
3109 ********************************************************************/
3111 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3112 prs_struct *ps, int depth)
3114 if (q_e == NULL)
3115 return False;
3117 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3118 depth++;
3120 if(!prs_align(ps))
3121 return False;
3123 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3124 return False;
3126 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3127 return False;
3128 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3129 return False;
3131 return True;
3134 /*******************************************************************
3135 inits a SAMR_R_ENUM_DOMAINS structure.
3136 ********************************************************************/
3138 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3139 uint32 next_idx, uint32 num_sam_entries)
3141 DEBUG(5, ("init_samr_r_enum_domains\n"));
3143 r_u->next_idx = next_idx;
3145 if (num_sam_entries != 0) {
3146 r_u->ptr_entries1 = 1;
3147 r_u->ptr_entries2 = 1;
3148 r_u->num_entries2 = num_sam_entries;
3149 r_u->num_entries3 = num_sam_entries;
3151 r_u->num_entries4 = num_sam_entries;
3152 } else {
3153 r_u->ptr_entries1 = 0;
3154 r_u->num_entries2 = num_sam_entries;
3155 r_u->ptr_entries2 = 1;
3159 /*******************************************************************
3160 reads or writes a structure.
3161 ********************************************************************/
3163 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3164 prs_struct *ps, int depth)
3166 uint32 i;
3168 if (r_u == NULL)
3169 return False;
3171 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3172 depth++;
3174 if(!prs_align(ps))
3175 return False;
3177 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3178 return False;
3179 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3180 return False;
3182 if (r_u->ptr_entries1 != 0) {
3183 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3184 return False;
3185 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3186 return False;
3187 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3188 return False;
3190 if (UNMARSHALLING(ps)) {
3191 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3192 r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3195 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3196 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3197 r_u->num_entries4 = 0;
3198 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3199 return False;
3202 for (i = 0; i < r_u->num_entries2; i++) {
3203 fstring tmp;
3204 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3205 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3206 return False;
3209 for (i = 0; i < r_u->num_entries2; i++) {
3210 fstring tmp;
3211 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3212 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3213 r_u->sam[i].hdr_name.buffer, ps,
3214 depth))
3215 return False;
3220 if(!prs_align(ps))
3221 return False;
3222 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3223 return False;
3224 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3225 return False;
3227 return True;
3230 /*******************************************************************
3231 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3232 ********************************************************************/
3234 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3235 POLICY_HND *pol,
3236 uint32 start_idx, uint32 size)
3238 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3240 q_e->pol = *pol;
3242 q_e->start_idx = start_idx;
3243 q_e->max_size = size;
3246 /*******************************************************************
3247 reads or writes a structure.
3248 ********************************************************************/
3250 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3251 prs_struct *ps, int depth)
3253 if (q_e == NULL)
3254 return False;
3256 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3257 depth++;
3259 if(!prs_align(ps))
3260 return False;
3262 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3263 return False;
3265 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3266 return False;
3267 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3268 return False;
3270 return True;
3273 /*******************************************************************
3274 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3275 ********************************************************************/
3277 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3278 uint32 next_idx, uint32 num_sam_entries)
3280 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3282 r_u->next_idx = next_idx;
3284 if (num_sam_entries != 0) {
3285 r_u->ptr_entries1 = 1;
3286 r_u->ptr_entries2 = 1;
3287 r_u->num_entries2 = num_sam_entries;
3288 r_u->num_entries3 = num_sam_entries;
3290 r_u->num_entries4 = num_sam_entries;
3291 } else {
3292 r_u->ptr_entries1 = 0;
3293 r_u->num_entries2 = num_sam_entries;
3294 r_u->ptr_entries2 = 1;
3298 /*******************************************************************
3299 reads or writes a structure.
3300 ********************************************************************/
3302 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3303 prs_struct *ps, int depth)
3305 uint32 i;
3307 if (r_u == NULL)
3308 return False;
3310 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3311 depth++;
3313 if(!prs_align(ps))
3314 return False;
3316 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3317 return False;
3318 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3319 return False;
3321 if (r_u->ptr_entries1 != 0) {
3322 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3323 return False;
3324 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3325 return False;
3326 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3327 return False;
3329 if (UNMARSHALLING(ps)) {
3330 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3331 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3334 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3335 DEBUG(0,
3336 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3337 r_u->num_entries4 = 0;
3338 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3339 return False;
3342 for (i = 0; i < r_u->num_entries2; i++) {
3343 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3344 return False;
3347 for (i = 0; i < r_u->num_entries2; i++) {
3348 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3349 r_u->sam[i].hdr_name.buffer, ps, depth))
3350 return False;
3354 if(!prs_align(ps))
3355 return False;
3356 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3357 return False;
3358 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3359 return False;
3361 return True;
3364 /*******************************************************************
3365 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3366 ********************************************************************/
3368 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3369 POLICY_HND *pol, uint32 start_idx,
3370 uint32 size)
3372 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3374 q_e->pol = *pol;
3376 q_e->start_idx = start_idx;
3377 q_e->max_size = size;
3381 /*******************************************************************
3382 reads or writes a structure.
3383 ********************************************************************/
3385 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3386 prs_struct *ps, int depth)
3388 if (q_e == NULL)
3389 return False;
3391 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3392 depth++;
3394 if(!prs_align(ps))
3395 return False;
3397 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3398 return False;
3400 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3401 return False;
3402 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3403 return False;
3405 return True;
3408 /*******************************************************************
3409 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3410 ********************************************************************/
3412 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3414 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3416 r_u->next_idx = next_idx;
3418 if (num_sam_entries != 0) {
3419 r_u->ptr_entries1 = 1;
3420 r_u->ptr_entries2 = 1;
3421 r_u->num_entries2 = num_sam_entries;
3422 r_u->num_entries3 = num_sam_entries;
3424 r_u->num_entries4 = num_sam_entries;
3425 } else {
3426 r_u->ptr_entries1 = 0;
3427 r_u->num_entries2 = num_sam_entries;
3428 r_u->ptr_entries2 = 1;
3432 /*******************************************************************
3433 reads or writes a structure.
3434 ********************************************************************/
3436 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3437 prs_struct *ps, int depth)
3439 uint32 i;
3441 if (r_u == NULL)
3442 return False;
3444 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3445 depth++;
3447 if(!prs_align(ps))
3448 return False;
3450 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3451 return False;
3452 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3453 return False;
3455 if (r_u->ptr_entries1 != 0) {
3456 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3457 return False;
3458 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3459 return False;
3460 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3461 return False;
3463 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3464 r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2);
3465 r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2);
3468 if (r_u->num_entries2 != 0 &&
3469 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3470 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3471 r_u->num_entries4 = 0;
3472 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3473 return False;
3476 for (i = 0; i < r_u->num_entries2; i++) {
3477 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3478 return False;
3481 for (i = 0; i < r_u->num_entries2; i++) {
3482 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3483 r_u->sam[i].hdr_name.buffer, ps,
3484 depth))
3485 return False;
3489 if(!prs_align(ps))
3490 return False;
3491 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3492 return False;
3493 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3494 return False;
3496 return True;
3499 /*******************************************************************
3500 inits a ALIAS_INFO1 structure.
3501 ********************************************************************/
3503 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3505 int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
3506 int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
3508 DEBUG(5, ("init_samr_alias_info1\n"));
3510 init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
3511 init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
3513 al1->num_member=num_member;
3515 init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
3516 init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
3519 /*******************************************************************
3520 reads or writes a structure.
3521 ********************************************************************/
3523 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3524 prs_struct *ps, int depth)
3526 if (al1 == NULL)
3527 return False;
3529 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3530 depth++;
3532 if(!prs_align(ps))
3533 return False;
3535 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth))
3536 return False;
3537 if(!prs_uint32("num_member", ps, depth, &al1->num_member))
3538 return False;
3539 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth))
3540 return False;
3542 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name,
3543 al1->hdr_acct_name.buffer, ps, depth))
3544 return False;
3546 if(!prs_align(ps))
3547 return False;
3549 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc,
3550 al1->hdr_acct_desc.buffer, ps, depth))
3551 return False;
3553 return True;
3556 /*******************************************************************
3557 inits a ALIAS_INFO3 structure.
3558 ********************************************************************/
3560 void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
3562 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
3564 DEBUG(5, ("init_samr_alias_info3\n"));
3566 init_uni_hdr(&al3->hdr_acct_desc, acct_len);
3567 init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
3570 /*******************************************************************
3571 reads or writes a structure.
3572 ********************************************************************/
3574 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3,
3575 prs_struct *ps, int depth)
3577 if (al3 == NULL)
3578 return False;
3580 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3581 depth++;
3583 if(!prs_align(ps))
3584 return False;
3586 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth))
3587 return False;
3588 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc,
3589 al3->hdr_acct_desc.buffer, ps, depth))
3590 return False;
3592 return True;
3595 /*******************************************************************
3596 reads or writes a structure.
3597 ********************************************************************/
3599 BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr,
3600 prs_struct *ps, int depth)
3602 if (ctr == NULL)
3603 return False;
3605 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3606 depth++;
3608 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
3609 return False;
3610 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
3611 return False;
3613 switch (ctr->switch_value1) {
3614 case 1:
3615 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3616 return False;
3617 break;
3618 case 3:
3619 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3620 return False;
3621 break;
3622 default:
3623 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3624 break;
3627 return True;
3630 /*******************************************************************
3631 inits a SAMR_Q_QUERY_ALIASINFO structure.
3632 ********************************************************************/
3634 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3635 POLICY_HND *pol, uint16 switch_level)
3637 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3639 q_e->pol = *pol;
3640 q_e->switch_level = switch_level;
3643 /*******************************************************************
3644 reads or writes a structure.
3645 ********************************************************************/
3647 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e,
3648 prs_struct *ps, int depth)
3650 if (q_e == NULL)
3651 return False;
3653 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3654 depth++;
3656 if(!prs_align(ps))
3657 return False;
3659 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3660 return False;
3662 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
3663 return False;
3665 return True;
3668 /*******************************************************************
3669 inits a SAMR_R_QUERY_ALIASINFO structure.
3670 ********************************************************************/
3672 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u,
3673 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3675 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3677 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3678 r_u->ctr = *ctr;
3679 r_u->status = status;
3682 /*******************************************************************
3683 reads or writes a structure.
3684 ********************************************************************/
3686 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u,
3687 prs_struct *ps, int depth)
3689 if (r_u == NULL)
3690 return False;
3692 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3693 depth++;
3695 if(!prs_align(ps))
3696 return False;
3698 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3699 return False;
3701 if (r_u->ptr != 0) {
3702 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth))
3703 return False;
3706 if(!prs_align(ps))
3707 return False;
3708 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3709 return False;
3711 return True;
3714 /*******************************************************************
3715 inits a SAMR_Q_SET_ALIASINFO structure.
3716 ********************************************************************/
3718 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3719 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3721 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3723 q_u->alias_pol = *hnd;
3724 q_u->ctr = *ctr;
3727 /*******************************************************************
3728 reads or writes a structure.
3729 ********************************************************************/
3731 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3732 prs_struct *ps, int depth)
3734 if (q_u == NULL)
3735 return False;
3737 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3738 depth++;
3740 if(!prs_align(ps))
3741 return False;
3743 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3744 return False;
3745 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth))
3746 return False;
3748 return True;
3751 /*******************************************************************
3752 reads or writes a structure.
3753 ********************************************************************/
3755 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3756 prs_struct *ps, int depth)
3758 if (r_u == NULL)
3759 return False;
3761 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3762 depth++;
3764 if(!prs_align(ps))
3765 return False;
3766 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3767 return False;
3769 return True;
3772 /*******************************************************************
3773 inits a SAMR_Q_QUERY_USERALIASES structure.
3774 ********************************************************************/
3776 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3777 POLICY_HND *hnd,
3778 uint32 num_sids,
3779 uint32 *ptr_sid, DOM_SID2 * sid)
3781 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3783 q_u->pol = *hnd;
3785 q_u->num_sids1 = num_sids;
3786 q_u->ptr = 1;
3787 q_u->num_sids2 = num_sids;
3789 q_u->ptr_sid = ptr_sid;
3790 q_u->sid = sid;
3793 /*******************************************************************
3794 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3795 ********************************************************************/
3797 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3798 prs_struct *ps, int depth)
3800 fstring tmp;
3801 uint32 i;
3803 if (q_u == NULL)
3804 return False;
3806 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3807 depth++;
3809 if(!prs_align(ps))
3810 return False;
3812 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3813 return False;
3815 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3816 return False;
3817 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3818 return False;
3820 if (q_u->ptr==0)
3821 return True;
3823 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3824 return False;
3826 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3827 q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2);
3828 if (q_u->ptr_sid == NULL)
3829 return False;
3831 q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2);
3832 if (q_u->sid == NULL)
3833 return False;
3836 for (i = 0; i < q_u->num_sids2; i++) {
3837 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3838 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3839 return False;
3842 for (i = 0; i < q_u->num_sids2; i++) {
3843 if (q_u->ptr_sid[i] != 0) {
3844 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3845 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3846 return False;
3850 return True;
3853 /*******************************************************************
3854 inits a SAMR_R_QUERY_USERALIASES structure.
3855 ********************************************************************/
3857 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3858 uint32 num_rids, uint32 *rid,
3859 NTSTATUS status)
3861 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3863 if (NT_STATUS_IS_OK(status)) {
3864 r_u->num_entries = num_rids;
3865 r_u->ptr = 1;
3866 r_u->num_entries2 = num_rids;
3868 r_u->rid = rid;
3869 } else {
3870 r_u->num_entries = 0;
3871 r_u->ptr = 0;
3872 r_u->num_entries2 = 0;
3875 r_u->status = status;
3878 /*******************************************************************
3879 reads or writes a structure.
3880 ********************************************************************/
3882 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3883 prs_struct *ps, int depth)
3885 fstring tmp;
3886 uint32 i;
3887 if (rid == NULL)
3888 return False;
3890 prs_debug(ps, depth, desc, "samr_io_rids");
3891 depth++;
3893 if(!prs_align(ps))
3894 return False;
3896 if(!prs_uint32("num_rids", ps, depth, num_rids))
3897 return False;
3899 if ((*num_rids) != 0) {
3900 if (UNMARSHALLING(ps)) {
3901 /* reading */
3902 (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids));
3904 if ((*rid) == NULL)
3905 return False;
3907 for (i = 0; i < (*num_rids); i++) {
3908 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3909 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3910 return False;
3914 return True;
3917 /*******************************************************************
3918 reads or writes a structure.
3919 ********************************************************************/
3921 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3922 prs_struct *ps, int depth)
3924 if (r_u == NULL)
3925 return False;
3927 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3928 depth++;
3930 if(!prs_align(ps))
3931 return False;
3933 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3934 return False;
3935 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3936 return False;
3938 if (r_u->ptr != 0) {
3939 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3940 return False;
3943 if(!prs_align(ps))
3944 return False;
3945 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3946 return False;
3948 return True;
3951 /*******************************************************************
3952 inits a SAMR_Q_OPEN_ALIAS structure.
3953 ********************************************************************/
3955 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
3956 uint32 access_mask, uint32 rid)
3958 DEBUG(5, ("init_samr_q_open_alias\n"));
3960 q_u->dom_pol = *pol;
3961 q_u->access_mask = access_mask;
3962 q_u->rid_alias = rid;
3965 /*******************************************************************
3966 reads or writes a structure.
3967 ********************************************************************/
3969 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
3970 prs_struct *ps, int depth)
3972 if (q_u == NULL)
3973 return False;
3975 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
3976 depth++;
3978 if(!prs_align(ps))
3979 return False;
3981 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
3982 return False;
3984 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
3985 return False;
3986 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
3987 return False;
3989 return True;
3992 /*******************************************************************
3993 reads or writes a structure.
3994 ********************************************************************/
3996 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
3997 prs_struct *ps, int depth)
3999 if (r_u == NULL)
4000 return False;
4002 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4003 depth++;
4005 if(!prs_align(ps))
4006 return False;
4008 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4009 return False;
4011 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4012 return False;
4014 return True;
4017 /*******************************************************************
4018 inits a SAMR_Q_LOOKUP_RIDS structure.
4019 ********************************************************************/
4021 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4022 POLICY_HND *pol, uint32 flags,
4023 uint32 num_rids, uint32 *rid)
4025 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4027 q_u->pol = *pol;
4029 q_u->num_rids1 = num_rids;
4030 q_u->flags = flags;
4031 q_u->ptr = 0;
4032 q_u->num_rids2 = num_rids;
4033 q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0]));
4034 if (q_u->rid == NULL) {
4035 q_u->num_rids1 = 0;
4036 q_u->num_rids2 = 0;
4037 } else {
4038 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4042 /*******************************************************************
4043 reads or writes a structure.
4044 ********************************************************************/
4046 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4047 prs_struct *ps, int depth)
4049 uint32 i;
4050 fstring tmp;
4052 if (q_u == NULL)
4053 return False;
4055 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4056 depth++;
4058 if (UNMARSHALLING(ps))
4059 ZERO_STRUCTP(q_u);
4061 if(!prs_align(ps))
4062 return False;
4064 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4065 return False;
4067 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4068 return False;
4069 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4070 return False;
4071 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4072 return False;
4073 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4074 return False;
4076 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4077 q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2);
4078 if (q_u->rid == NULL)
4079 return False;
4082 for (i = 0; i < q_u->num_rids2; i++) {
4083 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4084 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4085 return False;
4088 return True;
4091 /*******************************************************************
4092 inits a SAMR_R_LOOKUP_RIDS structure.
4093 ********************************************************************/
4095 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4096 uint32 num_names, UNIHDR * hdr_name,
4097 UNISTR2 *uni_name, uint32 *type)
4099 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4101 r_u->hdr_name = NULL;
4102 r_u->uni_name = NULL;
4103 r_u->type = NULL;
4105 if (num_names != 0) {
4106 r_u->num_names1 = num_names;
4107 r_u->ptr_names = 1;
4108 r_u->num_names2 = num_names;
4110 r_u->num_types1 = num_names;
4111 r_u->ptr_types = 1;
4112 r_u->num_types2 = num_names;
4114 r_u->hdr_name = hdr_name;
4115 r_u->uni_name = uni_name;
4116 r_u->type = type;
4117 } else {
4118 r_u->num_names1 = num_names;
4119 r_u->ptr_names = 0;
4120 r_u->num_names2 = num_names;
4122 r_u->num_types1 = num_names;
4123 r_u->ptr_types = 0;
4124 r_u->num_types2 = num_names;
4128 /*******************************************************************
4129 reads or writes a structure.
4130 ********************************************************************/
4132 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4133 prs_struct *ps, int depth)
4135 uint32 i;
4136 fstring tmp;
4137 if (r_u == NULL)
4138 return False;
4140 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4141 depth++;
4143 if(!prs_align(ps))
4144 return False;
4146 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4147 return False;
4148 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4149 return False;
4151 if (r_u->ptr_names != 0) {
4153 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4154 return False;
4157 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4158 r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0]));
4159 if (r_u->hdr_name == NULL)
4160 return False;
4162 r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0]));
4163 if (r_u->uni_name == NULL)
4164 return False;
4167 for (i = 0; i < r_u->num_names2; i++) {
4168 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4169 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4170 return False;
4172 for (i = 0; i < r_u->num_names2; i++) {
4173 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4174 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4175 return False;
4180 if(!prs_align(ps))
4181 return False;
4182 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4183 return False;
4184 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4185 return False;
4187 if (r_u->ptr_types != 0) {
4189 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4190 return False;
4192 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4193 r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0]));
4194 if (r_u->type == NULL)
4195 return False;
4198 for (i = 0; i < r_u->num_types2; i++) {
4199 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4200 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4201 return False;
4205 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4206 return False;
4208 return True;
4211 /*******************************************************************
4212 inits a SAMR_Q_OPEN_ALIAS structure.
4213 ********************************************************************/
4215 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4217 DEBUG(5, ("init_samr_q_delete_alias\n"));
4219 q_u->alias_pol = *hnd;
4222 /*******************************************************************
4223 reads or writes a structure.
4224 ********************************************************************/
4226 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4227 prs_struct *ps, int depth)
4229 if (q_u == NULL)
4230 return False;
4232 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4233 depth++;
4235 if(!prs_align(ps))
4236 return False;
4238 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4239 return False;
4241 return True;
4244 /*******************************************************************
4245 reads or writes a structure.
4246 ********************************************************************/
4248 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4249 prs_struct *ps, int depth)
4251 if (r_u == NULL)
4252 return False;
4254 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4255 depth++;
4257 if(!prs_align(ps))
4258 return False;
4260 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4261 return False;
4262 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4263 return False;
4265 return True;
4268 /*******************************************************************
4269 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4270 ********************************************************************/
4272 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4273 POLICY_HND *hnd, char *acct_desc)
4275 int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
4277 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4279 q_u->dom_pol = *hnd;
4281 init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
4282 init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
4284 q_u->access_mask = 0x001f000f;
4287 /*******************************************************************
4288 reads or writes a structure.
4289 ********************************************************************/
4291 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4292 prs_struct *ps, int depth)
4294 if (q_u == NULL)
4295 return False;
4297 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4298 depth++;
4300 if(!prs_align(ps))
4301 return False;
4303 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4304 return False;
4306 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4307 return False;
4308 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4309 q_u->hdr_acct_desc.buffer, ps, depth))
4310 return False;
4312 if(!prs_align(ps))
4313 return False;
4314 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4315 return False;
4317 return True;
4320 /*******************************************************************
4321 reads or writes a structure.
4322 ********************************************************************/
4324 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4325 prs_struct *ps, int depth)
4327 if (r_u == NULL)
4328 return False;
4330 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4331 depth++;
4333 if(!prs_align(ps))
4334 return False;
4336 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4337 return False;
4339 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4340 return False;
4342 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4343 return False;
4345 return True;
4348 /*******************************************************************
4349 inits a SAMR_Q_ADD_ALIASMEM structure.
4350 ********************************************************************/
4352 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4353 DOM_SID *sid)
4355 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4357 q_u->alias_pol = *hnd;
4358 init_dom_sid2(&q_u->sid, sid);
4361 /*******************************************************************
4362 reads or writes a structure.
4363 ********************************************************************/
4365 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4366 prs_struct *ps, int depth)
4368 if (q_u == NULL)
4369 return False;
4371 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4372 depth++;
4374 if(!prs_align(ps))
4375 return False;
4377 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4378 return False;
4379 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4380 return False;
4382 return True;
4385 /*******************************************************************
4386 reads or writes a structure.
4387 ********************************************************************/
4389 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4390 prs_struct *ps, int depth)
4392 if (r_u == NULL)
4393 return False;
4395 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4396 depth++;
4398 if(!prs_align(ps))
4399 return False;
4401 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4402 return False;
4404 return True;
4407 /*******************************************************************
4408 inits a SAMR_Q_DEL_ALIASMEM structure.
4409 ********************************************************************/
4411 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4412 DOM_SID *sid)
4414 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4416 q_u->alias_pol = *hnd;
4417 init_dom_sid2(&q_u->sid, sid);
4420 /*******************************************************************
4421 reads or writes a structure.
4422 ********************************************************************/
4424 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4425 prs_struct *ps, int depth)
4427 if (q_u == NULL)
4428 return False;
4430 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4431 depth++;
4433 if(!prs_align(ps))
4434 return False;
4436 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4437 return False;
4438 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4439 return False;
4441 return True;
4444 /*******************************************************************
4445 reads or writes a structure.
4446 ********************************************************************/
4448 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4449 prs_struct *ps, int depth)
4451 if (r_u == NULL)
4452 return False;
4454 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4455 depth++;
4457 if(!prs_align(ps))
4458 return False;
4460 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4461 return False;
4463 return True;
4466 /*******************************************************************
4467 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4468 ********************************************************************/
4470 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4471 POLICY_HND *hnd)
4473 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4475 q_c->alias_pol = *hnd;
4478 /*******************************************************************
4479 reads or writes a structure.
4480 ********************************************************************/
4482 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4483 prs_struct *ps, int depth)
4485 if (q_u == NULL)
4486 return False;
4488 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4489 depth++;
4491 if(!prs_align(ps))
4492 return False;
4494 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4495 return False;
4497 return True;
4500 /*******************************************************************
4501 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4502 ********************************************************************/
4504 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4505 NTSTATUS status)
4507 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4509 r_u->status = status;
4512 /*******************************************************************
4513 reads or writes a structure.
4514 ********************************************************************/
4516 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4517 prs_struct *ps, int depth)
4519 if (r_u == NULL)
4520 return False;
4522 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4523 depth++;
4525 if(!prs_align(ps))
4526 return False;
4528 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4529 return False;
4531 return True;
4534 /*******************************************************************
4535 inits a SAMR_Q_QUERY_ALIASMEM structure.
4536 ********************************************************************/
4538 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4539 POLICY_HND *hnd)
4541 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4543 q_c->alias_pol = *hnd;
4546 /*******************************************************************
4547 reads or writes a structure.
4548 ********************************************************************/
4550 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4551 prs_struct *ps, int depth)
4553 if (q_u == NULL)
4554 return False;
4556 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4557 depth++;
4559 if(!prs_align(ps))
4560 return False;
4562 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4563 return False;
4565 return True;
4568 /*******************************************************************
4569 inits a SAMR_R_QUERY_ALIASMEM structure.
4570 ********************************************************************/
4572 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4573 uint32 num_sids, DOM_SID2 * sid,
4574 NTSTATUS status)
4576 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4578 if (NT_STATUS_IS_OK(status)) {
4579 r_u->num_sids = num_sids;
4580 r_u->ptr = (num_sids != 0) ? 1 : 0;
4581 r_u->num_sids1 = num_sids;
4583 r_u->sid = sid;
4584 } else {
4585 r_u->ptr = 0;
4586 r_u->num_sids = 0;
4589 r_u->status = status;
4592 /*******************************************************************
4593 reads or writes a structure.
4594 ********************************************************************/
4596 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4597 prs_struct *ps, int depth)
4599 uint32 i;
4601 if (r_u == NULL)
4602 return False;
4604 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4605 depth++;
4607 if(!prs_align(ps))
4608 return False;
4610 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4611 return False;
4612 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4613 return False;
4615 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4616 uint32 *ptr_sid = NULL;
4618 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4619 return False;
4621 ptr_sid = talloc(ps->mem_ctx, sizeof(uint32) * r_u->num_sids1);
4622 if (!ptr_sid) {
4623 return False;
4626 for (i = 0; i < r_u->num_sids1; i++) {
4627 ptr_sid[i] = 1;
4628 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4629 return False;
4632 if (UNMARSHALLING(ps)) {
4633 r_u->sid = talloc(ps->mem_ctx, r_u->num_sids1 * sizeof(DOM_SID2));
4636 for (i = 0; i < r_u->num_sids1; i++) {
4637 if (ptr_sid[i] != 0) {
4638 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4639 return False;
4644 if(!prs_align(ps))
4645 return False;
4646 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4647 return False;
4649 return True;
4652 /*******************************************************************
4653 inits a SAMR_Q_LOOKUP_NAMES structure.
4654 ********************************************************************/
4656 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4657 POLICY_HND *pol, uint32 flags,
4658 uint32 num_names, const char **name)
4660 uint32 i;
4662 DEBUG(5, ("init_samr_q_lookup_names\n"));
4664 q_u->pol = *pol;
4666 q_u->num_names1 = num_names;
4667 q_u->flags = flags;
4668 q_u->ptr = 0;
4669 q_u->num_names2 = num_names;
4671 if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR))))
4672 return NT_STATUS_NO_MEMORY;
4674 if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2))))
4675 return NT_STATUS_NO_MEMORY;
4677 for (i = 0; i < num_names; i++) {
4678 int len_name = name[i] != NULL ? strlen(name[i]) : 0;
4679 init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
4680 init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
4683 return NT_STATUS_OK;
4686 /*******************************************************************
4687 reads or writes a structure.
4688 ********************************************************************/
4690 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4691 prs_struct *ps, int depth)
4693 uint32 i;
4695 if (q_u == NULL)
4696 return False;
4698 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4699 depth++;
4701 if (UNMARSHALLING(ps))
4702 ZERO_STRUCTP(q_u);
4704 if(!prs_align(ps))
4705 return False;
4707 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4708 return False;
4710 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4711 return False;
4712 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4713 return False;
4714 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4715 return False;
4716 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4717 return False;
4719 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4720 q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) *
4721 q_u->num_names2);
4722 q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
4723 q_u->num_names2);
4724 if (!q_u->hdr_name || !q_u->uni_name)
4725 return False;
4728 for (i = 0; i < q_u->num_names2; i++) {
4729 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4730 return False;
4733 for (i = 0; i < q_u->num_names2; i++) {
4734 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4735 return False;
4738 return True;
4741 /*******************************************************************
4742 inits a SAMR_R_LOOKUP_NAMES structure.
4743 ********************************************************************/
4745 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4746 uint32 num_rids,
4747 uint32 *rid, uint32 *type,
4748 NTSTATUS status)
4750 DEBUG(5, ("init_samr_r_lookup_names\n"));
4752 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4753 uint32 i;
4755 r_u->num_types1 = num_rids;
4756 r_u->ptr_types = 1;
4757 r_u->num_types2 = num_rids;
4759 r_u->num_rids1 = num_rids;
4760 r_u->ptr_rids = 1;
4761 r_u->num_rids2 = num_rids;
4763 if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4764 return NT_STATUS_NO_MEMORY;
4765 if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids)))
4766 return NT_STATUS_NO_MEMORY;
4768 if (!r_u->rids || !r_u->types)
4769 goto empty;
4771 for (i = 0; i < num_rids; i++) {
4772 r_u->rids[i] = rid[i];
4773 r_u->types[i] = type[i];
4775 } else {
4777 empty:
4778 r_u->num_types1 = 0;
4779 r_u->ptr_types = 0;
4780 r_u->num_types2 = 0;
4782 r_u->num_rids1 = 0;
4783 r_u->ptr_rids = 0;
4784 r_u->num_rids2 = 0;
4786 r_u->rids = NULL;
4787 r_u->types = NULL;
4790 r_u->status = status;
4792 return NT_STATUS_OK;
4795 /*******************************************************************
4796 reads or writes a structure.
4797 ********************************************************************/
4799 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4800 prs_struct *ps, int depth)
4802 uint32 i;
4803 fstring tmp;
4805 if (r_u == NULL)
4806 return False;
4808 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4809 depth++;
4811 if (UNMARSHALLING(ps))
4812 ZERO_STRUCTP(r_u);
4814 if(!prs_align(ps))
4815 return False;
4817 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4818 return False;
4819 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4820 return False;
4822 if (r_u->ptr_rids != 0) {
4823 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4824 return False;
4826 if (r_u->num_rids2 != r_u->num_rids1) {
4827 /* RPC fault */
4828 return False;
4831 if (UNMARSHALLING(ps))
4832 r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2);
4834 if (!r_u->rids) {
4835 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4836 return False;
4839 for (i = 0; i < r_u->num_rids2; i++) {
4840 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4841 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4842 return False;
4846 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4847 return False;
4848 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4849 return False;
4851 if (r_u->ptr_types != 0) {
4852 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4853 return False;
4855 if (r_u->num_types2 != r_u->num_types1) {
4856 /* RPC fault */
4857 return False;
4860 if (UNMARSHALLING(ps))
4861 r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2);
4863 if (!r_u->types) {
4864 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4865 return False;
4868 for (i = 0; i < r_u->num_types2; i++) {
4869 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4870 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4871 return False;
4875 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4876 return False;
4878 return True;
4881 /*******************************************************************
4882 inits a SAMR_Q_DELETE_DOM_USER structure.
4883 ********************************************************************/
4885 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4886 POLICY_HND *hnd)
4888 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4890 q_c->user_pol = *hnd;
4893 /*******************************************************************
4894 reads or writes a structure.
4895 ********************************************************************/
4897 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4898 prs_struct *ps, int depth)
4900 if (q_u == NULL)
4901 return False;
4903 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4904 depth++;
4906 if(!prs_align(ps))
4907 return False;
4909 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4910 return False;
4912 return True;
4915 /*******************************************************************
4916 reads or writes a structure.
4917 ********************************************************************/
4919 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4920 prs_struct *ps, int depth)
4922 if (r_u == NULL)
4923 return False;
4925 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4926 depth++;
4928 if(!prs_align(ps))
4929 return False;
4931 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4932 return False;
4933 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4934 return False;
4936 return True;
4939 /*******************************************************************
4940 reads or writes a structure.
4941 ********************************************************************/
4943 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4944 POLICY_HND *pol,
4945 uint32 access_mask, uint32 rid)
4947 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4949 q_u->domain_pol = *pol;
4950 q_u->access_mask = access_mask;
4951 q_u->user_rid = rid;
4954 /*******************************************************************
4955 reads or writes a structure.
4956 ********************************************************************/
4958 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
4959 prs_struct *ps, int depth)
4961 if (q_u == NULL)
4962 return False;
4964 prs_debug(ps, depth, desc, "samr_io_q_open_user");
4965 depth++;
4967 if(!prs_align(ps))
4968 return False;
4970 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
4971 return False;
4973 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4974 return False;
4975 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
4976 return False;
4978 return True;
4981 /*******************************************************************
4982 reads or writes a structure.
4983 ********************************************************************/
4985 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
4986 prs_struct *ps, int depth)
4988 if (r_u == NULL)
4989 return False;
4991 prs_debug(ps, depth, desc, "samr_io_r_open_user");
4992 depth++;
4994 if(!prs_align(ps))
4995 return False;
4997 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
4998 return False;
5000 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5001 return False;
5003 return True;
5007 /*******************************************************************
5008 reads or writes a structure.
5009 ********************************************************************/
5011 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5012 POLICY_HND *pol,
5013 const char *name,
5014 uint32 acb_info, uint32 access_mask)
5016 int len_name;
5017 len_name = strlen(name);
5019 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5021 q_u->domain_pol = *pol;
5023 init_uni_hdr(&q_u->hdr_name, len_name);
5024 init_unistr2(&q_u->uni_name, name, len_name);
5026 q_u->acb_info = acb_info;
5027 q_u->access_mask = access_mask;
5030 /*******************************************************************
5031 reads or writes a structure.
5032 ********************************************************************/
5034 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5035 prs_struct *ps, int depth)
5037 if (q_u == NULL)
5038 return False;
5040 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5041 depth++;
5043 if(!prs_align(ps))
5044 return False;
5046 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5047 return False;
5049 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5050 return False;
5051 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5052 return False;
5054 if(!prs_align(ps))
5055 return False;
5056 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5057 return False;
5058 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5059 return False;
5061 return True;
5064 /*******************************************************************
5065 reads or writes a structure.
5066 ********************************************************************/
5068 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5069 prs_struct *ps, int depth)
5071 if (r_u == NULL)
5072 return False;
5074 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5075 depth++;
5077 if(!prs_align(ps))
5078 return False;
5080 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5081 return False;
5083 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5084 return False;
5085 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5086 return False;
5087 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5088 return False;
5090 return True;
5093 /*******************************************************************
5094 inits a SAMR_Q_QUERY_USERINFO structure.
5095 ********************************************************************/
5097 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5098 POLICY_HND *hnd, uint16 switch_value)
5100 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5102 q_u->pol = *hnd;
5103 q_u->switch_value = switch_value;
5106 /*******************************************************************
5107 reads or writes a structure.
5108 ********************************************************************/
5110 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5111 prs_struct *ps, int depth)
5113 if (q_u == NULL)
5114 return False;
5116 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5117 depth++;
5119 if(!prs_align(ps))
5120 return False;
5122 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5123 return False;
5125 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5126 return False;
5128 return True;
5131 /*******************************************************************
5132 reads or writes a LOGON_HRS structure.
5133 ********************************************************************/
5135 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5136 prs_struct *ps, int depth)
5138 if (hrs == NULL)
5139 return False;
5141 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5142 depth++;
5144 if(!prs_align(ps))
5145 return False;
5147 if(!prs_uint32("len ", ps, depth, &hrs->len))
5148 return False;
5150 if (hrs->len > sizeof(hrs->hours)) {
5151 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5152 hrs->len = sizeof(hrs->hours);
5155 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5156 return False;
5158 return True;
5161 /*******************************************************************
5162 inits a SAM_USER_INFO_12 structure.
5163 ********************************************************************/
5165 void init_sam_user_info12(SAM_USER_INFO_12 * usr,
5166 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5168 DEBUG(5, ("init_sam_user_info12\n"));
5170 usr->lm_pwd_active =
5171 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5172 usr->nt_pwd_active =
5173 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5176 /*******************************************************************
5177 reads or writes a structure.
5178 ********************************************************************/
5180 static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u,
5181 prs_struct *ps, int depth)
5183 if (u == NULL)
5184 return False;
5186 prs_debug(ps, depth, desc, "samr_io_r_user_info12");
5187 depth++;
5189 if(!prs_align(ps))
5190 return False;
5192 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5193 return False;
5194 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5195 return False;
5197 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5198 return False;
5199 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5200 return False;
5202 return True;
5205 /*******************************************************************
5206 inits a SAM_USER_INFO_10 structure.
5207 ********************************************************************/
5209 void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info)
5211 DEBUG(5, ("init_sam_user_info10\n"));
5213 usr->acb_info = acb_info;
5216 /*******************************************************************
5217 reads or writes a structure.
5218 ********************************************************************/
5220 static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr,
5221 prs_struct *ps, int depth)
5223 if (usr == NULL)
5224 return False;
5226 prs_debug(ps, depth, desc, "samr_io_r_user_info10");
5227 depth++;
5229 if(!prs_align(ps))
5230 return False;
5232 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5233 return False;
5235 return True;
5238 /*******************************************************************
5239 inits a SAM_USER_INFO_11 structure.
5240 ********************************************************************/
5242 void init_sam_user_info11(SAM_USER_INFO_11 * usr,
5243 NTTIME * expiry,
5244 char *mach_acct,
5245 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5247 int len_mach_acct;
5249 DEBUG(5, ("init_sam_user_info11\n"));
5251 len_mach_acct = strlen(mach_acct);
5253 memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
5254 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5256 init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
5257 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5259 usr->ptr_1 = 1; /* pointer */
5260 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5261 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5263 usr->ptr_2 = 1; /* pointer */
5264 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5266 usr->ptr_3 = 1; /* pointer */
5267 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5269 usr->rid_user = rid_user;
5270 usr->rid_group = rid_group;
5272 usr->acct_ctrl = acct_ctrl;
5273 usr->unknown_3 = 0x0000;
5275 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5276 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5278 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5279 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5281 init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
5284 /*******************************************************************
5285 reads or writes a structure.
5286 ********************************************************************/
5288 static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr,
5289 prs_struct *ps, int depth)
5291 if (usr == NULL)
5292 return False;
5294 prs_debug(ps, depth, desc, "samr_io_r_unknown_11");
5295 depth++;
5297 if(!prs_align(ps))
5298 return False;
5300 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5301 return False;
5303 if(!smb_io_time("time", &usr->expiry, ps, depth))
5304 return False;
5306 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5307 return False;
5309 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5310 return False;
5312 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5313 return False;
5315 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5316 return False;
5317 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5318 return False;
5320 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5321 return False;
5323 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5324 return False;
5325 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5326 return False;
5328 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5329 return False;
5330 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5331 return False;
5333 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5334 return False;
5335 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5336 return False;
5337 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5338 return False;
5339 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5340 return False;
5341 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5342 return False;
5343 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5344 return False;
5346 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5347 return False;
5349 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5350 return False;
5352 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5353 return False;
5355 if(!prs_align(ps))
5356 return False;
5358 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5359 return False;
5361 return True;
5364 /*************************************************************************
5365 init_sam_user_infoa
5367 unknown_3 = 0x09f8 27fa
5368 unknown_5 = 0x0001 0000
5369 unknown_6 = 0x0000 04ec
5371 *************************************************************************/
5373 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5375 DEBUG(10, ("init_sam_user_info24:\n"));
5376 memcpy(usr->pass, newpass, sizeof(usr->pass));
5377 usr->pw_len = pw_len;
5380 /*******************************************************************
5381 reads or writes a structure.
5382 ********************************************************************/
5384 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5385 prs_struct *ps, int depth)
5387 if (usr == NULL)
5388 return False;
5390 prs_debug(ps, depth, desc, "sam_io_user_info24");
5391 depth++;
5393 if(!prs_align(ps))
5394 return False;
5396 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5397 sizeof(usr->pass)))
5398 return False;
5400 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5401 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5402 return False;
5404 if(!prs_align(ps))
5405 return False;
5407 return True;
5410 /*************************************************************************
5411 init_sam_user_info23
5413 unknown_3 = 0x09f8 27fa
5414 unknown_5 = 0x0001 0000
5415 unknown_6 = 0x0000 04ec
5417 *************************************************************************/
5419 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5420 NTTIME * logoff_time, /* all zeros */
5421 NTTIME * kickoff_time, /* all zeros */
5422 NTTIME * pass_last_set_time, /* all zeros */
5423 NTTIME * pass_can_change_time, /* all zeros */
5424 NTTIME * pass_must_change_time, /* all zeros */
5425 UNISTR2 *user_name,
5426 UNISTR2 *full_name,
5427 UNISTR2 *home_dir,
5428 UNISTR2 *dir_drive,
5429 UNISTR2 *log_scr,
5430 UNISTR2 *prof_path,
5431 UNISTR2 *desc,
5432 UNISTR2 *wkstas,
5433 UNISTR2 *unk_str,
5434 UNISTR2 *mung_dial,
5435 uint32 user_rid, /* 0x0000 0000 */
5436 uint32 group_rid,
5437 uint32 acb_info,
5438 uint32 unknown_3,
5439 uint16 logon_divs,
5440 LOGON_HRS * hrs,
5441 uint32 unknown_5,
5442 char newpass[516], uint32 unknown_6)
5444 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5445 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5446 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5447 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5448 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5449 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5450 int len_description = desc != NULL ? desc->uni_str_len : 0;
5451 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5452 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5453 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5455 usr->logon_time = *logon_time; /* all zeros */
5456 usr->logoff_time = *logoff_time; /* all zeros */
5457 usr->kickoff_time = *kickoff_time; /* all zeros */
5458 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5459 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5460 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5462 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5463 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5464 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5465 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5466 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5467 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5468 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5469 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5470 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5471 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5473 ZERO_STRUCT(usr->nt_pwd);
5474 ZERO_STRUCT(usr->lm_pwd);
5476 usr->user_rid = user_rid; /* 0x0000 0000 */
5477 usr->group_rid = group_rid;
5478 usr->acb_info = acb_info;
5479 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5481 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5482 usr->ptr_logon_hrs = hrs ? 1 : 0;
5484 if (nt_time_is_zero(pass_must_change_time)) {
5485 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5486 } else {
5487 usr->passmustchange=0;
5491 ZERO_STRUCT(usr->padding1);
5492 ZERO_STRUCT(usr->padding2);
5494 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5496 memcpy(usr->pass, newpass, sizeof(usr->pass));
5498 copy_unistr2(&usr->uni_user_name, user_name);
5499 copy_unistr2(&usr->uni_full_name, full_name);
5500 copy_unistr2(&usr->uni_home_dir, home_dir);
5501 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5502 copy_unistr2(&usr->uni_logon_script, log_scr);
5503 copy_unistr2(&usr->uni_profile_path, prof_path);
5504 copy_unistr2(&usr->uni_acct_desc, desc);
5505 copy_unistr2(&usr->uni_workstations, wkstas);
5506 copy_unistr2(&usr->uni_unknown_str, unk_str);
5507 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5509 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5510 usr->padding4 = 0;
5512 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5515 /*************************************************************************
5516 init_sam_user_info23
5518 unknown_3 = 0x09f8 27fa
5519 unknown_5 = 0x0001 0000
5520 unknown_6 = 0x0000 04ec
5522 *************************************************************************/
5524 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5525 NTTIME * logoff_time, /* all zeros */
5526 NTTIME * kickoff_time, /* all zeros */
5527 NTTIME * pass_last_set_time, /* all zeros */
5528 NTTIME * pass_can_change_time, /* all zeros */
5529 NTTIME * pass_must_change_time, /* all zeros */
5530 char *user_name, /* NULL */
5531 char *full_name,
5532 char *home_dir, char *dir_drive, char *log_scr,
5533 char *prof_path, const char *desc, char *wkstas,
5534 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5535 uint32 group_rid, uint32 acb_info,
5536 uint32 unknown_3, uint16 logon_divs,
5537 LOGON_HRS * hrs, uint32 unknown_5,
5538 char newpass[516], uint32 unknown_6)
5540 int len_user_name = user_name != NULL ? strlen(user_name) : 0;
5541 int len_full_name = full_name != NULL ? strlen(full_name) : 0;
5542 int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
5543 int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
5544 int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
5545 int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
5546 int len_description = desc != NULL ? strlen(desc) : 0;
5547 int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
5548 int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
5549 int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
5551 usr->logon_time = *logon_time; /* all zeros */
5552 usr->logoff_time = *logoff_time; /* all zeros */
5553 usr->kickoff_time = *kickoff_time; /* all zeros */
5554 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5555 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5556 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5558 init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
5559 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5560 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5561 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5562 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5563 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5564 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5565 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5566 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5567 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5569 ZERO_STRUCT(usr->nt_pwd);
5570 ZERO_STRUCT(usr->lm_pwd);
5572 usr->user_rid = user_rid; /* 0x0000 0000 */
5573 usr->group_rid = group_rid;
5574 usr->acb_info = acb_info;
5575 usr->unknown_3 = unknown_3; /* 09f8 27fa */
5577 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5578 usr->ptr_logon_hrs = hrs ? 1 : 0;
5580 if (nt_time_is_zero(pass_must_change_time)) {
5581 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5582 } else {
5583 usr->passmustchange=0;
5586 ZERO_STRUCT(usr->padding1);
5587 ZERO_STRUCT(usr->padding2);
5589 usr->unknown_5 = unknown_5; /* 0x0001 0000 */
5591 memcpy(usr->pass, newpass, sizeof(usr->pass));
5593 init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
5594 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
5595 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
5596 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
5597 init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
5598 init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
5599 init_unistr2(&usr->uni_acct_desc, desc, len_description);
5600 init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
5601 init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
5602 init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
5604 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5605 usr->padding4 = 0;
5607 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5610 /*******************************************************************
5611 reads or writes a structure.
5612 ********************************************************************/
5614 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5615 prs_struct *ps, int depth)
5617 if (usr == NULL)
5618 return False;
5620 prs_debug(ps, depth, desc, "sam_io_user_info23");
5621 depth++;
5623 if(!prs_align(ps))
5624 return False;
5626 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5627 return False;
5628 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5629 return False;
5630 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5631 return False;
5632 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5633 return False;
5634 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5635 return False;
5636 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5637 return False;
5639 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5640 return False;
5641 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5642 return False;
5643 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5644 return False;
5645 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5646 return False;
5647 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5648 return False;
5649 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5650 return False;
5651 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5652 return False;
5653 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5654 return False;
5655 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5656 return False;
5657 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5658 return False;
5660 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5661 return False;
5662 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5663 return False;
5665 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5666 return False;
5667 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5668 return False;
5669 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5670 return False;
5672 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
5673 return False;
5674 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5675 return False;
5676 if(!prs_align(ps))
5677 return False;
5678 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5679 return False;
5681 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
5682 return False;
5684 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5685 return False;
5686 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5687 return False;
5688 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5689 return False;
5692 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5693 return False;
5695 /* here begins pointed-to data */
5697 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5698 return False;
5700 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5701 return False;
5703 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5704 return False;
5706 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5707 return False;
5709 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5710 return False;
5712 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5713 return False;
5715 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5716 return False;
5718 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5719 return False;
5721 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5722 return False;
5724 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5725 return False;
5727 /* ok, this is only guess-work (as usual) */
5728 if (usr->ptr_logon_hrs) {
5729 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5730 return False;
5731 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5732 return False;
5733 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5734 return False;
5735 } else if (UNMARSHALLING(ps)) {
5736 usr->unknown_6 = 0;
5737 usr->padding4 = 0;
5740 return True;
5743 /*******************************************************************
5744 reads or writes a structure.
5745 NB. This structure is *definately* incorrect. It's my best guess
5746 currently for W2K SP2. The password field is encrypted in a different
5747 way than normal... And there are definately other problems. JRA.
5748 ********************************************************************/
5750 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5752 if (usr == NULL)
5753 return False;
5755 prs_debug(ps, depth, desc, "sam_io_user_info25");
5756 depth++;
5758 if(!prs_align(ps))
5759 return False;
5761 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5762 return False;
5763 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5764 return False;
5765 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5766 return False;
5767 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5768 return False;
5769 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5770 return False;
5771 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5772 return False;
5774 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5775 return False;
5776 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5777 return False;
5778 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5779 return False;
5780 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5781 return False;
5782 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5783 return False;
5784 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5785 return False;
5786 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5787 return False;
5788 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5789 return False;
5790 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5791 return False;
5792 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5793 return False;
5795 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5796 return False;
5797 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5798 return False;
5800 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5801 return False;
5802 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5803 return False;
5804 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5805 return False;
5807 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5808 return False;
5810 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5811 return False;
5813 /* here begins pointed-to data */
5815 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5816 return False;
5818 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5819 return False;
5821 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5822 return False;
5824 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5825 return False;
5827 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5828 return False;
5830 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5831 return False;
5833 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5834 return False;
5836 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5837 return False;
5839 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5840 return False;
5842 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5843 return False;
5845 #if 0 /* JRA - unknown... */
5846 /* ok, this is only guess-work (as usual) */
5847 if (usr->ptr_logon_hrs) {
5848 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
5849 return False;
5850 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
5851 return False;
5852 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5853 return False;
5854 } else if (UNMARSHALLING(ps)) {
5855 usr->unknown_6 = 0;
5856 usr->padding4 = 0;
5858 #endif
5860 return True;
5864 /*************************************************************************
5865 init_sam_user_info21W
5867 unknown_3 = 0x00ff ffff
5868 unknown_5 = 0x0002 0000
5869 unknown_6 = 0x0000 04ec
5871 *************************************************************************/
5873 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5874 NTTIME * logon_time,
5875 NTTIME * logoff_time,
5876 NTTIME * kickoff_time,
5877 NTTIME * pass_last_set_time,
5878 NTTIME * pass_can_change_time,
5879 NTTIME * pass_must_change_time,
5880 UNISTR2 *user_name,
5881 UNISTR2 *full_name,
5882 UNISTR2 *home_dir,
5883 UNISTR2 *dir_drive,
5884 UNISTR2 *log_scr,
5885 UNISTR2 *prof_path,
5886 UNISTR2 *desc,
5887 UNISTR2 *wkstas,
5888 UNISTR2 *unk_str,
5889 UNISTR2 *mung_dial,
5890 uchar lm_pwd[16],
5891 uchar nt_pwd[16],
5892 uint32 user_rid,
5893 uint32 group_rid,
5894 uint32 acb_info,
5895 uint32 unknown_3,
5896 uint16 logon_divs,
5897 LOGON_HRS * hrs,
5898 uint32 unknown_5, uint32 unknown_6)
5900 int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
5901 int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
5902 int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
5903 int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
5904 int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
5905 int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
5906 int len_description = desc != NULL ? desc->uni_str_len : 0;
5907 int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
5908 int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
5909 int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
5911 usr->logon_time = *logon_time;
5912 usr->logoff_time = *logoff_time;
5913 usr->kickoff_time = *kickoff_time;
5914 usr->pass_last_set_time = *pass_last_set_time;
5915 usr->pass_can_change_time = *pass_can_change_time;
5916 usr->pass_must_change_time = *pass_must_change_time;
5918 init_uni_hdr(&usr->hdr_user_name, len_user_name);
5919 init_uni_hdr(&usr->hdr_full_name, len_full_name);
5920 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
5921 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
5922 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
5923 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
5924 init_uni_hdr(&usr->hdr_acct_desc, len_description);
5925 init_uni_hdr(&usr->hdr_workstations, len_workstations);
5926 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
5927 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
5929 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
5930 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
5932 usr->user_rid = user_rid;
5933 usr->group_rid = group_rid;
5934 usr->acb_info = acb_info;
5935 usr->unknown_3 = unknown_3; /* 0x00ff ffff */
5937 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5938 usr->ptr_logon_hrs = hrs ? 1 : 0;
5939 usr->unknown_5 = unknown_5; /* 0x0002 0000 */
5941 if (nt_time_is_zero(pass_must_change_time)) {
5942 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5943 } else {
5944 usr->passmustchange=0;
5948 ZERO_STRUCT(usr->padding1);
5949 ZERO_STRUCT(usr->padding2);
5951 copy_unistr2(&usr->uni_user_name, user_name);
5952 copy_unistr2(&usr->uni_full_name, full_name);
5953 copy_unistr2(&usr->uni_home_dir, home_dir);
5954 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5955 copy_unistr2(&usr->uni_logon_script, log_scr);
5956 copy_unistr2(&usr->uni_profile_path, prof_path);
5957 copy_unistr2(&usr->uni_acct_desc, desc);
5958 copy_unistr2(&usr->uni_workstations, wkstas);
5959 copy_unistr2(&usr->uni_unknown_str, unk_str);
5960 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5962 usr->unknown_6 = unknown_6; /* 0x0000 04ec */
5963 usr->padding4 = 0;
5965 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5968 /*************************************************************************
5969 init_sam_user_info21
5971 unknown_3 = 0x00ff ffff
5972 unknown_5 = 0x0002 0000
5973 unknown_6 = 0x0000 04ec
5975 *************************************************************************/
5977 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid)
5979 NTTIME logon_time, logoff_time, kickoff_time,
5980 pass_last_set_time, pass_can_change_time,
5981 pass_must_change_time;
5983 int len_user_name, len_full_name, len_home_dir,
5984 len_dir_drive, len_logon_script, len_profile_path,
5985 len_description, len_workstations, len_unknown_str,
5986 len_munged_dial;
5988 const char* user_name = pdb_get_username(pw);
5989 const char* full_name = pdb_get_fullname(pw);
5990 const char* home_dir = pdb_get_homedir(pw);
5991 const char* dir_drive = pdb_get_dir_drive(pw);
5992 const char* logon_script = pdb_get_logon_script(pw);
5993 const char* profile_path = pdb_get_profile_path(pw);
5994 const char* description = pdb_get_acct_desc(pw);
5995 const char* workstations = pdb_get_workstations(pw);
5996 const char* munged_dial = pdb_get_munged_dial(pw);
5998 uint32 user_rid;
5999 const DOM_SID *user_sid;
6001 uint32 group_rid;
6002 const DOM_SID *group_sid;
6004 len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
6005 len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
6006 len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
6007 len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
6008 len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
6009 len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
6010 len_description = description != NULL ? strlen(description )+1 : 0;
6011 len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
6012 len_unknown_str = 0;
6013 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6016 /* Create NTTIME structs */
6017 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6018 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6019 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6020 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6021 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6022 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6024 /* structure assignment */
6025 usr->logon_time = logon_time;
6026 usr->logoff_time = logoff_time;
6027 usr->kickoff_time = kickoff_time;
6028 usr->pass_last_set_time = pass_last_set_time;
6029 usr->pass_can_change_time = pass_can_change_time;
6030 usr->pass_must_change_time = pass_must_change_time;
6032 init_uni_hdr(&usr->hdr_user_name, len_user_name);
6033 init_uni_hdr(&usr->hdr_full_name, len_full_name);
6034 init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
6035 init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
6036 init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
6037 init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
6038 init_uni_hdr(&usr->hdr_acct_desc, len_description);
6039 init_uni_hdr(&usr->hdr_workstations, len_workstations);
6040 init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
6041 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6043 ZERO_STRUCT(usr->nt_pwd);
6044 ZERO_STRUCT(usr->lm_pwd);
6046 user_sid = pdb_get_user_sid(pw);
6048 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6049 fstring user_sid_string;
6050 fstring domain_sid_string;
6051 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6052 "the domain sid %s. Failing operation.\n",
6053 user_name,
6054 sid_to_string(user_sid_string, user_sid),
6055 sid_to_string(domain_sid_string, domain_sid)));
6056 return NT_STATUS_UNSUCCESSFUL;
6059 group_sid = pdb_get_group_sid(pw);
6061 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6062 fstring group_sid_string;
6063 fstring domain_sid_string;
6064 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6065 "which conflicts with the domain sid %s. Failing operation.\n",
6066 user_name,
6067 sid_to_string(group_sid_string, group_sid),
6068 sid_to_string(domain_sid_string, domain_sid)));
6069 return NT_STATUS_UNSUCCESSFUL;
6072 usr->user_rid = user_rid;
6073 usr->group_rid = group_rid;
6074 usr->acb_info = pdb_get_acct_ctrl(pw);
6077 Look at a user on a real NT4 PDC with usrmgr, press
6078 'ok'. Then you will see that unknown_3 is set to
6079 0x08f827fa. Look at the user immediately after that again,
6080 and you will see that 0x00fffff is returned. This solves
6081 the problem that you get access denied after having looked
6082 at the user.
6083 -- Volker
6085 usr->unknown_3 = 0x00ffffff;
6087 usr->logon_divs = pdb_get_logon_divs(pw);
6088 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6089 usr->unknown_5 = pdb_get_unknown_5(pw); /* 0x0002 0000 */
6091 if (pdb_get_pass_must_change_time(pw) == 0) {
6092 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6093 } else {
6094 usr->passmustchange=0;
6098 ZERO_STRUCT(usr->padding1);
6099 ZERO_STRUCT(usr->padding2);
6101 init_unistr2(&usr->uni_user_name, user_name, len_user_name);
6102 init_unistr2(&usr->uni_full_name, full_name, len_full_name);
6103 init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
6104 init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
6105 init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
6106 init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
6107 init_unistr2(&usr->uni_acct_desc, description, len_description);
6108 init_unistr2(&usr->uni_workstations, workstations, len_workstations);
6109 init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
6110 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6112 usr->unknown_6 = pdb_get_unknown_6(pw);
6113 usr->padding4 = 0;
6115 if (pdb_get_hours(pw)) {
6116 usr->logon_hrs.len = pdb_get_hours_len(pw);
6117 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6118 } else
6119 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6121 return NT_STATUS_OK;
6124 /*******************************************************************
6125 reads or writes a structure.
6126 ********************************************************************/
6128 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6129 prs_struct *ps, int depth)
6131 if (usr == NULL)
6132 return False;
6134 prs_debug(ps, depth, desc, "sam_io_user_info21");
6135 depth++;
6137 if(!prs_align(ps))
6138 return False;
6140 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6141 return False;
6142 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6143 return False;
6144 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6145 return False;
6146 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6147 return False;
6148 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6149 return False;
6150 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6151 return False;
6153 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6154 return False;
6155 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6156 return False;
6157 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6158 return False;
6159 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6160 return False;
6161 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6162 return False;
6163 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6164 return False;
6165 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6166 return False;
6167 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6168 return False;
6169 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6170 return False;
6171 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6172 return False;
6174 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6175 return False;
6176 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6177 return False;
6179 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6180 return False;
6181 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6182 return False;
6183 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6184 return False;
6186 if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3))
6187 return False;
6188 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6189 return False;
6190 if(!prs_align(ps))
6191 return False;
6192 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6193 return False;
6195 if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
6196 return False;
6198 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6199 return False;
6200 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6201 return False;
6202 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6203 return False;
6205 /* here begins pointed-to data */
6207 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6208 return False;
6209 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6210 return False;
6211 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6212 return False;
6213 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6214 return False;
6215 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6216 return False;
6217 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6218 return False;
6219 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6220 return False;
6221 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6222 return False;
6223 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6224 return False;
6225 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6226 return False;
6228 /* ok, this is only guess-work (as usual) */
6229 if (usr->ptr_logon_hrs) {
6230 if(!prs_align(ps))
6231 return False;
6232 if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6))
6233 return False;
6234 if(!prs_uint32("padding4 ", ps, depth, &usr->padding4))
6235 return False;
6236 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6237 return False;
6238 } else if (UNMARSHALLING(ps)) {
6239 usr->unknown_6 = 0;
6240 usr->padding4 = 0;
6243 return True;
6246 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
6248 int len_munged_dial;
6249 const char* munged_dial = pdb_get_munged_dial(pw);
6251 len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
6252 init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
6253 init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
6257 /*******************************************************************
6258 reads or writes a structure.
6259 ********************************************************************/
6261 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6262 prs_struct *ps, int depth)
6264 if (usr == NULL)
6265 return False;
6267 prs_debug(ps, depth, desc, "sam_io_user_info20");
6268 depth++;
6270 if(!prs_align(ps))
6271 return False;
6273 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6274 return False;
6276 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6277 return False;
6279 return True;
6282 /*******************************************************************
6283 inits a SAM_USERINFO_CTR structure.
6284 ********************************************************************/
6286 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6287 uint16 switch_value,
6288 SAM_USER_INFO_21 * usr)
6290 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6292 ctr->switch_value = switch_value;
6293 ctr->info.id = NULL;
6295 switch (switch_value) {
6296 case 0x10:
6297 ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10));
6298 if (ctr->info.id10 == NULL)
6299 return NT_STATUS_NO_MEMORY;
6301 init_sam_user_info10(ctr->info.id10, usr->acb_info);
6302 break;
6303 #if 0
6304 /* whoops - got this wrong. i think. or don't understand what's happening. */
6305 case 0x11:
6307 NTTIME expire;
6308 info = (void *)&id11;
6310 expire.low = 0xffffffff;
6311 expire.high = 0x7fffffff;
6313 ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11));
6314 init_sam_user_info11(ctr->info.id11, &expire,
6315 "BROOKFIELDS$", /* name */
6316 0x03ef, /* user rid */
6317 0x201, /* group rid */
6318 0x0080); /* acb info */
6320 break;
6322 #endif
6323 case 0x12:
6324 ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12));
6325 if (ctr->info.id12 == NULL)
6326 return NT_STATUS_NO_MEMORY;
6328 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd);
6329 break;
6330 case 21:
6332 SAM_USER_INFO_21 *cusr;
6333 cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21));
6334 ctr->info.id21 = cusr;
6335 if (ctr->info.id21 == NULL)
6336 return NT_STATUS_NO_MEMORY;
6337 memcpy(cusr, usr, sizeof(*usr));
6338 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6339 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6340 break;
6342 default:
6343 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6344 return NT_STATUS_INVALID_INFO_CLASS;
6347 return NT_STATUS_OK;
6350 /*******************************************************************
6351 inits a SAM_USERINFO_CTR structure.
6352 ********************************************************************/
6354 void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key,
6355 uint16 switch_value, void *info)
6357 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6359 ctr->switch_value = switch_value;
6360 ctr->info.id = info;
6362 switch (switch_value) {
6363 case 0x18:
6364 SamOEMhash(ctr->info.id24->pass, sess_key, 516);
6365 dump_data(100, (char *)sess_key, 16);
6366 dump_data(100, (char *)ctr->info.id24->pass, 516);
6367 break;
6368 case 0x17:
6369 SamOEMhash(ctr->info.id23->pass, sess_key, 516);
6370 dump_data(100, (char *)sess_key, 16);
6371 dump_data(100, (char *)ctr->info.id23->pass, 516);
6372 break;
6373 default:
6374 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6378 /*******************************************************************
6379 reads or writes a structure.
6380 ********************************************************************/
6382 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6383 prs_struct *ps, int depth)
6385 BOOL ret;
6386 SAM_USERINFO_CTR *ctr;
6388 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6389 depth++;
6391 if (UNMARSHALLING(ps)) {
6392 ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR));
6393 if (ctr == NULL)
6394 return False;
6395 *ppctr = ctr;
6396 } else {
6397 ctr = *ppctr;
6400 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6402 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6403 return False;
6404 if(!prs_align(ps))
6405 return False;
6407 ret = False;
6409 switch (ctr->switch_value) {
6410 case 0x10:
6411 if (UNMARSHALLING(ps))
6412 ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10));
6413 if (ctr->info.id10 == NULL) {
6414 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6415 return False;
6417 ret = sam_io_user_info10("", ctr->info.id10, ps, depth);
6418 break;
6419 case 0x11:
6420 if (UNMARSHALLING(ps))
6421 ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11));
6423 if (ctr->info.id11 == NULL) {
6424 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6425 return False;
6427 ret = sam_io_user_info11("", ctr->info.id11, ps, depth);
6428 break;
6429 case 0x12:
6430 if (UNMARSHALLING(ps))
6431 ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12));
6433 if (ctr->info.id12 == NULL) {
6434 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6435 return False;
6437 ret = sam_io_user_info12("", ctr->info.id12, ps, depth);
6438 break;
6439 case 20:
6440 if (UNMARSHALLING(ps))
6441 ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20));
6443 if (ctr->info.id20 == NULL) {
6444 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6445 return False;
6447 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6448 break;
6449 case 21:
6450 if (UNMARSHALLING(ps))
6451 ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21));
6453 if (ctr->info.id21 == NULL) {
6454 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6455 return False;
6457 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6458 break;
6459 case 23:
6460 if (UNMARSHALLING(ps))
6461 ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23));
6463 if (ctr->info.id23 == NULL) {
6464 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6465 return False;
6467 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6468 break;
6469 case 24:
6470 if (UNMARSHALLING(ps))
6471 ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24));
6473 if (ctr->info.id24 == NULL) {
6474 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6475 return False;
6477 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6478 break;
6479 case 25:
6480 if (UNMARSHALLING(ps))
6481 ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25));
6483 if (ctr->info.id25 == NULL) {
6484 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6485 return False;
6487 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6488 break;
6489 default:
6490 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6491 ret = False;
6492 break;
6495 return ret;
6498 /*******************************************************************
6499 inits a SAMR_R_QUERY_USERINFO structure.
6500 ********************************************************************/
6502 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6503 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6505 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6507 r_u->ptr = 0;
6508 r_u->ctr = NULL;
6510 if (NT_STATUS_IS_OK(status)) {
6511 r_u->ptr = 1;
6512 r_u->ctr = ctr;
6515 r_u->status = status; /* return status */
6518 /*******************************************************************
6519 reads or writes a structure.
6520 ********************************************************************/
6522 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6523 prs_struct *ps, int depth)
6525 if (r_u == NULL)
6526 return False;
6528 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6529 depth++;
6531 if(!prs_align(ps))
6532 return False;
6534 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6535 return False;
6537 if (r_u->ptr != 0) {
6538 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6539 return False;
6542 if(!prs_align(ps))
6543 return False;
6544 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6545 return False;
6547 return True;
6550 /*******************************************************************
6551 inits a SAMR_Q_SET_USERINFO structure.
6552 ********************************************************************/
6554 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6555 POLICY_HND *hnd, unsigned char sess_key[16],
6556 uint16 switch_value, void *info)
6558 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6560 q_u->pol = *hnd;
6561 q_u->switch_value = switch_value;
6562 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6565 /*******************************************************************
6566 reads or writes a structure.
6567 ********************************************************************/
6569 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6570 prs_struct *ps, int depth)
6572 if (q_u == NULL)
6573 return False;
6575 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6576 depth++;
6578 if(!prs_align(ps))
6579 return False;
6581 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6583 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6584 return False;
6585 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6586 return False;
6588 return True;
6591 /*******************************************************************
6592 inits a SAMR_R_SET_USERINFO structure.
6593 ********************************************************************/
6595 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6597 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6599 r_u->status = status; /* return status */
6602 /*******************************************************************
6603 reads or writes a structure.
6604 ********************************************************************/
6606 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6607 prs_struct *ps, int depth)
6609 if (r_u == NULL)
6610 return False;
6612 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6613 depth++;
6615 if(!prs_align(ps))
6616 return False;
6618 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6619 return False;
6621 return True;
6624 /*******************************************************************
6625 inits a SAMR_Q_SET_USERINFO2 structure.
6626 ********************************************************************/
6628 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6629 POLICY_HND *hnd, unsigned char sess_key[16],
6630 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6632 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6634 q_u->pol = *hnd;
6635 q_u->switch_value = switch_value;
6636 q_u->ctr = ctr;
6638 if (q_u->ctr != NULL)
6639 q_u->ctr->switch_value = switch_value;
6641 switch (switch_value) {
6642 case 0x12:
6643 SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16);
6644 SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16);
6645 dump_data(100, (char *)sess_key, 16);
6646 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16);
6647 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16);
6648 break;
6652 /*******************************************************************
6653 reads or writes a structure.
6654 ********************************************************************/
6656 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6657 prs_struct *ps, int depth)
6659 if (q_u == NULL)
6660 return False;
6662 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6663 depth++;
6665 if(!prs_align(ps))
6666 return False;
6668 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6669 return False;
6671 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6672 return False;
6673 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6674 return False;
6676 return True;
6679 /*******************************************************************
6680 inits a SAMR_R_SET_USERINFO2 structure.
6681 ********************************************************************/
6683 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6685 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6687 r_u->status = status; /* return status */
6690 /*******************************************************************
6691 reads or writes a structure.
6692 ********************************************************************/
6694 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6695 prs_struct *ps, int depth)
6697 if (r_u == NULL)
6698 return False;
6700 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6701 depth++;
6703 if(!prs_align(ps))
6704 return False;
6706 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6707 return False;
6709 return True;
6712 /*******************************************************************
6713 inits a SAMR_Q_CONNECT structure.
6714 ********************************************************************/
6716 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6717 char *srv_name, uint32 access_mask)
6719 int len_srv_name = strlen(srv_name);
6721 DEBUG(5, ("init_samr_q_connect\n"));
6723 /* make PDC server name \\server */
6724 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6725 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6727 /* example values: 0x0000 0002 */
6728 q_u->access_mask = access_mask;
6731 /*******************************************************************
6732 reads or writes a structure.
6733 ********************************************************************/
6735 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6736 prs_struct *ps, int depth)
6738 if (q_u == NULL)
6739 return False;
6741 prs_debug(ps, depth, desc, "samr_io_q_connect");
6742 depth++;
6744 if(!prs_align(ps))
6745 return False;
6747 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6748 return False;
6749 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6750 return False;
6752 if(!prs_align(ps))
6753 return False;
6754 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6755 return False;
6757 return True;
6760 /*******************************************************************
6761 reads or writes a structure.
6762 ********************************************************************/
6764 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6765 prs_struct *ps, int depth)
6767 if (r_u == NULL)
6768 return False;
6770 prs_debug(ps, depth, desc, "samr_io_r_connect");
6771 depth++;
6773 if(!prs_align(ps))
6774 return False;
6776 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6777 return False;
6779 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6780 return False;
6782 return True;
6785 /*******************************************************************
6786 inits a SAMR_Q_CONNECT4 structure.
6787 ********************************************************************/
6789 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6790 char *srv_name, uint32 access_mask)
6792 int len_srv_name = strlen(srv_name);
6794 DEBUG(5, ("init_samr_q_connect\n"));
6796 /* make PDC server name \\server */
6797 q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
6798 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
6800 /* Only value we've seen, possibly an address type ? */
6801 q_u->unk_0 = 2;
6803 /* example values: 0x0000 0002 */
6804 q_u->access_mask = access_mask;
6807 /*******************************************************************
6808 reads or writes a structure.
6809 ********************************************************************/
6811 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6812 prs_struct *ps, int depth)
6814 if (q_u == NULL)
6815 return False;
6817 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6818 depth++;
6820 if(!prs_align(ps))
6821 return False;
6823 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6824 return False;
6825 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6826 return False;
6828 if(!prs_align(ps))
6829 return False;
6830 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6831 return False;
6832 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6833 return False;
6835 return True;
6838 /*******************************************************************
6839 reads or writes a structure.
6840 ********************************************************************/
6842 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6843 prs_struct *ps, int depth)
6845 if (r_u == NULL)
6846 return False;
6848 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6849 depth++;
6851 if(!prs_align(ps))
6852 return False;
6854 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6855 return False;
6857 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6858 return False;
6860 return True;
6863 /*******************************************************************
6864 inits a SAMR_Q_CONNECT_ANON structure.
6865 ********************************************************************/
6867 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
6869 DEBUG(5, ("init_samr_q_connect_anon\n"));
6871 q_u->ptr = 1;
6872 q_u->unknown_0 = 0x5c; /* server name (?!!) */
6873 q_u->unknown_1 = 0x01;
6874 q_u->access_mask = 0x20;
6877 /*******************************************************************
6878 reads or writes a structure.
6879 ********************************************************************/
6881 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
6882 prs_struct *ps, int depth)
6884 if (q_u == NULL)
6885 return False;
6887 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
6888 depth++;
6890 if(!prs_align(ps))
6891 return False;
6893 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
6894 return False;
6895 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
6896 return False;
6897 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1))
6898 return False;
6899 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6900 return False;
6902 return True;
6905 /*******************************************************************
6906 reads or writes a structure.
6907 ********************************************************************/
6909 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
6910 prs_struct *ps, int depth)
6912 if (r_u == NULL)
6913 return False;
6915 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
6916 depth++;
6918 if(!prs_align(ps))
6919 return False;
6921 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6922 return False;
6924 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6925 return False;
6927 return True;
6930 /*******************************************************************
6931 inits a SAMR_Q_GET_DOM_PWINFO structure.
6932 ********************************************************************/
6934 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
6935 char *srv_name)
6937 int len_srv_name = strlen(srv_name);
6939 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6941 q_u->ptr = 1;
6942 init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
6943 init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
6946 /*******************************************************************
6947 reads or writes a structure.
6948 ********************************************************************/
6950 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
6951 prs_struct *ps, int depth)
6953 if (q_u == NULL)
6954 return False;
6956 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
6957 depth++;
6959 if(!prs_align(ps))
6960 return False;
6962 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
6963 return False;
6964 if (q_u->ptr != 0) {
6965 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
6966 return False;
6967 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
6968 return False;
6971 return True;
6974 /*******************************************************************
6975 reads or writes a structure.
6976 ********************************************************************/
6978 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
6979 prs_struct *ps, int depth)
6981 if (r_u == NULL)
6982 return False;
6984 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
6985 depth++;
6987 if(!prs_align(ps))
6988 return False;
6991 * We need 16 bytes here according to tests. Don't know
6992 * what they are, but the length is important for the singing
6995 if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0))
6996 return False;
6997 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1))
6998 return False;
6999 if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2))
7000 return False;
7002 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7003 return False;
7005 return True;
7008 /*******************************************************************
7009 make a SAMR_ENC_PASSWD structure.
7010 ********************************************************************/
7012 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512])
7014 ZERO_STRUCTP(pwd);
7016 if (pass == NULL) {
7017 pwd->ptr = 0;
7018 } else {
7019 pwd->ptr = 1;
7020 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7024 /*******************************************************************
7025 reads or writes a SAMR_ENC_PASSWD structure.
7026 ********************************************************************/
7028 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7029 prs_struct *ps, int depth)
7031 if (pwd == NULL)
7032 return False;
7034 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7035 depth++;
7037 if(!prs_align(ps))
7038 return False;
7040 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7041 return False;
7043 if (pwd->ptr != 0) {
7044 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7045 return False;
7048 return True;
7051 /*******************************************************************
7052 inits a SAMR_ENC_HASH structure.
7053 ********************************************************************/
7055 void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16])
7057 ZERO_STRUCTP(hsh);
7059 if (hash == NULL) {
7060 hsh->ptr = 0;
7061 } else {
7062 hsh->ptr = 1;
7063 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7067 /*******************************************************************
7068 reads or writes a SAMR_ENC_HASH structure.
7069 ********************************************************************/
7071 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7072 prs_struct *ps, int depth)
7074 if (hsh == NULL)
7075 return False;
7077 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7078 depth++;
7080 if(!prs_align(ps))
7081 return False;
7083 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7084 return False;
7085 if (hsh->ptr != 0) {
7086 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7087 return False;
7090 return True;
7093 /*******************************************************************
7094 inits a SAMR_R_GET_DOM_PWINFO structure.
7095 ********************************************************************/
7097 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7098 char *dest_host, char *user_name,
7099 char nt_newpass[516],
7100 uchar nt_oldhash[16],
7101 char lm_newpass[516],
7102 uchar lm_oldhash[16])
7104 int len_dest_host = strlen(dest_host);
7105 int len_user_name = strlen(user_name);
7107 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7109 q_u->ptr_0 = 1;
7110 init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
7111 init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
7112 init_uni_hdr(&q_u->hdr_user_name, len_user_name);
7113 init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
7115 init_enc_passwd(&q_u->nt_newpass, nt_newpass);
7116 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7118 q_u->unknown = 0x01;
7120 init_enc_passwd(&q_u->lm_newpass, lm_newpass);
7121 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7124 /*******************************************************************
7125 reads or writes a structure.
7126 ********************************************************************/
7128 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7129 prs_struct *ps, int depth)
7131 if (q_u == NULL)
7132 return False;
7134 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7135 depth++;
7137 if(!prs_align(ps))
7138 return False;
7140 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7141 return False;
7143 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7144 return False;
7145 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7146 return False;
7148 if(!prs_align(ps))
7149 return False;
7150 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7151 return False;
7152 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7153 return False;
7155 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7156 return False;
7157 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7158 return False;
7160 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7161 return False;
7163 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7164 return False;
7165 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7166 return False;
7168 return True;
7171 /*******************************************************************
7172 inits a SAMR_R_CHGPASSWD_USER structure.
7173 ********************************************************************/
7175 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7177 DEBUG(5, ("init_r_chgpasswd_user\n"));
7179 r_u->status = status;
7182 /*******************************************************************
7183 reads or writes a structure.
7184 ********************************************************************/
7186 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7187 prs_struct *ps, int depth)
7189 if (r_u == NULL)
7190 return False;
7192 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7193 depth++;
7195 if(!prs_align(ps))
7196 return False;
7198 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7199 return False;
7201 return True;
7204 /*******************************************************************
7205 reads or writes a structure.
7206 ********************************************************************/
7208 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u,
7209 POLICY_HND *domain_pol, uint16 switch_value)
7211 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7213 q_u->domain_pol = *domain_pol;
7214 q_u->switch_value = switch_value;
7217 /*******************************************************************
7218 reads or writes a structure.
7219 ********************************************************************/
7221 BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u,
7222 prs_struct *ps, int depth)
7224 if (q_u == NULL)
7225 return False;
7227 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e");
7228 depth++;
7230 if(!prs_align(ps))
7231 return False;
7233 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7234 return False;
7236 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7237 return False;
7239 return True;
7242 /*******************************************************************
7243 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7244 ********************************************************************/
7246 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u,
7247 uint16 switch_value, SAM_UNK_CTR * ctr,
7248 NTSTATUS status)
7250 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7252 r_u->ptr_0 = 0;
7253 r_u->switch_value = 0;
7254 r_u->status = status; /* return status */
7256 if (NT_STATUS_IS_OK(status)) {
7257 r_u->switch_value = switch_value;
7258 r_u->ptr_0 = 1;
7259 r_u->ctr = ctr;
7263 /*******************************************************************
7264 reads or writes a structure.
7265 ********************************************************************/
7267 BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u,
7268 prs_struct *ps, int depth)
7270 if (r_u == NULL)
7271 return False;
7273 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7274 depth++;
7276 if(!prs_align(ps))
7277 return False;
7279 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7280 return False;
7282 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7283 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7284 return False;
7285 if(!prs_align(ps))
7286 return False;
7288 switch (r_u->switch_value) {
7289 case 0x0c:
7290 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7291 return False;
7292 break;
7293 case 0x07:
7294 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7295 return False;
7296 break;
7297 case 0x06:
7298 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7299 return False;
7300 break;
7301 case 0x05:
7302 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7303 return False;
7304 break;
7305 case 0x03:
7306 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7307 return False;
7308 break;
7309 case 0x02:
7310 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7311 return False;
7312 break;
7313 case 0x01:
7314 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7315 return False;
7316 break;
7317 default:
7318 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7319 r_u->switch_value));
7320 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7321 return False;
7325 if(!prs_align(ps))
7326 return False;
7328 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7329 return False;
7331 return True;
7335 /*******************************************************************
7336 reads or writes a structure.
7337 ********************************************************************/
7339 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7340 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7342 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7344 q_u->domain_pol = *domain_pol;
7345 q_u->switch_value0 = switch_value;
7347 q_u->switch_value = switch_value;
7348 q_u->ctr = ctr;
7352 /*******************************************************************
7353 reads or writes a structure.
7354 ********************************************************************/
7356 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7357 prs_struct *ps, int depth)
7359 if (q_u == NULL)
7360 return False;
7362 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7363 depth++;
7365 if(!prs_align(ps))
7366 return False;
7368 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7369 return False;
7371 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7372 return False;
7374 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7375 return False;
7377 if(!prs_align(ps))
7378 return False;
7380 if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL)
7381 return False;
7383 switch (q_u->switch_value) {
7385 case 0x0c:
7386 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7387 return False;
7388 break;
7389 case 0x07:
7390 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7391 return False;
7392 break;
7393 case 0x06:
7394 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7395 return False;
7396 break;
7397 case 0x05:
7398 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7399 return False;
7400 break;
7401 case 0x03:
7402 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7403 return False;
7404 break;
7405 case 0x02:
7406 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7407 return False;
7408 break;
7409 case 0x01:
7410 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7411 return False;
7412 break;
7413 default:
7414 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7415 q_u->switch_value));
7416 return False;
7419 return True;
7422 /*******************************************************************
7423 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7424 ********************************************************************/
7426 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7428 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7430 r_u->status = status; /* return status */
7433 /*******************************************************************
7434 reads or writes a structure.
7435 ********************************************************************/
7437 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7438 prs_struct *ps, int depth)
7440 if (r_u == NULL)
7441 return False;
7443 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7444 depth++;
7446 if(!prs_align(ps))
7447 return False;
7449 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7450 return False;
7452 return True;