r15438: Fix samrQueryDomainInfo level 5 where we returned our netbios
[Samba/nascimento.git] / source3 / rpc_parse / parse_samr.c
blobc425b945b4b5882066cdc14eb43fe32ac3977bcc
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"
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
40 q_c->pol = *hnd;
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
50 if (q_u == NULL)
51 return False;
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
54 depth++;
56 if(!prs_align(ps))
57 return False;
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
69 if (r_u == NULL)
70 return False;
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
73 depth++;
75 if(!prs_align(ps))
76 return False;
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
79 return False;
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
82 return False;
84 return True;
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u->connect_pol = *pol;
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
108 if (q_u == NULL)
109 return False;
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
112 depth++;
114 if(!prs_align(ps))
115 return False;
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
118 return False;
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
121 return False;
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
124 return False;
126 return True;
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u->status = status;
139 r_u->ptr_sid = 0;
140 if (NT_STATUS_IS_OK(status)) {
141 r_u->ptr_sid = 1;
142 init_dom_sid2(&r_u->dom_sid, dom_sid);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
153 if (r_u == NULL)
154 return False;
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
157 depth++;
159 if(!prs_align(ps))
160 return False;
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
163 return False;
165 if (r_u->ptr_sid != 0) {
166 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth))
167 return False;
168 if(!prs_align(ps))
169 return False;
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
173 return False;
175 return True;
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
197 if (q_u == NULL)
198 return False;
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
201 depth++;
203 if(!prs_align(ps))
204 return False;
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
207 return False;
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
210 return False;
212 if(!prs_align(ps))
213 return False;
215 return True;
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
225 if (r_u == NULL)
226 return False;
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
229 depth++;
231 if(!prs_align(ps))
232 return False;
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
235 return False;
237 return True;
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
246 const DOM_SID *sid)
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
250 q_u->pol = *pol;
251 q_u->flags = flags;
252 init_dom_sid2(&q_u->dom_sid, sid);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
262 if (q_u == NULL)
263 return False;
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
266 depth++;
268 if(!prs_align(ps))
269 return False;
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
272 return False;
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
275 return False;
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
278 return False;
280 return True;
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
290 if (r_u == NULL)
291 return False;
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
294 depth++;
296 if(!prs_align(ps))
297 return False;
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
300 return False;
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
303 return False;
305 return True;
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u->user_pol = *user_pol;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
327 if (q_u == NULL)
328 return False;
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
331 depth++;
333 if(!prs_align(ps))
334 return False;
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
339 /*******************************************************************
340 Init.
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u->min_pwd_length = 0x0000;
350 * used to be
351 * r_u->unknown_1 = 0x0015;
352 * but for trusts.
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
357 r_u->password_properties = 0x00000000;
359 r_u->status = status;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
369 if (r_u == NULL)
370 return False;
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
373 depth++;
375 if(!prs_align(ps))
376 return False;
378 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
379 return False;
380 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1))
381 return False;
382 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
383 return False;
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
386 return False;
388 return True;
392 /*******************************************************************
393 reads or writes a structure.
394 ********************************************************************/
396 BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
399 if (q_u == NULL)
400 return False;
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
403 depth++;
405 if(!prs_align(ps))
406 return False;
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
409 return False;
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
412 return False;
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
415 return False;
417 return True;
421 /*******************************************************************
422 reads or writes a structure.
423 ********************************************************************/
425 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
435 /*******************************************************************
436 reads or writes a structure.
437 ********************************************************************/
439 BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
442 if (q_u == NULL)
443 return False;
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
446 depth++;
448 if(!prs_align(ps))
449 return False;
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
452 return False;
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
455 return False;
457 return True;
460 /*******************************************************************
461 reads or writes a structure.
462 ********************************************************************/
464 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
473 /*******************************************************************
474 reads or writes a structure.
475 ********************************************************************/
477 BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
480 if (q_u == NULL)
481 return False;
483 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info");
484 depth++;
486 if(!prs_align(ps))
487 return False;
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
490 return False;
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
493 return False;
495 return True;
499 /*******************************************************************
500 inits a structure.
501 ********************************************************************/
503 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
505 u_3->logout.low = nt_logout.low;
506 u_3->logout.high = nt_logout.high;
509 /*******************************************************************
510 reads or writes a structure.
511 ********************************************************************/
513 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
514 prs_struct *ps, int depth)
516 if (u_3 == NULL)
517 return False;
519 prs_debug(ps, depth, desc, "sam_io_unk_info3");
520 depth++;
522 if(!smb_io_time("logout", &u_3->logout, ps, depth))
523 return False;
525 return True;
528 /*******************************************************************
529 inits a structure.
530 ********************************************************************/
532 void init_unk_info6(SAM_UNK_INFO_6 * u_6)
534 u_6->unknown_0 = 0x00000000;
535 u_6->ptr_0 = 1;
536 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */
539 /*******************************************************************
540 reads or writes a structure.
541 ********************************************************************/
543 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
544 prs_struct *ps, int depth)
546 if (u_6 == NULL)
547 return False;
549 prs_debug(ps, depth, desc, "sam_io_unk_info6");
550 depth++;
552 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */
553 return False;
554 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */
555 return False;
556 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */
557 return False;
559 return True;
562 /*******************************************************************
563 inits a structure.
564 ********************************************************************/
566 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
568 u_7->server_role = server_role;
571 /*******************************************************************
572 reads or writes a structure.
573 ********************************************************************/
575 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
576 prs_struct *ps, int depth)
578 if (u_7 == NULL)
579 return False;
581 prs_debug(ps, depth, desc, "sam_io_unk_info7");
582 depth++;
584 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
585 return False;
587 return True;
590 /*******************************************************************
591 inits a structure.
592 ********************************************************************/
594 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
596 unix_to_nt_time(&u_8->domain_create_time, 0);
597 u_8->seq_num.low = seq_num;
598 u_8->seq_num.high = 0x0000;
601 /*******************************************************************
602 reads or writes a structure.
603 ********************************************************************/
605 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
606 prs_struct *ps, int depth)
608 if (u_8 == NULL)
609 return False;
611 prs_debug(ps, depth, desc, "sam_io_unk_info8");
612 depth++;
614 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
615 return False;
617 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
618 return False;
620 return True;
624 /*******************************************************************
625 inits a structure.
626 ********************************************************************/
628 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
630 u_12->duration.low = nt_lock_duration.low;
631 u_12->duration.high = nt_lock_duration.high;
632 u_12->reset_count.low = nt_reset_time.low;
633 u_12->reset_count.high = nt_reset_time.high;
635 u_12->bad_attempt_lockout = lockout;
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
643 prs_struct *ps, int depth)
645 if (u_12 == NULL)
646 return False;
648 prs_debug(ps, depth, desc, "sam_io_unk_info12");
649 depth++;
651 if(!smb_io_time("duration", &u_12->duration, ps, depth))
652 return False;
653 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
654 return False;
655 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
656 return False;
658 return True;
661 /*******************************************************************
662 inits a structure.
663 ********************************************************************/
665 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
667 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
668 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
671 /*******************************************************************
672 reads or writes a structure.
673 ********************************************************************/
675 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
676 prs_struct *ps, int depth)
678 if (u_5 == NULL)
679 return False;
681 prs_debug(ps, depth, desc, "sam_io_unk_info5");
682 depth++;
684 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
685 return False;
687 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
688 return False;
690 return True;
693 /*******************************************************************
694 inits a structure.
695 ********************************************************************/
697 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
698 const char *comment, const char *domain, const char *server,
699 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
701 u_2->logout.low = nt_logout.low;
702 u_2->logout.high = nt_logout.high;
704 u_2->seq_num.low = seq_num;
705 u_2->seq_num.high = 0x00000000;
708 u_2->unknown_4 = 0x00000001;
709 u_2->server_role = server_role;
710 u_2->unknown_6 = 0x00000001;
711 u_2->num_domain_usrs = num_users;
712 u_2->num_domain_grps = num_groups;
713 u_2->num_local_grps = num_alias;
715 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
717 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
718 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
719 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
720 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
721 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
722 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
725 /*******************************************************************
726 reads or writes a structure.
727 ********************************************************************/
729 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
730 prs_struct *ps, int depth)
732 if (u_2 == NULL)
733 return False;
735 prs_debug(ps, depth, desc, "sam_io_unk_info2");
736 depth++;
738 if(!smb_io_time("logout", &u_2->logout, ps, depth))
739 return False;
740 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
741 return False;
742 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
743 return False;
744 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
745 return False;
747 /* put all the data in here, at the moment, including what the above
748 pointer is referring to
751 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
752 return False;
754 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
755 return False;
756 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
757 return False;
758 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
759 return False;
760 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
761 return False;
762 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
763 return False;
764 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
765 return False;
767 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
768 return False;
769 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
770 return False;
771 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
772 return False;
774 return True;
777 /*******************************************************************
778 inits a structure.
779 ********************************************************************/
781 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
782 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
784 u_1->min_length_password = min_pass_len;
785 u_1->password_history = pass_hist;
786 u_1->password_properties = password_properties;
788 /* password never expire */
789 u_1->expire.high = nt_expire.high;
790 u_1->expire.low = nt_expire.low;
792 /* can change the password now */
793 u_1->min_passwordage.high = nt_min_age.high;
794 u_1->min_passwordage.low = nt_min_age.low;
798 /*******************************************************************
799 reads or writes a structure.
800 ********************************************************************/
802 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
803 prs_struct *ps, int depth)
805 if (u_1 == NULL)
806 return False;
808 prs_debug(ps, depth, desc, "sam_io_unk_info1");
809 depth++;
811 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
812 return False;
813 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
814 return False;
815 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
816 return False;
817 if(!smb_io_time("expire", &u_1->expire, ps, depth))
818 return False;
819 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
820 return False;
822 return True;
825 /*******************************************************************
826 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
827 ********************************************************************/
829 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
830 uint16 switch_value, SAM_UNK_CTR * ctr,
831 NTSTATUS status)
833 DEBUG(5, ("init_samr_r_query_dom_info\n"));
835 r_u->ptr_0 = 0;
836 r_u->switch_value = 0;
837 r_u->status = status; /* return status */
839 if (NT_STATUS_IS_OK(status)) {
840 r_u->switch_value = switch_value;
841 r_u->ptr_0 = 1;
842 r_u->ctr = ctr;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
850 BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
851 prs_struct *ps, int depth)
853 if (r_u == NULL)
854 return False;
856 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info");
857 depth++;
859 if(!prs_align(ps))
860 return False;
862 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
863 return False;
865 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
866 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
867 return False;
868 if(!prs_align(ps))
869 return False;
871 switch (r_u->switch_value) {
872 case 0x0c:
873 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
874 return False;
875 break;
876 case 0x08:
877 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
878 return False;
879 break;
880 case 0x07:
881 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
882 return False;
883 break;
884 case 0x06:
885 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
886 return False;
887 break;
888 case 0x05:
889 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
890 return False;
891 break;
892 case 0x03:
893 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
894 return False;
895 break;
896 case 0x02:
897 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
898 return False;
899 break;
900 case 0x01:
901 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
902 return False;
903 break;
904 default:
905 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
906 r_u->switch_value));
907 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
908 return False;
912 if(!prs_align(ps))
913 return False;
915 if(!prs_ntstatus("status", ps, depth, &r_u->status))
916 return False;
918 return True;
921 /*******************************************************************
922 reads or writes a structure.
923 ********************************************************************/
925 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
926 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
928 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
930 q_u->pol = *pol;
931 q_u->sec_info = sec_info;
932 q_u->buf = buf;
936 /*******************************************************************
937 reads or writes a SAMR_R_SET_SEC_OBJ structure.
938 ********************************************************************/
940 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
941 prs_struct *ps, int depth)
943 if (r_u == NULL)
944 return False;
946 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
947 depth++;
949 if(!prs_align(ps))
950 return False;
952 if(!prs_ntstatus("status", ps, depth, &r_u->status))
953 return False;
955 return True;
958 /*******************************************************************
959 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
960 ********************************************************************/
962 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
963 prs_struct *ps, int depth)
965 if (r_u == NULL)
966 return False;
968 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
969 depth++;
971 if(!prs_align(ps))
972 return False;
974 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
975 return False;
976 if (r_u->ptr != 0) {
977 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
978 return False;
981 if(!prs_ntstatus("status", ps, depth, &r_u->status))
982 return False;
984 return True;
987 /*******************************************************************
988 reads or writes a SAM_STR1 structure.
989 ********************************************************************/
991 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
992 uint32 name_buf, uint32 desc_buf,
993 prs_struct *ps, int depth)
995 if (sam == NULL)
996 return False;
998 prs_debug(ps, depth, desc, "sam_io_sam_str1");
999 depth++;
1001 if(!prs_align(ps))
1002 return False;
1003 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
1004 return False;
1006 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1007 return False;
1009 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1010 return False;
1012 return True;
1015 /*******************************************************************
1016 inits a SAM_ENTRY1 structure.
1017 ********************************************************************/
1019 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1020 UNISTR2 *sam_name, UNISTR2 *sam_full,
1021 UNISTR2 *sam_desc, uint32 rid_user,
1022 uint32 acb_info)
1024 DEBUG(5, ("init_sam_entry1\n"));
1026 ZERO_STRUCTP(sam);
1028 sam->user_idx = user_idx;
1029 sam->rid_user = rid_user;
1030 sam->acb_info = acb_info;
1032 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1033 init_uni_hdr(&sam->hdr_user_name, sam_full);
1034 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1037 /*******************************************************************
1038 reads or writes a SAM_ENTRY1 structure.
1039 ********************************************************************/
1041 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1042 prs_struct *ps, int depth)
1044 if (sam == NULL)
1045 return False;
1047 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1048 depth++;
1050 if(!prs_align(ps))
1051 return False;
1053 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1054 return False;
1056 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1057 return False;
1058 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1059 return False;
1061 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1062 return False;
1063 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1064 return False;
1065 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1066 return False;
1068 return True;
1071 /*******************************************************************
1072 reads or writes a SAM_STR2 structure.
1073 ********************************************************************/
1075 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1076 uint32 desc_buf, prs_struct *ps, int depth)
1078 if (sam == NULL)
1079 return False;
1081 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1082 depth++;
1084 if(!prs_align(ps))
1085 return False;
1087 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1088 return False;
1089 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1090 return False;
1092 return True;
1095 /*******************************************************************
1096 inits a SAM_ENTRY2 structure.
1097 ********************************************************************/
1098 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1099 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1100 uint32 rid_user, uint32 acb_info)
1102 DEBUG(5, ("init_sam_entry2\n"));
1104 sam->user_idx = user_idx;
1105 sam->rid_user = rid_user;
1106 sam->acb_info = acb_info;
1108 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1109 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1112 /*******************************************************************
1113 reads or writes a SAM_ENTRY2 structure.
1114 ********************************************************************/
1116 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1117 prs_struct *ps, int depth)
1119 if (sam == NULL)
1120 return False;
1122 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1123 depth++;
1125 if(!prs_align(ps))
1126 return False;
1128 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1129 return False;
1131 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1132 return False;
1133 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1134 return False;
1136 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1137 return False;
1138 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1139 return False;
1141 return True;
1144 /*******************************************************************
1145 reads or writes a SAM_STR3 structure.
1146 ********************************************************************/
1148 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1149 uint32 desc_buf, prs_struct *ps, int depth)
1151 if (sam == NULL)
1152 return False;
1154 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1155 depth++;
1157 if(!prs_align(ps))
1158 return False;
1160 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1161 return False;
1162 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1163 return False;
1165 return True;
1168 /*******************************************************************
1169 inits a SAM_ENTRY3 structure.
1170 ********************************************************************/
1172 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1173 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1174 uint32 rid_grp)
1176 DEBUG(5, ("init_sam_entry3\n"));
1178 sam->grp_idx = grp_idx;
1179 sam->rid_grp = rid_grp;
1180 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1182 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1183 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1186 /*******************************************************************
1187 reads or writes a SAM_ENTRY3 structure.
1188 ********************************************************************/
1190 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1191 prs_struct *ps, int depth)
1193 if (sam == NULL)
1194 return False;
1196 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1197 depth++;
1199 if(!prs_align(ps))
1200 return False;
1202 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1203 return False;
1205 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1206 return False;
1207 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1208 return False;
1210 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1211 return False;
1212 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1213 return False;
1215 return True;
1218 /*******************************************************************
1219 inits a SAM_ENTRY4 structure.
1220 ********************************************************************/
1222 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1223 uint32 len_acct_name)
1225 DEBUG(5, ("init_sam_entry4\n"));
1227 sam->user_idx = user_idx;
1228 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1231 /*******************************************************************
1232 reads or writes a SAM_ENTRY4 structure.
1233 ********************************************************************/
1235 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1236 prs_struct *ps, int depth)
1238 if (sam == NULL)
1239 return False;
1241 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1242 depth++;
1244 if(!prs_align(ps))
1245 return False;
1247 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1248 return False;
1249 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1250 return False;
1252 return True;
1255 /*******************************************************************
1256 inits a SAM_ENTRY5 structure.
1257 ********************************************************************/
1259 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1260 uint32 len_grp_name)
1262 DEBUG(5, ("init_sam_entry5\n"));
1264 sam->grp_idx = grp_idx;
1265 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1266 len_grp_name != 0);
1269 /*******************************************************************
1270 reads or writes a SAM_ENTRY5 structure.
1271 ********************************************************************/
1273 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1274 prs_struct *ps, int depth)
1276 if (sam == NULL)
1277 return False;
1279 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1280 depth++;
1282 if(!prs_align(ps))
1283 return False;
1285 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1286 return False;
1287 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1288 return False;
1290 return True;
1293 /*******************************************************************
1294 inits a SAM_ENTRY structure.
1295 ********************************************************************/
1297 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1299 DEBUG(10, ("init_sam_entry: %d\n", rid));
1301 sam->rid = rid;
1302 init_uni_hdr(&sam->hdr_name, uni2);
1305 /*******************************************************************
1306 reads or writes a SAM_ENTRY structure.
1307 ********************************************************************/
1309 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1310 prs_struct *ps, int depth)
1312 if (sam == NULL)
1313 return False;
1315 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1316 depth++;
1318 if(!prs_align(ps))
1319 return False;
1320 if(!prs_uint32("rid", ps, depth, &sam->rid))
1321 return False;
1322 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1323 return False;
1325 return True;
1328 /*******************************************************************
1329 inits a SAMR_Q_ENUM_DOM_USERS structure.
1330 ********************************************************************/
1332 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1333 uint32 start_idx,
1334 uint32 acb_mask, uint32 size)
1336 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1338 q_e->pol = *pol;
1340 q_e->start_idx = start_idx; /* zero indicates lots */
1341 q_e->acb_mask = acb_mask;
1342 q_e->max_size = size;
1345 /*******************************************************************
1346 reads or writes a structure.
1347 ********************************************************************/
1349 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1350 prs_struct *ps, int depth)
1352 if (q_e == NULL)
1353 return False;
1355 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1356 depth++;
1358 if(!prs_align(ps))
1359 return False;
1361 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1362 return False;
1364 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1365 return False;
1366 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1367 return False;
1369 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1370 return False;
1372 return True;
1376 /*******************************************************************
1377 inits a SAMR_R_ENUM_DOM_USERS structure.
1378 ********************************************************************/
1380 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1381 uint32 next_idx, uint32 num_sam_entries)
1383 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1385 r_u->next_idx = next_idx;
1387 if (num_sam_entries != 0) {
1388 r_u->ptr_entries1 = 1;
1389 r_u->ptr_entries2 = 1;
1390 r_u->num_entries2 = num_sam_entries;
1391 r_u->num_entries3 = num_sam_entries;
1393 r_u->num_entries4 = num_sam_entries;
1394 } else {
1395 r_u->ptr_entries1 = 0;
1396 r_u->num_entries2 = num_sam_entries;
1397 r_u->ptr_entries2 = 1;
1401 /*******************************************************************
1402 reads or writes a structure.
1403 ********************************************************************/
1405 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1406 prs_struct *ps, int depth)
1408 uint32 i;
1410 if (r_u == NULL)
1411 return False;
1413 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1414 depth++;
1416 if(!prs_align(ps))
1417 return False;
1419 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1420 return False;
1421 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1422 return False;
1424 if (r_u->ptr_entries1 != 0) {
1425 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1426 return False;
1427 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1428 return False;
1429 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1430 return False;
1432 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1433 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1434 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1437 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1438 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1439 r_u->num_entries4 = 0;
1440 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1441 return False;
1444 for (i = 0; i < r_u->num_entries2; i++) {
1445 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1446 return False;
1449 for (i = 0; i < r_u->num_entries2; i++) {
1450 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1451 return False;
1456 if(!prs_align(ps))
1457 return False;
1459 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1460 return False;
1461 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1462 return False;
1464 return True;
1467 /*******************************************************************
1468 inits a SAMR_Q_QUERY_DISPINFO structure.
1469 ********************************************************************/
1471 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1472 uint16 switch_level, uint32 start_idx,
1473 uint32 max_entries, uint32 max_size)
1475 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1477 q_e->domain_pol = *pol;
1479 q_e->switch_level = switch_level;
1481 q_e->start_idx = start_idx;
1482 q_e->max_entries = max_entries;
1483 q_e->max_size = max_size;
1486 /*******************************************************************
1487 reads or writes a structure.
1488 ********************************************************************/
1490 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1491 prs_struct *ps, int depth)
1493 if (q_e == NULL)
1494 return False;
1496 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1497 depth++;
1499 if(!prs_align(ps))
1500 return False;
1502 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1503 return False;
1505 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1506 return False;
1507 if(!prs_align(ps))
1508 return False;
1510 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1511 return False;
1512 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1513 return False;
1514 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1515 return False;
1517 return True;
1520 /*******************************************************************
1521 inits a SAM_DISPINFO_1 structure.
1522 ********************************************************************/
1524 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1525 uint32 num_entries, uint32 start_idx,
1526 struct samr_displayentry *entries)
1528 uint32 i;
1530 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1532 if (num_entries==0)
1533 return NT_STATUS_OK;
1535 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1536 if (*sam == NULL)
1537 return NT_STATUS_NO_MEMORY;
1539 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1540 if ((*sam)->sam == NULL)
1541 return NT_STATUS_NO_MEMORY;
1543 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1544 if ((*sam)->str == NULL)
1545 return NT_STATUS_NO_MEMORY;
1547 for (i = 0; i < num_entries ; i++) {
1548 init_unistr2(&(*sam)->str[i].uni_acct_name,
1549 entries[i].account_name, UNI_FLAGS_NONE);
1550 init_unistr2(&(*sam)->str[i].uni_full_name,
1551 entries[i].fullname, UNI_FLAGS_NONE);
1552 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1553 entries[i].description, UNI_FLAGS_NONE);
1555 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1556 &(*sam)->str[i].uni_acct_name,
1557 &(*sam)->str[i].uni_full_name,
1558 &(*sam)->str[i].uni_acct_desc,
1559 entries[i].rid, entries[i].acct_flags);
1562 return NT_STATUS_OK;
1565 /*******************************************************************
1566 reads or writes a structure.
1567 ********************************************************************/
1569 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1570 uint32 num_entries,
1571 prs_struct *ps, int depth)
1573 uint32 i;
1575 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1576 depth++;
1578 if(!prs_align(ps))
1579 return False;
1581 if (UNMARSHALLING(ps) && num_entries > 0) {
1583 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1584 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1585 return False;
1588 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1589 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1590 return False;
1594 for (i = 0; i < num_entries; i++) {
1595 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1596 return False;
1599 for (i = 0; i < num_entries; i++) {
1600 if(!sam_io_sam_str1("", &sam->str[i],
1601 sam->sam[i].hdr_acct_name.buffer,
1602 sam->sam[i].hdr_user_name.buffer,
1603 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1604 return False;
1607 return True;
1610 /*******************************************************************
1611 inits a SAM_DISPINFO_2 structure.
1612 ********************************************************************/
1614 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1615 uint32 num_entries, uint32 start_idx,
1616 struct samr_displayentry *entries)
1618 uint32 i;
1620 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1622 if (num_entries==0)
1623 return NT_STATUS_OK;
1625 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1626 if (*sam == NULL)
1627 return NT_STATUS_NO_MEMORY;
1629 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1630 if ((*sam)->sam == NULL)
1631 return NT_STATUS_NO_MEMORY;
1633 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1634 if ((*sam)->str == NULL)
1635 return NT_STATUS_NO_MEMORY;
1637 for (i = 0; i < num_entries; i++) {
1638 init_unistr2(&(*sam)->str[i].uni_srv_name,
1639 entries[i].account_name, UNI_FLAGS_NONE);
1640 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1641 entries[i].description, UNI_FLAGS_NONE);
1643 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1644 &(*sam)->str[i].uni_srv_name,
1645 &(*sam)->str[i].uni_srv_desc,
1646 entries[i].rid, entries[i].acct_flags);
1649 return NT_STATUS_OK;
1652 /*******************************************************************
1653 reads or writes a structure.
1654 ********************************************************************/
1656 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1657 uint32 num_entries,
1658 prs_struct *ps, int depth)
1660 uint32 i;
1662 if (sam == NULL)
1663 return False;
1665 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1666 depth++;
1668 if(!prs_align(ps))
1669 return False;
1671 if (UNMARSHALLING(ps) && num_entries > 0) {
1673 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1674 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1675 return False;
1678 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1679 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1680 return False;
1684 for (i = 0; i < num_entries; i++) {
1685 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1686 return False;
1689 for (i = 0; i < num_entries; i++) {
1690 if(!sam_io_sam_str2("", &sam->str[i],
1691 sam->sam[i].hdr_srv_name.buffer,
1692 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1693 return False;
1696 return True;
1699 /*******************************************************************
1700 inits a SAM_DISPINFO_3 structure.
1701 ********************************************************************/
1703 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1704 uint32 num_entries, uint32 start_idx,
1705 struct samr_displayentry *entries)
1707 uint32 i;
1709 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1711 if (num_entries==0)
1712 return NT_STATUS_OK;
1714 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1715 if (*sam == NULL)
1716 return NT_STATUS_NO_MEMORY;
1718 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1719 return NT_STATUS_NO_MEMORY;
1721 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1722 return NT_STATUS_NO_MEMORY;
1724 for (i = 0; i < num_entries; i++) {
1725 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1727 init_unistr2(&(*sam)->str[i].uni_grp_name,
1728 entries[i].account_name, UNI_FLAGS_NONE);
1729 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1730 entries[i].description, UNI_FLAGS_NONE);
1732 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1733 &(*sam)->str[i].uni_grp_name,
1734 &(*sam)->str[i].uni_grp_desc,
1735 entries[i].rid);
1738 return NT_STATUS_OK;
1741 /*******************************************************************
1742 reads or writes a structure.
1743 ********************************************************************/
1745 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1746 uint32 num_entries,
1747 prs_struct *ps, int depth)
1749 uint32 i;
1751 if (sam == NULL)
1752 return False;
1754 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1755 depth++;
1757 if(!prs_align(ps))
1758 return False;
1760 if (UNMARSHALLING(ps) && num_entries > 0) {
1762 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1763 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1764 return False;
1767 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1768 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1769 return False;
1773 for (i = 0; i < num_entries; i++) {
1774 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1775 return False;
1778 for (i = 0; i < num_entries; i++) {
1779 if(!sam_io_sam_str3("", &sam->str[i],
1780 sam->sam[i].hdr_grp_name.buffer,
1781 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1782 return False;
1785 return True;
1788 /*******************************************************************
1789 inits a SAM_DISPINFO_4 structure.
1790 ********************************************************************/
1792 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1793 uint32 num_entries, uint32 start_idx,
1794 struct samr_displayentry *entries)
1796 uint32 i;
1798 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1800 if (num_entries==0)
1801 return NT_STATUS_OK;
1803 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1804 if (*sam == NULL)
1805 return NT_STATUS_NO_MEMORY;
1807 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1808 if ((*sam)->sam == NULL)
1809 return NT_STATUS_NO_MEMORY;
1811 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1812 if ((*sam)->str == NULL)
1813 return NT_STATUS_NO_MEMORY;
1815 for (i = 0; i < num_entries; i++) {
1816 size_t len_sam_name = strlen(entries[i].account_name);
1818 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1820 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1821 len_sam_name);
1823 init_string2(&(*sam)->str[i].acct_name,
1824 entries[i].account_name, len_sam_name+1,
1825 len_sam_name);
1828 return NT_STATUS_OK;
1831 /*******************************************************************
1832 reads or writes a structure.
1833 ********************************************************************/
1835 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1836 uint32 num_entries,
1837 prs_struct *ps, int depth)
1839 uint32 i;
1841 if (sam == NULL)
1842 return False;
1844 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1845 depth++;
1847 if(!prs_align(ps))
1848 return False;
1850 if (UNMARSHALLING(ps) && num_entries > 0) {
1852 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1853 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1854 return False;
1857 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1858 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1859 return False;
1863 for (i = 0; i < num_entries; i++) {
1864 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1865 return False;
1868 for (i = 0; i < num_entries; i++) {
1869 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1870 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1871 return False;
1874 return True;
1877 /*******************************************************************
1878 inits a SAM_DISPINFO_5 structure.
1879 ********************************************************************/
1881 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1882 uint32 num_entries, uint32 start_idx,
1883 struct samr_displayentry *entries)
1885 uint32 len_sam_name;
1886 uint32 i;
1888 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1890 if (num_entries==0)
1891 return NT_STATUS_OK;
1893 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1894 if (*sam == NULL)
1895 return NT_STATUS_NO_MEMORY;
1897 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1898 return NT_STATUS_NO_MEMORY;
1900 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
1901 return NT_STATUS_NO_MEMORY;
1903 for (i = 0; i < num_entries; i++) {
1904 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
1906 len_sam_name = strlen(entries[i].account_name);
1908 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
1909 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
1910 len_sam_name+1, len_sam_name);
1913 return NT_STATUS_OK;
1916 /*******************************************************************
1917 reads or writes a structure.
1918 ********************************************************************/
1920 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
1921 uint32 num_entries,
1922 prs_struct *ps, int depth)
1924 uint32 i;
1926 if (sam == NULL)
1927 return False;
1929 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
1930 depth++;
1932 if(!prs_align(ps))
1933 return False;
1935 if (UNMARSHALLING(ps) && num_entries > 0) {
1937 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
1938 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1939 return False;
1942 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
1943 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1944 return False;
1948 for (i = 0; i < num_entries; i++) {
1949 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
1950 return False;
1953 for (i = 0; i < num_entries; i++) {
1954 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
1955 sam->sam[i].hdr_grp_name.buffer, ps, depth))
1956 return False;
1959 return True;
1962 /*******************************************************************
1963 inits a SAMR_R_QUERY_DISPINFO structure.
1964 ********************************************************************/
1966 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
1967 uint32 num_entries, uint32 total_size, uint32 data_size,
1968 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
1969 NTSTATUS status)
1971 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
1973 r_u->total_size = total_size;
1975 r_u->data_size = data_size;
1977 r_u->switch_level = switch_level;
1978 r_u->num_entries = num_entries;
1980 if (num_entries==0)
1981 r_u->ptr_entries = 0;
1982 else
1983 r_u->ptr_entries = 1;
1985 r_u->num_entries2 = num_entries;
1986 r_u->ctr = ctr;
1988 r_u->status = status;
1991 /*******************************************************************
1992 reads or writes a structure.
1993 ********************************************************************/
1995 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
1996 prs_struct *ps, int depth)
1998 if (r_u == NULL)
1999 return False;
2001 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2002 depth++;
2004 if(!prs_align(ps))
2005 return False;
2007 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2008 return False;
2009 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2010 return False;
2011 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2012 return False;
2013 if(!prs_align(ps))
2014 return False;
2016 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2017 return False;
2018 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2019 return False;
2021 if (r_u->ptr_entries==0) {
2022 if(!prs_align(ps))
2023 return False;
2024 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2025 return False;
2027 return True;
2030 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2031 return False;
2033 switch (r_u->switch_level) {
2034 case 0x1:
2035 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2036 r_u->num_entries, ps, depth))
2037 return False;
2038 break;
2039 case 0x2:
2040 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2041 r_u->num_entries, ps, depth))
2042 return False;
2043 break;
2044 case 0x3:
2045 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2046 r_u->num_entries, ps, depth))
2047 return False;
2048 break;
2049 case 0x4:
2050 if(!sam_io_sam_dispinfo_4("user list",
2051 r_u->ctr->sam.info4,
2052 r_u->num_entries, ps, depth))
2053 return False;
2054 break;
2055 case 0x5:
2056 if(!sam_io_sam_dispinfo_5("group list",
2057 r_u->ctr->sam.info5,
2058 r_u->num_entries, ps, depth))
2059 return False;
2060 break;
2061 default:
2062 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2063 break;
2066 if(!prs_align(ps))
2067 return False;
2068 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2069 return False;
2071 return True;
2074 /*******************************************************************
2075 inits a SAMR_Q_OPEN_GROUP structure.
2076 ********************************************************************/
2078 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2079 POLICY_HND *hnd,
2080 uint32 access_mask, uint32 rid)
2082 DEBUG(5, ("init_samr_q_open_group\n"));
2084 q_c->domain_pol = *hnd;
2085 q_c->access_mask = access_mask;
2086 q_c->rid_group = rid;
2089 /*******************************************************************
2090 reads or writes a structure.
2091 ********************************************************************/
2093 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2094 prs_struct *ps, int depth)
2096 if (q_u == NULL)
2097 return False;
2099 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2100 depth++;
2102 if(!prs_align(ps))
2103 return False;
2105 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2106 return False;
2108 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2109 return False;
2110 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2111 return False;
2113 return True;
2116 /*******************************************************************
2117 reads or writes a structure.
2118 ********************************************************************/
2120 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2121 prs_struct *ps, int depth)
2123 if (r_u == NULL)
2124 return False;
2126 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2127 depth++;
2129 if(!prs_align(ps))
2130 return False;
2132 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2133 return False;
2135 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2136 return False;
2138 return True;
2141 /*******************************************************************
2142 inits a GROUP_INFO1 structure.
2143 ********************************************************************/
2145 void init_samr_group_info1(GROUP_INFO1 * gr1,
2146 char *acct_name, char *acct_desc,
2147 uint32 num_members)
2149 DEBUG(5, ("init_samr_group_info1\n"));
2151 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2152 gr1->num_members = num_members;
2154 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2155 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2156 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2157 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2160 /*******************************************************************
2161 reads or writes a structure.
2162 ********************************************************************/
2164 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2165 prs_struct *ps, int depth)
2167 uint16 dummy = 1;
2169 if (gr1 == NULL)
2170 return False;
2172 prs_debug(ps, depth, desc, "samr_io_group_info1");
2173 depth++;
2175 if(!prs_uint16("level", ps, depth, &dummy))
2176 return False;
2178 if(!prs_align(ps))
2179 return False;
2181 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2182 return False;
2184 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2185 return False;
2186 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2187 return False;
2189 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2190 return False;
2192 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2193 gr1->hdr_acct_name.buffer, ps, depth))
2194 return False;
2196 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2197 gr1->hdr_acct_desc.buffer, ps, depth))
2198 return False;
2200 return True;
2203 /*******************************************************************
2204 inits a GROUP_INFO2 structure.
2205 ********************************************************************/
2207 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2209 DEBUG(5, ("init_samr_group_info2\n"));
2211 gr2->level = 2;
2212 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2213 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2216 /*******************************************************************
2217 reads or writes a structure.
2218 ********************************************************************/
2220 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2222 if (gr2 == NULL)
2223 return False;
2225 prs_debug(ps, depth, desc, "samr_io_group_info2");
2226 depth++;
2228 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2229 return False;
2231 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2232 return False;
2233 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2234 gr2->hdr_acct_name.buffer, ps, depth))
2235 return False;
2237 return True;
2240 /*******************************************************************
2241 inits a GROUP_INFO3 structure.
2242 ********************************************************************/
2244 void init_samr_group_info3(GROUP_INFO3 *gr3)
2246 DEBUG(5, ("init_samr_group_info3\n"));
2248 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2251 /*******************************************************************
2252 reads or writes a structure.
2253 ********************************************************************/
2255 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2257 if (gr3 == NULL)
2258 return False;
2260 prs_debug(ps, depth, desc, "samr_io_group_info3");
2261 depth++;
2263 if(!prs_align(ps))
2264 return False;
2266 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2267 return False;
2269 return True;
2272 /*******************************************************************
2273 inits a GROUP_INFO4 structure.
2274 ********************************************************************/
2276 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2278 DEBUG(5, ("init_samr_group_info4\n"));
2280 gr4->level = 4;
2281 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2282 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2285 /*******************************************************************
2286 reads or writes a structure.
2287 ********************************************************************/
2289 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2290 prs_struct *ps, int depth)
2292 if (gr4 == NULL)
2293 return False;
2295 prs_debug(ps, depth, desc, "samr_io_group_info4");
2296 depth++;
2298 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2299 return False;
2300 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2301 return False;
2302 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2303 gr4->hdr_acct_desc.buffer, ps, depth))
2304 return False;
2306 return True;
2309 /*******************************************************************
2310 inits a GROUP_INFO5 structure.
2311 ********************************************************************/
2313 void init_samr_group_info5(GROUP_INFO5 * gr5,
2314 char *acct_name, char *acct_desc,
2315 uint32 num_members)
2317 DEBUG(5, ("init_samr_group_info5\n"));
2319 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2320 gr5->num_members = num_members;
2322 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2323 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2324 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2325 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2328 /*******************************************************************
2329 reads or writes a structure.
2330 ********************************************************************/
2332 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2333 prs_struct *ps, int depth)
2335 uint16 dummy = 1;
2337 if (gr5 == NULL)
2338 return False;
2340 prs_debug(ps, depth, desc, "samr_io_group_info5");
2341 depth++;
2343 if(!prs_uint16("level", ps, depth, &dummy))
2344 return False;
2346 if(!prs_align(ps))
2347 return False;
2349 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2350 return False;
2352 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2353 return False;
2354 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2355 return False;
2357 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2358 return False;
2360 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2361 gr5->hdr_acct_name.buffer, ps, depth))
2362 return False;
2364 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2365 gr5->hdr_acct_desc.buffer, ps, depth))
2366 return False;
2368 return True;
2372 /*******************************************************************
2373 reads or writes a structure.
2374 ********************************************************************/
2376 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2377 prs_struct *ps, int depth)
2379 if (UNMARSHALLING(ps))
2380 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2382 if (*ctr == NULL)
2383 return False;
2385 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2386 depth++;
2388 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2389 return False;
2391 switch ((*ctr)->switch_value1) {
2392 case 1:
2393 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2394 return False;
2395 break;
2396 case 2:
2397 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2398 return False;
2399 break;
2400 case 3:
2401 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2402 return False;
2403 break;
2404 case 4:
2405 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2406 return False;
2407 break;
2408 case 5:
2409 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2410 return False;
2411 break;
2412 default:
2413 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2414 break;
2417 return True;
2420 /*******************************************************************
2421 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2422 ********************************************************************/
2424 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2425 POLICY_HND *pol, const char *acct_desc,
2426 uint32 access_mask)
2428 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2430 q_e->pol = *pol;
2432 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2433 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2435 q_e->access_mask = access_mask;
2438 /*******************************************************************
2439 reads or writes a structure.
2440 ********************************************************************/
2442 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2443 prs_struct *ps, int depth)
2445 if (q_e == NULL)
2446 return False;
2448 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2449 depth++;
2451 if(!prs_align(ps))
2452 return False;
2454 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2455 return False;
2457 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2458 return False;
2459 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2460 q_e->hdr_acct_desc.buffer, ps, depth))
2461 return False;
2463 if(!prs_align(ps))
2464 return False;
2465 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2466 return False;
2468 return True;
2471 /*******************************************************************
2472 reads or writes a structure.
2473 ********************************************************************/
2475 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2476 prs_struct *ps, int depth)
2478 if (r_u == NULL)
2479 return False;
2481 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2482 depth++;
2484 if(!prs_align(ps))
2485 return False;
2487 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2488 return False;
2490 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2491 return False;
2492 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2493 return False;
2495 return True;
2498 /*******************************************************************
2499 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2500 ********************************************************************/
2502 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2503 POLICY_HND *hnd)
2505 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2507 q_c->group_pol = *hnd;
2510 /*******************************************************************
2511 reads or writes a structure.
2512 ********************************************************************/
2514 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2515 prs_struct *ps, int depth)
2517 if (q_u == NULL)
2518 return False;
2520 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2521 depth++;
2523 if(!prs_align(ps))
2524 return False;
2526 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2527 return False;
2529 return True;
2532 /*******************************************************************
2533 reads or writes a structure.
2534 ********************************************************************/
2536 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2537 prs_struct *ps, int depth)
2539 if (r_u == NULL)
2540 return False;
2542 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2543 depth++;
2545 if(!prs_align(ps))
2546 return False;
2548 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2549 return False;
2551 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2552 return False;
2554 return True;
2557 /*******************************************************************
2558 inits a SAMR_Q_DEL_GROUPMEM structure.
2559 ********************************************************************/
2561 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2562 POLICY_HND *pol, uint32 rid)
2564 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2566 q_e->pol = *pol;
2567 q_e->rid = rid;
2570 /*******************************************************************
2571 reads or writes a structure.
2572 ********************************************************************/
2574 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2575 prs_struct *ps, int depth)
2577 if (q_e == NULL)
2578 return False;
2580 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2581 depth++;
2583 if(!prs_align(ps))
2584 return False;
2586 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2587 return False;
2589 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2590 return False;
2592 return True;
2595 /*******************************************************************
2596 inits a SAMR_R_DEL_GROUPMEM structure.
2597 ********************************************************************/
2599 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2600 NTSTATUS status)
2602 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2604 r_u->status = status;
2607 /*******************************************************************
2608 reads or writes a structure.
2609 ********************************************************************/
2611 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2612 prs_struct *ps, int depth)
2614 if (r_u == NULL)
2615 return False;
2617 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2618 depth++;
2620 if(!prs_align(ps))
2621 return False;
2623 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2624 return False;
2626 return True;
2629 /*******************************************************************
2630 inits a SAMR_Q_ADD_GROUPMEM structure.
2631 ********************************************************************/
2633 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2634 POLICY_HND *pol, uint32 rid)
2636 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2638 q_e->pol = *pol;
2639 q_e->rid = rid;
2640 q_e->unknown = 0x0005;
2643 /*******************************************************************
2644 reads or writes a structure.
2645 ********************************************************************/
2647 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2648 prs_struct *ps, int depth)
2650 if (q_e == NULL)
2651 return False;
2653 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2654 depth++;
2656 if(!prs_align(ps))
2657 return False;
2659 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2660 return False;
2662 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2663 return False;
2664 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2665 return False;
2667 return True;
2670 /*******************************************************************
2671 inits a SAMR_R_ADD_GROUPMEM structure.
2672 ********************************************************************/
2674 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2675 NTSTATUS status)
2677 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2679 r_u->status = status;
2682 /*******************************************************************
2683 reads or writes a structure.
2684 ********************************************************************/
2686 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2687 prs_struct *ps, int depth)
2689 if (r_u == NULL)
2690 return False;
2692 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2693 depth++;
2695 if(!prs_align(ps))
2696 return False;
2698 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2699 return False;
2701 return True;
2704 /*******************************************************************
2705 inits a SAMR_Q_SET_GROUPINFO structure.
2706 ********************************************************************/
2708 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2709 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2711 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2713 q_e->pol = *pol;
2714 q_e->ctr = ctr;
2717 /*******************************************************************
2718 reads or writes a structure.
2719 ********************************************************************/
2721 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2722 prs_struct *ps, int depth)
2724 if (q_e == NULL)
2725 return False;
2727 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2728 depth++;
2730 if(!prs_align(ps))
2731 return False;
2733 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2734 return False;
2736 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2737 return False;
2739 return True;
2742 /*******************************************************************
2743 inits a SAMR_R_SET_GROUPINFO structure.
2744 ********************************************************************/
2746 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2748 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2750 r_u->status = status;
2753 /*******************************************************************
2754 reads or writes a structure.
2755 ********************************************************************/
2757 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2758 prs_struct *ps, int depth)
2760 if (r_u == NULL)
2761 return False;
2763 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2764 depth++;
2766 if(!prs_align(ps))
2767 return False;
2769 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2770 return False;
2772 return True;
2775 /*******************************************************************
2776 inits a SAMR_Q_QUERY_GROUPINFO structure.
2777 ********************************************************************/
2779 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2780 POLICY_HND *pol, uint16 switch_level)
2782 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2784 q_e->pol = *pol;
2786 q_e->switch_level = switch_level;
2789 /*******************************************************************
2790 reads or writes a structure.
2791 ********************************************************************/
2793 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2794 prs_struct *ps, int depth)
2796 if (q_e == NULL)
2797 return False;
2799 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2800 depth++;
2802 if(!prs_align(ps))
2803 return False;
2805 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2806 return False;
2808 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2809 return False;
2811 return True;
2814 /*******************************************************************
2815 inits a SAMR_R_QUERY_GROUPINFO structure.
2816 ********************************************************************/
2818 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2819 GROUP_INFO_CTR * ctr, NTSTATUS status)
2821 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2823 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2824 r_u->ctr = ctr;
2825 r_u->status = status;
2828 /*******************************************************************
2829 reads or writes a structure.
2830 ********************************************************************/
2832 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2833 prs_struct *ps, int depth)
2835 if (r_u == NULL)
2836 return False;
2838 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2839 depth++;
2841 if(!prs_align(ps))
2842 return False;
2844 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2845 return False;
2847 if (r_u->ptr != 0) {
2848 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2849 return False;
2852 if(!prs_align(ps))
2853 return False;
2854 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2855 return False;
2857 return True;
2860 /*******************************************************************
2861 inits a SAMR_Q_QUERY_GROUPMEM structure.
2862 ********************************************************************/
2864 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2866 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2868 q_c->group_pol = *hnd;
2871 /*******************************************************************
2872 reads or writes a structure.
2873 ********************************************************************/
2875 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2876 prs_struct *ps, int depth)
2878 if (q_u == NULL)
2879 return False;
2881 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2882 depth++;
2884 if(!prs_align(ps))
2885 return False;
2887 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2888 return False;
2890 return True;
2893 /*******************************************************************
2894 inits a SAMR_R_QUERY_GROUPMEM structure.
2895 ********************************************************************/
2897 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2898 uint32 num_entries, uint32 *rid,
2899 uint32 *attr, NTSTATUS status)
2901 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2903 if (NT_STATUS_IS_OK(status)) {
2904 r_u->ptr = 1;
2905 r_u->num_entries = num_entries;
2907 r_u->ptr_attrs = attr != NULL ? 1 : 0;
2908 r_u->ptr_rids = rid != NULL ? 1 : 0;
2910 r_u->num_rids = num_entries;
2911 r_u->rid = rid;
2913 r_u->num_attrs = num_entries;
2914 r_u->attr = attr;
2915 } else {
2916 r_u->ptr = 0;
2917 r_u->num_entries = 0;
2920 r_u->status = status;
2923 /*******************************************************************
2924 reads or writes a structure.
2925 ********************************************************************/
2927 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
2928 prs_struct *ps, int depth)
2930 uint32 i;
2932 if (r_u == NULL)
2933 return False;
2935 if (UNMARSHALLING(ps))
2936 ZERO_STRUCTP(r_u);
2938 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
2939 depth++;
2941 if(!prs_align(ps))
2942 return False;
2944 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2945 return False;
2946 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2947 return False;
2949 if (r_u->ptr != 0) {
2950 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
2951 return False;
2952 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
2953 return False;
2955 if (r_u->ptr_rids != 0) {
2956 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
2957 return False;
2958 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
2959 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
2960 if (r_u->rid == NULL)
2961 return False;
2964 for (i = 0; i < r_u->num_rids; i++) {
2965 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
2966 return False;
2970 if (r_u->ptr_attrs != 0) {
2971 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
2972 return False;
2974 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
2975 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
2976 if (r_u->attr == NULL)
2977 return False;
2980 for (i = 0; i < r_u->num_attrs; i++) {
2981 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
2982 return False;
2987 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2988 return False;
2990 return True;
2993 /*******************************************************************
2994 inits a SAMR_Q_QUERY_USERGROUPS structure.
2995 ********************************************************************/
2997 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
2998 POLICY_HND *hnd)
3000 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3002 q_u->pol = *hnd;
3005 /*******************************************************************
3006 reads or writes a structure.
3007 ********************************************************************/
3009 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3010 prs_struct *ps, int depth)
3012 if (q_u == NULL)
3013 return False;
3015 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3016 depth++;
3018 if(!prs_align(ps))
3019 return False;
3021 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3022 return False;
3024 return True;
3027 /*******************************************************************
3028 inits a SAMR_R_QUERY_USERGROUPS structure.
3029 ********************************************************************/
3031 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3032 uint32 num_gids, DOM_GID * gid,
3033 NTSTATUS status)
3035 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3037 if (NT_STATUS_IS_OK(status)) {
3038 r_u->ptr_0 = 1;
3039 r_u->num_entries = num_gids;
3040 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3041 r_u->num_entries2 = num_gids;
3043 r_u->gid = gid;
3044 } else {
3045 r_u->ptr_0 = 0;
3046 r_u->num_entries = 0;
3047 r_u->ptr_1 = 0;
3048 r_u->gid = NULL;
3051 r_u->status = status;
3054 /*******************************************************************
3055 reads or writes a structure.
3056 ********************************************************************/
3058 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3059 prs_struct *ps, int depth)
3061 uint32 i;
3062 if (gid == NULL)
3063 return False;
3065 prs_debug(ps, depth, desc, "samr_io_gids");
3066 depth++;
3068 if(!prs_align(ps))
3069 return False;
3071 if(!prs_uint32("num_gids", ps, depth, num_gids))
3072 return False;
3074 if ((*num_gids) != 0) {
3075 if (UNMARSHALLING(ps)) {
3076 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3079 if ((*gid) == NULL) {
3080 return False;
3083 for (i = 0; i < (*num_gids); i++) {
3084 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3085 return False;
3089 return True;
3092 /*******************************************************************
3093 reads or writes a structure.
3094 ********************************************************************/
3096 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3097 prs_struct *ps, int depth)
3099 if (r_u == NULL)
3100 return False;
3102 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3103 depth++;
3105 if(!prs_align(ps))
3106 return False;
3108 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3109 return False;
3111 if (r_u->ptr_0 != 0) {
3112 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3113 return False;
3114 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3115 return False;
3117 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3118 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3119 return False;
3123 if(!prs_align(ps))
3124 return False;
3125 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3126 return False;
3128 return True;
3131 /*******************************************************************
3132 inits a SAMR_Q_ENUM_DOMAINS structure.
3133 ********************************************************************/
3135 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3136 POLICY_HND *pol,
3137 uint32 start_idx, uint32 size)
3139 DEBUG(5, ("init_samr_q_enum_domains\n"));
3141 q_e->pol = *pol;
3143 q_e->start_idx = start_idx;
3144 q_e->max_size = size;
3147 /*******************************************************************
3148 reads or writes a structure.
3149 ********************************************************************/
3151 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3152 prs_struct *ps, int depth)
3154 if (q_e == NULL)
3155 return False;
3157 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3158 depth++;
3160 if(!prs_align(ps))
3161 return False;
3163 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3164 return False;
3166 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3167 return False;
3168 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3169 return False;
3171 return True;
3174 /*******************************************************************
3175 inits a SAMR_R_ENUM_DOMAINS structure.
3176 ********************************************************************/
3178 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3179 uint32 next_idx, uint32 num_sam_entries)
3181 DEBUG(5, ("init_samr_r_enum_domains\n"));
3183 r_u->next_idx = next_idx;
3185 if (num_sam_entries != 0) {
3186 r_u->ptr_entries1 = 1;
3187 r_u->ptr_entries2 = 1;
3188 r_u->num_entries2 = num_sam_entries;
3189 r_u->num_entries3 = num_sam_entries;
3191 r_u->num_entries4 = num_sam_entries;
3192 } else {
3193 r_u->ptr_entries1 = 0;
3194 r_u->num_entries2 = num_sam_entries;
3195 r_u->ptr_entries2 = 1;
3199 /*******************************************************************
3200 reads or writes a structure.
3201 ********************************************************************/
3203 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3204 prs_struct *ps, int depth)
3206 uint32 i;
3208 if (r_u == NULL)
3209 return False;
3211 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3212 depth++;
3214 if(!prs_align(ps))
3215 return False;
3217 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3218 return False;
3219 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3220 return False;
3222 if (r_u->ptr_entries1 != 0) {
3223 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3224 return False;
3225 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3226 return False;
3227 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3228 return False;
3230 if (UNMARSHALLING(ps)) {
3231 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3232 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3235 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3236 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3237 r_u->num_entries4 = 0;
3238 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3239 return False;
3242 for (i = 0; i < r_u->num_entries2; i++) {
3243 fstring tmp;
3244 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3245 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3246 return False;
3249 for (i = 0; i < r_u->num_entries2; i++) {
3250 fstring tmp;
3251 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3252 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3253 r_u->sam[i].hdr_name.buffer, ps,
3254 depth))
3255 return False;
3260 if(!prs_align(ps))
3261 return False;
3262 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3263 return False;
3264 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3265 return False;
3267 return True;
3270 /*******************************************************************
3271 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3272 ********************************************************************/
3274 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3275 POLICY_HND *pol,
3276 uint32 start_idx, uint32 size)
3278 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3280 q_e->pol = *pol;
3282 q_e->start_idx = start_idx;
3283 q_e->max_size = size;
3286 /*******************************************************************
3287 reads or writes a structure.
3288 ********************************************************************/
3290 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3291 prs_struct *ps, int depth)
3293 if (q_e == NULL)
3294 return False;
3296 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3297 depth++;
3299 if(!prs_align(ps))
3300 return False;
3302 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3303 return False;
3305 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3306 return False;
3307 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3308 return False;
3310 return True;
3313 /*******************************************************************
3314 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3315 ********************************************************************/
3317 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3318 uint32 next_idx, uint32 num_sam_entries)
3320 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3322 r_u->next_idx = next_idx;
3324 if (num_sam_entries != 0) {
3325 r_u->ptr_entries1 = 1;
3326 r_u->ptr_entries2 = 1;
3327 r_u->num_entries2 = num_sam_entries;
3328 r_u->num_entries3 = num_sam_entries;
3330 r_u->num_entries4 = num_sam_entries;
3331 } else {
3332 r_u->ptr_entries1 = 0;
3333 r_u->num_entries2 = num_sam_entries;
3334 r_u->ptr_entries2 = 1;
3338 /*******************************************************************
3339 reads or writes a structure.
3340 ********************************************************************/
3342 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3343 prs_struct *ps, int depth)
3345 uint32 i;
3347 if (r_u == NULL)
3348 return False;
3350 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3351 depth++;
3353 if(!prs_align(ps))
3354 return False;
3356 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3357 return False;
3358 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3359 return False;
3361 if (r_u->ptr_entries1 != 0) {
3362 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3363 return False;
3364 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3365 return False;
3366 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3367 return False;
3369 if (UNMARSHALLING(ps)) {
3370 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3371 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3374 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3375 DEBUG(0,
3376 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3377 r_u->num_entries4 = 0;
3378 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3379 return False;
3382 for (i = 0; i < r_u->num_entries2; i++) {
3383 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3384 return False;
3387 for (i = 0; i < r_u->num_entries2; i++) {
3388 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3389 r_u->sam[i].hdr_name.buffer, ps, depth))
3390 return False;
3394 if(!prs_align(ps))
3395 return False;
3396 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3397 return False;
3398 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3399 return False;
3401 return True;
3404 /*******************************************************************
3405 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3406 ********************************************************************/
3408 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3409 POLICY_HND *pol, uint32 start_idx,
3410 uint32 size)
3412 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3414 q_e->pol = *pol;
3416 q_e->start_idx = start_idx;
3417 q_e->max_size = size;
3421 /*******************************************************************
3422 reads or writes a structure.
3423 ********************************************************************/
3425 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3426 prs_struct *ps, int depth)
3428 if (q_e == NULL)
3429 return False;
3431 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3432 depth++;
3434 if(!prs_align(ps))
3435 return False;
3437 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3438 return False;
3440 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3441 return False;
3442 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3443 return False;
3445 return True;
3448 /*******************************************************************
3449 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3450 ********************************************************************/
3452 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3454 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3456 r_u->next_idx = next_idx;
3458 if (num_sam_entries != 0) {
3459 r_u->ptr_entries1 = 1;
3460 r_u->ptr_entries2 = 1;
3461 r_u->num_entries2 = num_sam_entries;
3462 r_u->num_entries3 = num_sam_entries;
3464 r_u->num_entries4 = num_sam_entries;
3465 } else {
3466 r_u->ptr_entries1 = 0;
3467 r_u->num_entries2 = num_sam_entries;
3468 r_u->ptr_entries2 = 1;
3472 /*******************************************************************
3473 reads or writes a structure.
3474 ********************************************************************/
3476 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3477 prs_struct *ps, int depth)
3479 uint32 i;
3481 if (r_u == NULL)
3482 return False;
3484 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3485 depth++;
3487 if(!prs_align(ps))
3488 return False;
3490 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3491 return False;
3492 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3493 return False;
3495 if (r_u->ptr_entries1 != 0) {
3496 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3497 return False;
3498 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3499 return False;
3500 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3501 return False;
3503 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3504 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3505 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3508 if (r_u->num_entries2 != 0 &&
3509 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3510 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3511 r_u->num_entries4 = 0;
3512 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3513 return False;
3516 for (i = 0; i < r_u->num_entries2; i++) {
3517 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3518 return False;
3521 for (i = 0; i < r_u->num_entries2; i++) {
3522 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3523 r_u->sam[i].hdr_name.buffer, ps,
3524 depth))
3525 return False;
3529 if(!prs_align(ps))
3530 return False;
3531 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3532 return False;
3533 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3534 return False;
3536 return True;
3539 /*******************************************************************
3540 inits a ALIAS_INFO1 structure.
3541 ********************************************************************/
3543 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3545 DEBUG(5, ("init_samr_alias_info1\n"));
3547 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3548 al1->num_member = num_member;
3549 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3552 /*******************************************************************
3553 reads or writes a structure.
3554 ********************************************************************/
3556 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3557 prs_struct *ps, int depth)
3559 if (al1 == NULL)
3560 return False;
3562 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3563 depth++;
3565 if(!prs_align(ps))
3566 return False;
3568 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3569 return False;
3570 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3571 return False;
3572 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3573 return False;
3575 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3576 return False;
3577 if ( !prs_align(ps) )
3578 return False;
3579 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3580 return False;
3581 if ( !prs_align(ps) )
3582 return False;
3584 return True;
3587 /*******************************************************************
3588 inits a ALIAS_INFO3 structure.
3589 ********************************************************************/
3591 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3593 DEBUG(5, ("init_samr_alias_info3\n"));
3595 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3598 /*******************************************************************
3599 reads or writes a structure.
3600 ********************************************************************/
3602 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3603 prs_struct *ps, int depth)
3605 if (al3 == NULL)
3606 return False;
3608 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3609 depth++;
3611 if(!prs_align(ps))
3612 return False;
3614 if (!prs_unistr4("description", ps, depth, &al3->description))
3615 return False;
3617 return True;
3620 /*******************************************************************
3621 reads or writes a structure.
3622 ********************************************************************/
3624 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3625 prs_struct *ps, int depth)
3627 if (al2 == NULL)
3628 return False;
3630 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3631 depth++;
3633 if(!prs_align(ps))
3634 return False;
3636 if (!prs_unistr4("name", ps, depth, &al2->name))
3637 return False;
3639 return True;
3642 /*******************************************************************
3643 reads or writes a structure.
3644 ********************************************************************/
3646 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3648 if ( !ctr )
3649 return False;
3651 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3652 depth++;
3654 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3655 return False;
3657 if(!prs_align(ps))
3658 return False;
3659 switch (ctr->level) {
3660 case 1:
3661 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3662 return False;
3663 break;
3664 case 2:
3665 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3666 return False;
3667 break;
3668 case 3:
3669 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3670 return False;
3671 break;
3672 default:
3673 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3674 break;
3677 return True;
3680 /*******************************************************************
3681 inits a SAMR_Q_QUERY_ALIASINFO structure.
3682 ********************************************************************/
3684 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3685 POLICY_HND *pol, uint32 switch_level)
3687 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3689 q_e->pol = *pol;
3690 q_e->level = switch_level;
3693 /*******************************************************************
3694 reads or writes a structure.
3695 ********************************************************************/
3697 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3698 prs_struct *ps, int depth)
3700 if ( !in )
3701 return False;
3703 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3704 depth++;
3706 if(!prs_align(ps))
3707 return False;
3709 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3710 return False;
3712 if ( !prs_uint16("level", ps, depth, &in->level) )
3713 return False;
3715 return True;
3718 /*******************************************************************
3719 inits a SAMR_R_QUERY_ALIASINFO structure.
3720 ********************************************************************/
3722 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3723 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3725 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3727 out->ctr = ctr;
3728 out->status = status;
3731 /*******************************************************************
3732 reads or writes a structure.
3733 ********************************************************************/
3735 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3736 prs_struct *ps, int depth)
3738 if ( !out )
3739 return False;
3741 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3742 depth++;
3744 if(!prs_align(ps))
3745 return False;
3747 if ( !prs_pointer("alias", ps, depth, (void**)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3748 return False;
3749 if(!prs_align(ps))
3750 return False;
3752 if(!prs_ntstatus("status", ps, depth, &out->status))
3753 return False;
3755 return True;
3758 /*******************************************************************
3759 inits a SAMR_Q_SET_ALIASINFO structure.
3760 ********************************************************************/
3762 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3763 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3765 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3767 q_u->alias_pol = *hnd;
3768 q_u->ctr = *ctr;
3771 /*******************************************************************
3772 reads or writes a structure.
3773 ********************************************************************/
3775 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3776 prs_struct *ps, int depth)
3778 if (q_u == NULL)
3779 return False;
3781 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3782 depth++;
3784 if(!prs_align(ps))
3785 return False;
3787 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3788 return False;
3789 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3790 return False;
3792 return True;
3795 /*******************************************************************
3796 reads or writes a structure.
3797 ********************************************************************/
3799 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3800 prs_struct *ps, int depth)
3802 if (r_u == NULL)
3803 return False;
3805 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3806 depth++;
3808 if(!prs_align(ps))
3809 return False;
3810 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3811 return False;
3813 return True;
3816 /*******************************************************************
3817 inits a SAMR_Q_QUERY_USERALIASES structure.
3818 ********************************************************************/
3820 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3821 POLICY_HND *hnd,
3822 uint32 num_sids,
3823 uint32 *ptr_sid, DOM_SID2 * sid)
3825 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3827 q_u->pol = *hnd;
3829 q_u->num_sids1 = num_sids;
3830 q_u->ptr = 1;
3831 q_u->num_sids2 = num_sids;
3833 q_u->ptr_sid = ptr_sid;
3834 q_u->sid = sid;
3837 /*******************************************************************
3838 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3839 ********************************************************************/
3841 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3842 prs_struct *ps, int depth)
3844 fstring tmp;
3845 uint32 i;
3847 if (q_u == NULL)
3848 return False;
3850 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3851 depth++;
3853 if(!prs_align(ps))
3854 return False;
3856 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3857 return False;
3859 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3860 return False;
3861 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3862 return False;
3864 if (q_u->ptr==0)
3865 return True;
3867 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3868 return False;
3870 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3871 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3872 if (q_u->ptr_sid == NULL)
3873 return False;
3875 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3876 if (q_u->sid == NULL)
3877 return False;
3880 for (i = 0; i < q_u->num_sids2; i++) {
3881 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3882 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3883 return False;
3886 for (i = 0; i < q_u->num_sids2; i++) {
3887 if (q_u->ptr_sid[i] != 0) {
3888 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3889 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3890 return False;
3894 return True;
3897 /*******************************************************************
3898 inits a SAMR_R_QUERY_USERALIASES structure.
3899 ********************************************************************/
3901 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
3902 uint32 num_rids, uint32 *rid,
3903 NTSTATUS status)
3905 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3907 if (NT_STATUS_IS_OK(status)) {
3908 r_u->num_entries = num_rids;
3909 r_u->ptr = 1;
3910 r_u->num_entries2 = num_rids;
3912 r_u->rid = rid;
3913 } else {
3914 r_u->num_entries = 0;
3915 r_u->ptr = 0;
3916 r_u->num_entries2 = 0;
3919 r_u->status = status;
3922 /*******************************************************************
3923 reads or writes a structure.
3924 ********************************************************************/
3926 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
3927 prs_struct *ps, int depth)
3929 fstring tmp;
3930 uint32 i;
3931 if (rid == NULL)
3932 return False;
3934 prs_debug(ps, depth, desc, "samr_io_rids");
3935 depth++;
3937 if(!prs_align(ps))
3938 return False;
3940 if(!prs_uint32("num_rids", ps, depth, num_rids))
3941 return False;
3943 if ((*num_rids) != 0) {
3944 if (UNMARSHALLING(ps)) {
3945 /* reading */
3946 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
3948 if ((*rid) == NULL)
3949 return False;
3951 for (i = 0; i < (*num_rids); i++) {
3952 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
3953 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
3954 return False;
3958 return True;
3961 /*******************************************************************
3962 reads or writes a structure.
3963 ********************************************************************/
3965 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
3966 prs_struct *ps, int depth)
3968 if (r_u == NULL)
3969 return False;
3971 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
3972 depth++;
3974 if(!prs_align(ps))
3975 return False;
3977 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
3978 return False;
3979 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
3980 return False;
3982 if (r_u->ptr != 0) {
3983 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
3984 return False;
3987 if(!prs_align(ps))
3988 return False;
3989 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3990 return False;
3992 return True;
3995 /*******************************************************************
3996 inits a SAMR_Q_OPEN_ALIAS structure.
3997 ********************************************************************/
3999 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4000 uint32 access_mask, uint32 rid)
4002 DEBUG(5, ("init_samr_q_open_alias\n"));
4004 q_u->dom_pol = *pol;
4005 q_u->access_mask = access_mask;
4006 q_u->rid_alias = rid;
4009 /*******************************************************************
4010 reads or writes a structure.
4011 ********************************************************************/
4013 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4014 prs_struct *ps, int depth)
4016 if (q_u == NULL)
4017 return False;
4019 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4020 depth++;
4022 if(!prs_align(ps))
4023 return False;
4025 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4026 return False;
4028 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4029 return False;
4030 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4031 return False;
4033 return True;
4036 /*******************************************************************
4037 reads or writes a structure.
4038 ********************************************************************/
4040 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4041 prs_struct *ps, int depth)
4043 if (r_u == NULL)
4044 return False;
4046 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4047 depth++;
4049 if(!prs_align(ps))
4050 return False;
4052 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4053 return False;
4055 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4056 return False;
4058 return True;
4061 /*******************************************************************
4062 inits a SAMR_Q_LOOKUP_RIDS structure.
4063 ********************************************************************/
4065 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4066 POLICY_HND *pol, uint32 flags,
4067 uint32 num_rids, uint32 *rid)
4069 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4071 q_u->pol = *pol;
4073 q_u->num_rids1 = num_rids;
4074 q_u->flags = flags;
4075 q_u->ptr = 0;
4076 q_u->num_rids2 = num_rids;
4077 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4078 if (q_u->rid == NULL) {
4079 q_u->num_rids1 = 0;
4080 q_u->num_rids2 = 0;
4081 } else {
4082 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4086 /*******************************************************************
4087 reads or writes a structure.
4088 ********************************************************************/
4090 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4091 prs_struct *ps, int depth)
4093 uint32 i;
4094 fstring tmp;
4096 if (q_u == NULL)
4097 return False;
4099 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4100 depth++;
4102 if (UNMARSHALLING(ps))
4103 ZERO_STRUCTP(q_u);
4105 if(!prs_align(ps))
4106 return False;
4108 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4109 return False;
4111 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4112 return False;
4113 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4114 return False;
4115 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4116 return False;
4117 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4118 return False;
4120 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4121 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4122 if (q_u->rid == NULL)
4123 return False;
4126 for (i = 0; i < q_u->num_rids2; i++) {
4127 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4128 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4129 return False;
4132 return True;
4135 /*******************************************************************
4136 inits a SAMR_R_LOOKUP_RIDS structure.
4137 ********************************************************************/
4139 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4140 uint32 num_names, UNIHDR * hdr_name,
4141 UNISTR2 *uni_name, uint32 *type)
4143 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4145 r_u->hdr_name = NULL;
4146 r_u->uni_name = NULL;
4147 r_u->type = NULL;
4149 if (num_names != 0) {
4150 r_u->num_names1 = num_names;
4151 r_u->ptr_names = 1;
4152 r_u->num_names2 = num_names;
4154 r_u->num_types1 = num_names;
4155 r_u->ptr_types = 1;
4156 r_u->num_types2 = num_names;
4158 r_u->hdr_name = hdr_name;
4159 r_u->uni_name = uni_name;
4160 r_u->type = type;
4161 } else {
4162 r_u->num_names1 = num_names;
4163 r_u->ptr_names = 0;
4164 r_u->num_names2 = num_names;
4166 r_u->num_types1 = num_names;
4167 r_u->ptr_types = 0;
4168 r_u->num_types2 = num_names;
4172 /*******************************************************************
4173 reads or writes a structure.
4174 ********************************************************************/
4176 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4177 prs_struct *ps, int depth)
4179 uint32 i;
4180 fstring tmp;
4181 if (r_u == NULL)
4182 return False;
4184 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4185 depth++;
4187 if(!prs_align(ps))
4188 return False;
4190 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4191 return False;
4192 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4193 return False;
4195 if (r_u->ptr_names != 0) {
4197 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4198 return False;
4201 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4202 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4203 if (r_u->hdr_name == NULL)
4204 return False;
4206 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4207 if (r_u->uni_name == NULL)
4208 return False;
4211 for (i = 0; i < r_u->num_names2; i++) {
4212 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4213 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4214 return False;
4216 for (i = 0; i < r_u->num_names2; i++) {
4217 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4218 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4219 return False;
4224 if(!prs_align(ps))
4225 return False;
4226 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4227 return False;
4228 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4229 return False;
4231 if (r_u->ptr_types != 0) {
4233 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4234 return False;
4236 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4237 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4238 if (r_u->type == NULL)
4239 return False;
4242 for (i = 0; i < r_u->num_types2; i++) {
4243 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4244 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4245 return False;
4249 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4250 return False;
4252 return True;
4255 /*******************************************************************
4256 inits a SAMR_Q_OPEN_ALIAS structure.
4257 ********************************************************************/
4259 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4261 DEBUG(5, ("init_samr_q_delete_alias\n"));
4263 q_u->alias_pol = *hnd;
4266 /*******************************************************************
4267 reads or writes a structure.
4268 ********************************************************************/
4270 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4271 prs_struct *ps, int depth)
4273 if (q_u == NULL)
4274 return False;
4276 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4277 depth++;
4279 if(!prs_align(ps))
4280 return False;
4282 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4283 return False;
4285 return True;
4288 /*******************************************************************
4289 reads or writes a structure.
4290 ********************************************************************/
4292 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4293 prs_struct *ps, int depth)
4295 if (r_u == NULL)
4296 return False;
4298 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4299 depth++;
4301 if(!prs_align(ps))
4302 return False;
4304 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4305 return False;
4306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4307 return False;
4309 return True;
4312 /*******************************************************************
4313 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4314 ********************************************************************/
4316 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4317 POLICY_HND *hnd, const char *acct_desc)
4319 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4321 q_u->dom_pol = *hnd;
4323 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4324 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4326 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4329 /*******************************************************************
4330 reads or writes a structure.
4331 ********************************************************************/
4333 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4334 prs_struct *ps, int depth)
4336 if (q_u == NULL)
4337 return False;
4339 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4340 depth++;
4342 if(!prs_align(ps))
4343 return False;
4345 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4346 return False;
4348 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4349 return False;
4350 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4351 q_u->hdr_acct_desc.buffer, ps, depth))
4352 return False;
4354 if(!prs_align(ps))
4355 return False;
4356 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4357 return False;
4359 return True;
4362 /*******************************************************************
4363 reads or writes a structure.
4364 ********************************************************************/
4366 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4367 prs_struct *ps, int depth)
4369 if (r_u == NULL)
4370 return False;
4372 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4373 depth++;
4375 if(!prs_align(ps))
4376 return False;
4378 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4379 return False;
4381 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4382 return False;
4384 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4385 return False;
4387 return True;
4390 /*******************************************************************
4391 inits a SAMR_Q_ADD_ALIASMEM structure.
4392 ********************************************************************/
4394 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4395 DOM_SID *sid)
4397 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4399 q_u->alias_pol = *hnd;
4400 init_dom_sid2(&q_u->sid, sid);
4403 /*******************************************************************
4404 reads or writes a structure.
4405 ********************************************************************/
4407 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4408 prs_struct *ps, int depth)
4410 if (q_u == NULL)
4411 return False;
4413 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4414 depth++;
4416 if(!prs_align(ps))
4417 return False;
4419 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4420 return False;
4421 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4422 return False;
4424 return True;
4427 /*******************************************************************
4428 reads or writes a structure.
4429 ********************************************************************/
4431 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4432 prs_struct *ps, int depth)
4434 if (r_u == NULL)
4435 return False;
4437 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4438 depth++;
4440 if(!prs_align(ps))
4441 return False;
4443 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4444 return False;
4446 return True;
4449 /*******************************************************************
4450 inits a SAMR_Q_DEL_ALIASMEM structure.
4451 ********************************************************************/
4453 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4454 DOM_SID *sid)
4456 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4458 q_u->alias_pol = *hnd;
4459 init_dom_sid2(&q_u->sid, sid);
4462 /*******************************************************************
4463 reads or writes a structure.
4464 ********************************************************************/
4466 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4467 prs_struct *ps, int depth)
4469 if (q_u == NULL)
4470 return False;
4472 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4473 depth++;
4475 if(!prs_align(ps))
4476 return False;
4478 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4479 return False;
4480 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4481 return False;
4483 return True;
4486 /*******************************************************************
4487 reads or writes a structure.
4488 ********************************************************************/
4490 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4491 prs_struct *ps, int depth)
4493 if (r_u == NULL)
4494 return False;
4496 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4497 depth++;
4499 if(!prs_align(ps))
4500 return False;
4502 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4503 return False;
4505 return True;
4508 /*******************************************************************
4509 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4510 ********************************************************************/
4512 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4513 POLICY_HND *hnd)
4515 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4517 q_c->alias_pol = *hnd;
4520 /*******************************************************************
4521 reads or writes a structure.
4522 ********************************************************************/
4524 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4525 prs_struct *ps, int depth)
4527 if (q_u == NULL)
4528 return False;
4530 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4531 depth++;
4533 if(!prs_align(ps))
4534 return False;
4536 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4537 return False;
4539 return True;
4542 /*******************************************************************
4543 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4544 ********************************************************************/
4546 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4547 NTSTATUS status)
4549 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4551 r_u->status = status;
4554 /*******************************************************************
4555 reads or writes a structure.
4556 ********************************************************************/
4558 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4559 prs_struct *ps, int depth)
4561 if (r_u == NULL)
4562 return False;
4564 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4565 depth++;
4567 if(!prs_align(ps))
4568 return False;
4570 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4571 return False;
4573 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4574 return False;
4576 return True;
4579 /*******************************************************************
4580 inits a SAMR_Q_QUERY_ALIASMEM structure.
4581 ********************************************************************/
4583 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4584 POLICY_HND *hnd)
4586 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4588 q_c->alias_pol = *hnd;
4591 /*******************************************************************
4592 reads or writes a structure.
4593 ********************************************************************/
4595 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4596 prs_struct *ps, int depth)
4598 if (q_u == NULL)
4599 return False;
4601 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4602 depth++;
4604 if(!prs_align(ps))
4605 return False;
4607 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4608 return False;
4610 return True;
4613 /*******************************************************************
4614 inits a SAMR_R_QUERY_ALIASMEM structure.
4615 ********************************************************************/
4617 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4618 uint32 num_sids, DOM_SID2 * sid,
4619 NTSTATUS status)
4621 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4623 if (NT_STATUS_IS_OK(status)) {
4624 r_u->num_sids = num_sids;
4625 r_u->ptr = (num_sids != 0) ? 1 : 0;
4626 r_u->num_sids1 = num_sids;
4628 r_u->sid = sid;
4629 } else {
4630 r_u->ptr = 0;
4631 r_u->num_sids = 0;
4634 r_u->status = status;
4637 /*******************************************************************
4638 reads or writes a structure.
4639 ********************************************************************/
4641 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4642 prs_struct *ps, int depth)
4644 uint32 i;
4646 if (r_u == NULL)
4647 return False;
4649 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4650 depth++;
4652 if(!prs_align(ps))
4653 return False;
4655 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4656 return False;
4657 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4658 return False;
4660 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4661 uint32 *ptr_sid = NULL;
4663 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4664 return False;
4666 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4667 if (!ptr_sid) {
4668 return False;
4671 for (i = 0; i < r_u->num_sids1; i++) {
4672 ptr_sid[i] = 1;
4673 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4674 return False;
4677 if (UNMARSHALLING(ps)) {
4678 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4681 for (i = 0; i < r_u->num_sids1; i++) {
4682 if (ptr_sid[i] != 0) {
4683 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4684 return False;
4689 if(!prs_align(ps))
4690 return False;
4691 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4692 return False;
4694 return True;
4697 /*******************************************************************
4698 inits a SAMR_Q_LOOKUP_NAMES structure.
4699 ********************************************************************/
4701 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4702 POLICY_HND *pol, uint32 flags,
4703 uint32 num_names, const char **name)
4705 uint32 i;
4707 DEBUG(5, ("init_samr_q_lookup_names\n"));
4709 q_u->pol = *pol;
4711 q_u->num_names1 = num_names;
4712 q_u->flags = flags;
4713 q_u->ptr = 0;
4714 q_u->num_names2 = num_names;
4716 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4717 return NT_STATUS_NO_MEMORY;
4719 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4720 return NT_STATUS_NO_MEMORY;
4722 for (i = 0; i < num_names; i++) {
4723 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4724 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4727 return NT_STATUS_OK;
4730 /*******************************************************************
4731 reads or writes a structure.
4732 ********************************************************************/
4734 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4735 prs_struct *ps, int depth)
4737 uint32 i;
4739 if (q_u == NULL)
4740 return False;
4742 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4743 depth++;
4745 if (UNMARSHALLING(ps))
4746 ZERO_STRUCTP(q_u);
4748 if(!prs_align(ps))
4749 return False;
4751 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4752 return False;
4754 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4755 return False;
4756 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4757 return False;
4758 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4759 return False;
4760 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4761 return False;
4763 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4764 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4765 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4766 if (!q_u->hdr_name || !q_u->uni_name)
4767 return False;
4770 for (i = 0; i < q_u->num_names2; i++) {
4771 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4772 return False;
4775 for (i = 0; i < q_u->num_names2; i++) {
4776 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4777 return False;
4780 return True;
4783 /*******************************************************************
4784 inits a SAMR_R_LOOKUP_NAMES structure.
4785 ********************************************************************/
4787 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4788 uint32 num_rids,
4789 uint32 *rid, uint32 *type,
4790 NTSTATUS status)
4792 DEBUG(5, ("init_samr_r_lookup_names\n"));
4794 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4795 uint32 i;
4797 r_u->num_types1 = num_rids;
4798 r_u->ptr_types = 1;
4799 r_u->num_types2 = num_rids;
4801 r_u->num_rids1 = num_rids;
4802 r_u->ptr_rids = 1;
4803 r_u->num_rids2 = num_rids;
4805 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4806 return NT_STATUS_NO_MEMORY;
4807 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4808 return NT_STATUS_NO_MEMORY;
4810 if (!r_u->rids || !r_u->types)
4811 goto empty;
4813 for (i = 0; i < num_rids; i++) {
4814 r_u->rids[i] = rid[i];
4815 r_u->types[i] = type[i];
4817 } else {
4819 empty:
4820 r_u->num_types1 = 0;
4821 r_u->ptr_types = 0;
4822 r_u->num_types2 = 0;
4824 r_u->num_rids1 = 0;
4825 r_u->ptr_rids = 0;
4826 r_u->num_rids2 = 0;
4828 r_u->rids = NULL;
4829 r_u->types = NULL;
4832 r_u->status = status;
4834 return NT_STATUS_OK;
4837 /*******************************************************************
4838 reads or writes a structure.
4839 ********************************************************************/
4841 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4842 prs_struct *ps, int depth)
4844 uint32 i;
4845 fstring tmp;
4847 if (r_u == NULL)
4848 return False;
4850 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4851 depth++;
4853 if (UNMARSHALLING(ps))
4854 ZERO_STRUCTP(r_u);
4856 if(!prs_align(ps))
4857 return False;
4859 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4860 return False;
4861 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4862 return False;
4864 if (r_u->ptr_rids != 0) {
4865 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4866 return False;
4868 if (r_u->num_rids2 != r_u->num_rids1) {
4869 /* RPC fault */
4870 return False;
4873 if (UNMARSHALLING(ps))
4874 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4876 if (!r_u->rids) {
4877 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4878 return False;
4881 for (i = 0; i < r_u->num_rids2; i++) {
4882 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4883 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4884 return False;
4888 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4889 return False;
4890 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4891 return False;
4893 if (r_u->ptr_types != 0) {
4894 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4895 return False;
4897 if (r_u->num_types2 != r_u->num_types1) {
4898 /* RPC fault */
4899 return False;
4902 if (UNMARSHALLING(ps))
4903 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4905 if (!r_u->types) {
4906 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4907 return False;
4910 for (i = 0; i < r_u->num_types2; i++) {
4911 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4912 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
4913 return False;
4917 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4918 return False;
4920 return True;
4923 /*******************************************************************
4924 inits a SAMR_Q_DELETE_DOM_USER structure.
4925 ********************************************************************/
4927 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
4928 POLICY_HND *hnd)
4930 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4932 q_c->user_pol = *hnd;
4935 /*******************************************************************
4936 reads or writes a structure.
4937 ********************************************************************/
4939 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
4940 prs_struct *ps, int depth)
4942 if (q_u == NULL)
4943 return False;
4945 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
4946 depth++;
4948 if(!prs_align(ps))
4949 return False;
4951 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
4952 return False;
4954 return True;
4957 /*******************************************************************
4958 reads or writes a structure.
4959 ********************************************************************/
4961 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
4962 prs_struct *ps, int depth)
4964 if (r_u == NULL)
4965 return False;
4967 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
4968 depth++;
4970 if(!prs_align(ps))
4971 return False;
4973 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4974 return False;
4975 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4976 return False;
4978 return True;
4981 /*******************************************************************
4982 reads or writes a structure.
4983 ********************************************************************/
4985 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
4986 POLICY_HND *pol,
4987 uint32 access_mask, uint32 rid)
4989 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4991 q_u->domain_pol = *pol;
4992 q_u->access_mask = access_mask;
4993 q_u->user_rid = rid;
4996 /*******************************************************************
4997 reads or writes a structure.
4998 ********************************************************************/
5000 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5001 prs_struct *ps, int depth)
5003 if (q_u == NULL)
5004 return False;
5006 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5007 depth++;
5009 if(!prs_align(ps))
5010 return False;
5012 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5013 return False;
5015 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5016 return False;
5017 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5018 return False;
5020 return True;
5023 /*******************************************************************
5024 reads or writes a structure.
5025 ********************************************************************/
5027 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5028 prs_struct *ps, int depth)
5030 if (r_u == NULL)
5031 return False;
5033 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5034 depth++;
5036 if(!prs_align(ps))
5037 return False;
5039 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5040 return False;
5042 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5043 return False;
5045 return True;
5049 /*******************************************************************
5050 reads or writes a structure.
5051 ********************************************************************/
5053 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5054 POLICY_HND *pol,
5055 const char *name,
5056 uint32 acb_info, uint32 access_mask)
5058 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5060 q_u->domain_pol = *pol;
5062 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5063 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5065 q_u->acb_info = acb_info;
5066 q_u->access_mask = access_mask;
5069 /*******************************************************************
5070 reads or writes a structure.
5071 ********************************************************************/
5073 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5074 prs_struct *ps, int depth)
5076 if (q_u == NULL)
5077 return False;
5079 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5080 depth++;
5082 if(!prs_align(ps))
5083 return False;
5085 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5086 return False;
5088 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5089 return False;
5090 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5091 return False;
5093 if(!prs_align(ps))
5094 return False;
5095 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5096 return False;
5097 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5098 return False;
5100 return True;
5103 /*******************************************************************
5104 reads or writes a structure.
5105 ********************************************************************/
5107 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5108 prs_struct *ps, int depth)
5110 if (r_u == NULL)
5111 return False;
5113 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5114 depth++;
5116 if(!prs_align(ps))
5117 return False;
5119 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5120 return False;
5122 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5123 return False;
5124 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5125 return False;
5126 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5127 return False;
5129 return True;
5132 /*******************************************************************
5133 inits a SAMR_Q_QUERY_USERINFO structure.
5134 ********************************************************************/
5136 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5137 const POLICY_HND *hnd, uint16 switch_value)
5139 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5141 q_u->pol = *hnd;
5142 q_u->switch_value = switch_value;
5145 /*******************************************************************
5146 reads or writes a structure.
5147 ********************************************************************/
5149 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5150 prs_struct *ps, int depth)
5152 if (q_u == NULL)
5153 return False;
5155 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5156 depth++;
5158 if(!prs_align(ps))
5159 return False;
5161 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5162 return False;
5164 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5165 return False;
5167 return True;
5170 /*******************************************************************
5171 reads or writes a LOGON_HRS structure.
5172 ********************************************************************/
5174 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5175 prs_struct *ps, int depth)
5177 if (hrs == NULL)
5178 return False;
5180 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5181 depth++;
5183 if(!prs_align(ps))
5184 return False;
5186 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5187 return False;
5189 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5190 return False;
5192 if(!prs_uint32("len ", ps, depth, &hrs->len))
5193 return False;
5195 if (hrs->len > sizeof(hrs->hours)) {
5196 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5197 hrs->len = sizeof(hrs->hours);
5200 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5201 return False;
5203 return True;
5206 /*******************************************************************
5207 inits a SAM_USER_INFO_18 structure.
5208 ********************************************************************/
5210 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5211 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5213 DEBUG(5, ("init_sam_user_info18\n"));
5215 usr->lm_pwd_active =
5216 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5217 usr->nt_pwd_active =
5218 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5221 /*******************************************************************
5222 reads or writes a structure.
5223 ********************************************************************/
5225 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5226 prs_struct *ps, int depth)
5228 if (u == NULL)
5229 return False;
5231 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5232 depth++;
5234 if(!prs_align(ps))
5235 return False;
5237 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5238 return False;
5239 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5240 return False;
5242 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5243 return False;
5244 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5245 return False;
5247 return True;
5250 /*******************************************************************
5251 inits a SAM_USER_INFO_7 structure.
5252 ********************************************************************/
5254 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5256 DEBUG(5, ("init_sam_user_info7\n"));
5258 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5259 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5263 /*******************************************************************
5264 reads or writes a structure.
5265 ********************************************************************/
5267 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5268 prs_struct *ps, int depth)
5270 if (usr == NULL)
5271 return False;
5273 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5274 depth++;
5276 if(!prs_align(ps))
5277 return False;
5279 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5280 return False;
5282 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5283 return False;
5285 return True;
5288 /*******************************************************************
5289 inits a SAM_USER_INFO_9 structure.
5290 ********************************************************************/
5292 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5294 DEBUG(5, ("init_sam_user_info9\n"));
5296 usr->rid_group = rid_group;
5299 /*******************************************************************
5300 reads or writes a structure.
5301 ********************************************************************/
5303 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5304 prs_struct *ps, int depth)
5306 if (usr == NULL)
5307 return False;
5309 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5310 depth++;
5312 if(!prs_align(ps))
5313 return False;
5315 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5316 return False;
5318 return True;
5321 /*******************************************************************
5322 inits a SAM_USER_INFO_16 structure.
5323 ********************************************************************/
5325 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5327 DEBUG(5, ("init_sam_user_info16\n"));
5329 usr->acb_info = acb_info;
5332 /*******************************************************************
5333 reads or writes a structure.
5334 ********************************************************************/
5336 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5337 prs_struct *ps, int depth)
5339 if (usr == NULL)
5340 return False;
5342 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5343 depth++;
5345 if(!prs_align(ps))
5346 return False;
5348 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5349 return False;
5351 return True;
5354 /*******************************************************************
5355 inits a SAM_USER_INFO_17 structure.
5356 ********************************************************************/
5358 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5359 NTTIME * expiry,
5360 char *mach_acct,
5361 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5363 DEBUG(5, ("init_sam_user_info17\n"));
5365 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5366 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5368 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5370 usr->ptr_1 = 1; /* pointer */
5371 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5372 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5374 usr->ptr_2 = 1; /* pointer */
5375 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5377 usr->ptr_3 = 1; /* pointer */
5378 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5380 usr->rid_user = rid_user;
5381 usr->rid_group = rid_group;
5383 usr->acct_ctrl = acct_ctrl;
5384 usr->unknown_3 = 0x0000;
5386 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5387 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5389 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5390 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5392 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5393 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5396 /*******************************************************************
5397 reads or writes a structure.
5398 ********************************************************************/
5400 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5401 prs_struct *ps, int depth)
5403 if (usr == NULL)
5404 return False;
5406 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5407 depth++;
5409 if(!prs_align(ps))
5410 return False;
5412 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5413 return False;
5415 if(!smb_io_time("time", &usr->expiry, ps, depth))
5416 return False;
5418 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5419 return False;
5421 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5422 return False;
5424 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5425 return False;
5427 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5428 return False;
5429 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5430 return False;
5432 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5433 return False;
5435 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5436 return False;
5437 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5438 return False;
5440 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5441 return False;
5442 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5443 return False;
5445 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5446 return False;
5447 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5448 return False;
5449 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5450 return False;
5451 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5452 return False;
5453 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5454 return False;
5455 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5456 return False;
5458 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5459 return False;
5461 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5462 return False;
5464 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5465 return False;
5467 if(!prs_align(ps))
5468 return False;
5470 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5471 return False;
5473 return True;
5476 /*************************************************************************
5477 init_sam_user_infoa
5478 *************************************************************************/
5480 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len)
5482 DEBUG(10, ("init_sam_user_info24:\n"));
5483 memcpy(usr->pass, newpass, sizeof(usr->pass));
5484 usr->pw_len = pw_len;
5487 /*******************************************************************
5488 reads or writes a structure.
5489 ********************************************************************/
5491 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5492 prs_struct *ps, int depth)
5494 if (usr == NULL)
5495 return False;
5497 prs_debug(ps, depth, desc, "sam_io_user_info24");
5498 depth++;
5500 if(!prs_align(ps))
5501 return False;
5503 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5504 sizeof(usr->pass)))
5505 return False;
5507 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5508 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5509 return False;
5510 } else if (UNMARSHALLING(ps)) {
5511 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len))
5512 return False;
5515 return True;
5518 /*******************************************************************
5519 reads or writes a structure.
5520 ********************************************************************/
5522 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5523 prs_struct *ps, int depth)
5525 if (usr == NULL)
5526 return False;
5528 prs_debug(ps, depth, desc, "sam_io_user_info26");
5529 depth++;
5531 if(!prs_align(ps))
5532 return False;
5534 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5535 sizeof(usr->pass)))
5536 return False;
5538 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5539 return False;
5541 return True;
5545 /*************************************************************************
5546 init_sam_user_info23
5548 unknown_6 = 0x0000 04ec
5550 *************************************************************************/
5552 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5553 NTTIME * logoff_time, /* all zeros */
5554 NTTIME * kickoff_time, /* all zeros */
5555 NTTIME * pass_last_set_time, /* all zeros */
5556 NTTIME * pass_can_change_time, /* all zeros */
5557 NTTIME * pass_must_change_time, /* all zeros */
5558 UNISTR2 *user_name,
5559 UNISTR2 *full_name,
5560 UNISTR2 *home_dir,
5561 UNISTR2 *dir_drive,
5562 UNISTR2 *log_scr,
5563 UNISTR2 *prof_path,
5564 UNISTR2 *desc,
5565 UNISTR2 *wkstas,
5566 UNISTR2 *unk_str,
5567 UNISTR2 *mung_dial,
5568 uint32 user_rid, /* 0x0000 0000 */
5569 uint32 group_rid,
5570 uint32 acb_info,
5571 uint32 fields_present,
5572 uint16 logon_divs,
5573 LOGON_HRS * hrs,
5574 uint16 bad_password_count,
5575 uint16 logon_count,
5576 char newpass[516])
5578 usr->logon_time = *logon_time; /* all zeros */
5579 usr->logoff_time = *logoff_time; /* all zeros */
5580 usr->kickoff_time = *kickoff_time; /* all zeros */
5581 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5582 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5583 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5585 ZERO_STRUCT(usr->nt_pwd);
5586 ZERO_STRUCT(usr->lm_pwd);
5588 usr->user_rid = user_rid; /* 0x0000 0000 */
5589 usr->group_rid = group_rid;
5590 usr->acb_info = acb_info;
5591 usr->fields_present = fields_present; /* 09f8 27fa */
5593 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5594 usr->ptr_logon_hrs = hrs ? 1 : 0;
5596 if (nt_time_is_zero(pass_must_change_time)) {
5597 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5598 } else {
5599 usr->passmustchange=0;
5602 ZERO_STRUCT(usr->padding1);
5603 ZERO_STRUCT(usr->padding2);
5605 usr->bad_password_count = bad_password_count;
5606 usr->logon_count = logon_count;
5608 memcpy(usr->pass, newpass, sizeof(usr->pass));
5610 copy_unistr2(&usr->uni_user_name, user_name);
5611 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5613 copy_unistr2(&usr->uni_full_name, full_name);
5614 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5616 copy_unistr2(&usr->uni_home_dir, home_dir);
5617 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5619 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5620 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5622 copy_unistr2(&usr->uni_logon_script, log_scr);
5623 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5625 copy_unistr2(&usr->uni_profile_path, prof_path);
5626 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5628 copy_unistr2(&usr->uni_acct_desc, desc);
5629 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5631 copy_unistr2(&usr->uni_workstations, wkstas);
5632 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5634 copy_unistr2(&usr->uni_unknown_str, unk_str);
5635 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5637 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5638 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5640 if (hrs) {
5641 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5642 } else {
5643 ZERO_STRUCT(usr->logon_hrs);
5647 /*************************************************************************
5648 init_sam_user_info23
5650 unknown_6 = 0x0000 04ec
5652 *************************************************************************/
5654 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5655 NTTIME * logoff_time, /* all zeros */
5656 NTTIME * kickoff_time, /* all zeros */
5657 NTTIME * pass_last_set_time, /* all zeros */
5658 NTTIME * pass_can_change_time, /* all zeros */
5659 NTTIME * pass_must_change_time, /* all zeros */
5660 char *user_name, /* NULL */
5661 char *full_name,
5662 char *home_dir, char *dir_drive, char *log_scr,
5663 char *prof_path, const char *desc, char *wkstas,
5664 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5665 uint32 group_rid, uint32 acb_info,
5666 uint32 fields_present, uint16 logon_divs,
5667 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5668 char newpass[516])
5670 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5672 usr->logon_time = *logon_time; /* all zeros */
5673 usr->logoff_time = *logoff_time; /* all zeros */
5674 usr->kickoff_time = *kickoff_time; /* all zeros */
5675 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5676 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5677 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5679 ZERO_STRUCT(usr->nt_pwd);
5680 ZERO_STRUCT(usr->lm_pwd);
5682 usr->user_rid = user_rid; /* 0x0000 0000 */
5683 usr->group_rid = group_rid;
5684 usr->acb_info = acb_info;
5685 usr->fields_present = fields_present; /* 09f8 27fa */
5687 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5688 usr->ptr_logon_hrs = hrs ? 1 : 0;
5690 if (nt_time_is_zero(pass_must_change_time)) {
5691 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5692 } else {
5693 usr->passmustchange=0;
5696 ZERO_STRUCT(usr->padding1);
5697 ZERO_STRUCT(usr->padding2);
5699 usr->bad_password_count = bad_password_count;
5700 usr->logon_count = logon_count;
5702 memcpy(usr->pass, newpass, sizeof(usr->pass));
5704 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5705 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5707 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5708 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5710 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5711 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5713 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5714 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5716 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5717 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5719 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5720 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5722 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5723 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5725 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5726 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5728 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
5729 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
5731 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5732 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5734 data_blob_free(&blob);
5736 if (hrs) {
5737 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5738 } else {
5739 ZERO_STRUCT(usr->logon_hrs);
5743 /*******************************************************************
5744 reads or writes a structure.
5745 ********************************************************************/
5747 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5748 prs_struct *ps, int depth)
5750 if (usr == NULL)
5751 return False;
5753 prs_debug(ps, depth, desc, "sam_io_user_info23");
5754 depth++;
5756 if(!prs_align(ps))
5757 return False;
5759 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5760 return False;
5761 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5762 return False;
5763 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5764 return False;
5765 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5766 return False;
5767 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5768 return False;
5769 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5770 return False;
5772 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5773 return False;
5774 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5775 return False;
5776 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5777 return False;
5778 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5779 return False;
5780 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5781 return False;
5782 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5783 return False;
5784 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5785 return False;
5786 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5787 return False;
5788 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5789 return False;
5790 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5791 return False;
5793 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5794 return False;
5795 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5796 return False;
5798 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5799 return False;
5800 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5801 return False;
5802 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5803 return False;
5805 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5806 return False;
5807 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5808 return False;
5809 if(!prs_align(ps))
5810 return False;
5811 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5812 return False;
5814 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5815 return False;
5816 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5817 return False;
5819 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5820 return False;
5821 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5822 return False;
5823 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5824 return False;
5827 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5828 return False;
5830 /* here begins pointed-to data */
5832 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5833 return False;
5835 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5836 return False;
5838 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5839 return False;
5841 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5842 return False;
5844 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5845 return False;
5847 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5848 return False;
5850 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5851 return False;
5853 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5854 return False;
5856 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5857 return False;
5859 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5860 return False;
5862 /* ok, this is only guess-work (as usual) */
5863 if (usr->ptr_logon_hrs) {
5864 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5865 return False;
5868 return True;
5871 /*******************************************************************
5872 reads or writes a structure.
5873 NB. This structure is *definately* incorrect. It's my best guess
5874 currently for W2K SP2. The password field is encrypted in a different
5875 way than normal... And there are definately other problems. JRA.
5876 ********************************************************************/
5878 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5880 if (usr == NULL)
5881 return False;
5883 prs_debug(ps, depth, desc, "sam_io_user_info25");
5884 depth++;
5886 if(!prs_align(ps))
5887 return False;
5889 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5890 return False;
5891 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5892 return False;
5893 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5894 return False;
5895 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5896 return False;
5897 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5898 return False;
5899 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5900 return False;
5902 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5903 return False;
5904 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5905 return False;
5906 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5907 return False;
5908 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5909 return False;
5910 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5911 return False;
5912 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5913 return False;
5914 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5915 return False;
5916 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5917 return False;
5918 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
5919 return False;
5920 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5921 return False;
5923 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5924 return False;
5925 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5926 return False;
5928 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5929 return False;
5930 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5931 return False;
5932 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5933 return False;
5935 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6))
5936 return False;
5938 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5939 return False;
5941 /* here begins pointed-to data */
5943 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5944 return False;
5946 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5947 return False;
5949 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5950 return False;
5952 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5953 return False;
5955 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5956 return False;
5958 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5959 return False;
5961 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5962 return False;
5964 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5965 return False;
5967 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
5968 return False;
5970 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5971 return False;
5973 #if 0 /* JRA - unknown... */
5974 /* ok, this is only guess-work (as usual) */
5975 if (usr->ptr_logon_hrs) {
5976 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5977 return False;
5979 #endif
5981 return True;
5985 /*************************************************************************
5986 init_sam_user_info21W
5988 unknown_6 = 0x0000 04ec
5990 *************************************************************************/
5992 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
5993 NTTIME * logon_time,
5994 NTTIME * logoff_time,
5995 NTTIME * kickoff_time,
5996 NTTIME * pass_last_set_time,
5997 NTTIME * pass_can_change_time,
5998 NTTIME * pass_must_change_time,
5999 UNISTR2 *user_name,
6000 UNISTR2 *full_name,
6001 UNISTR2 *home_dir,
6002 UNISTR2 *dir_drive,
6003 UNISTR2 *log_scr,
6004 UNISTR2 *prof_path,
6005 UNISTR2 *desc,
6006 UNISTR2 *wkstas,
6007 UNISTR2 *unk_str,
6008 UNISTR2 *mung_dial,
6009 uchar lm_pwd[16],
6010 uchar nt_pwd[16],
6011 uint32 user_rid,
6012 uint32 group_rid,
6013 uint32 acb_info,
6014 uint32 fields_present,
6015 uint16 logon_divs,
6016 LOGON_HRS * hrs,
6017 uint16 bad_password_count,
6018 uint16 logon_count)
6020 usr->logon_time = *logon_time;
6021 usr->logoff_time = *logoff_time;
6022 usr->kickoff_time = *kickoff_time;
6023 usr->pass_last_set_time = *pass_last_set_time;
6024 usr->pass_can_change_time = *pass_can_change_time;
6025 usr->pass_must_change_time = *pass_must_change_time;
6027 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6028 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6030 usr->user_rid = user_rid;
6031 usr->group_rid = group_rid;
6032 usr->acb_info = acb_info;
6033 usr->fields_present = fields_present; /* 0x00ff ffff */
6035 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6036 usr->ptr_logon_hrs = hrs ? 1 : 0;
6037 usr->bad_password_count = bad_password_count;
6038 usr->logon_count = logon_count;
6040 if (nt_time_is_zero(pass_must_change_time)) {
6041 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6042 } else {
6043 usr->passmustchange=0;
6046 ZERO_STRUCT(usr->padding1);
6047 ZERO_STRUCT(usr->padding2);
6049 copy_unistr2(&usr->uni_user_name, user_name);
6050 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6052 copy_unistr2(&usr->uni_full_name, full_name);
6053 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6055 copy_unistr2(&usr->uni_home_dir, home_dir);
6056 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6058 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6059 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6061 copy_unistr2(&usr->uni_logon_script, log_scr);
6062 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6064 copy_unistr2(&usr->uni_profile_path, prof_path);
6065 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6067 copy_unistr2(&usr->uni_acct_desc, desc);
6068 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6070 copy_unistr2(&usr->uni_workstations, wkstas);
6071 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6073 copy_unistr2(&usr->uni_unknown_str, unk_str);
6074 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6076 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6077 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6079 if (hrs) {
6080 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6081 } else {
6082 ZERO_STRUCT(usr->logon_hrs);
6086 /*************************************************************************
6087 init_sam_user_info21
6089 unknown_6 = 0x0000 04ec
6091 *************************************************************************/
6093 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6095 NTTIME logon_time, logoff_time, kickoff_time,
6096 pass_last_set_time, pass_can_change_time,
6097 pass_must_change_time;
6099 const char* user_name = pdb_get_username(pw);
6100 const char* full_name = pdb_get_fullname(pw);
6101 const char* home_dir = pdb_get_homedir(pw);
6102 const char* dir_drive = pdb_get_dir_drive(pw);
6103 const char* logon_script = pdb_get_logon_script(pw);
6104 const char* profile_path = pdb_get_profile_path(pw);
6105 const char* description = pdb_get_acct_desc(pw);
6106 const char* workstations = pdb_get_workstations(pw);
6107 const char* munged_dial = pdb_get_munged_dial(pw);
6108 DATA_BLOB munged_dial_blob;
6110 uint32 user_rid;
6111 const DOM_SID *user_sid;
6113 uint32 group_rid;
6114 const DOM_SID *group_sid;
6116 if (munged_dial) {
6117 munged_dial_blob = base64_decode_data_blob(munged_dial);
6118 } else {
6119 munged_dial_blob = data_blob(NULL, 0);
6122 /* Create NTTIME structs */
6123 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6124 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6125 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6126 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6127 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6128 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6130 /* structure assignment */
6131 usr->logon_time = logon_time;
6132 usr->logoff_time = logoff_time;
6133 usr->kickoff_time = kickoff_time;
6134 usr->pass_last_set_time = pass_last_set_time;
6135 usr->pass_can_change_time = pass_can_change_time;
6136 usr->pass_must_change_time = pass_must_change_time;
6138 ZERO_STRUCT(usr->nt_pwd);
6139 ZERO_STRUCT(usr->lm_pwd);
6141 user_sid = pdb_get_user_sid(pw);
6143 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6144 fstring user_sid_string;
6145 fstring domain_sid_string;
6146 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6147 "the domain sid %s. Failing operation.\n",
6148 user_name,
6149 sid_to_string(user_sid_string, user_sid),
6150 sid_to_string(domain_sid_string, domain_sid)));
6151 data_blob_free(&munged_dial_blob);
6152 return NT_STATUS_UNSUCCESSFUL;
6155 group_sid = pdb_get_group_sid(pw);
6157 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6158 fstring group_sid_string;
6159 fstring domain_sid_string;
6160 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6161 "which conflicts with the domain sid %s. Failing operation.\n",
6162 user_name,
6163 sid_to_string(group_sid_string, group_sid),
6164 sid_to_string(domain_sid_string, domain_sid)));
6165 data_blob_free(&munged_dial_blob);
6166 return NT_STATUS_UNSUCCESSFUL;
6169 usr->user_rid = user_rid;
6170 usr->group_rid = group_rid;
6171 usr->acb_info = pdb_get_acct_ctrl(pw);
6174 Look at a user on a real NT4 PDC with usrmgr, press
6175 'ok'. Then you will see that fields_present is set to
6176 0x08f827fa. Look at the user immediately after that again,
6177 and you will see that 0x00fffff is returned. This solves
6178 the problem that you get access denied after having looked
6179 at the user.
6180 -- Volker
6182 usr->fields_present = pdb_build_fields_present(pw);
6184 usr->logon_divs = pdb_get_logon_divs(pw);
6185 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6186 usr->bad_password_count = pdb_get_bad_password_count(pw);
6187 usr->logon_count = pdb_get_logon_count(pw);
6189 if (pdb_get_pass_must_change_time(pw) == 0) {
6190 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6191 } else {
6192 usr->passmustchange=0;
6195 ZERO_STRUCT(usr->padding1);
6196 ZERO_STRUCT(usr->padding2);
6198 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6199 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6201 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6202 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6204 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6205 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6207 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6208 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6210 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6211 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6213 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6214 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6216 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6217 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6219 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6220 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6222 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
6223 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
6225 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6226 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6227 data_blob_free(&munged_dial_blob);
6229 if (pdb_get_hours(pw)) {
6230 usr->logon_hrs.max_len = 1260;
6231 usr->logon_hrs.offset = 0;
6232 usr->logon_hrs.len = pdb_get_hours_len(pw);
6233 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6234 } else {
6235 usr->logon_hrs.max_len = 1260;
6236 usr->logon_hrs.offset = 0;
6237 usr->logon_hrs.len = 0;
6238 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6241 return NT_STATUS_OK;
6244 /*******************************************************************
6245 reads or writes a structure.
6246 ********************************************************************/
6248 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6249 prs_struct *ps, int depth)
6251 if (usr == NULL)
6252 return False;
6254 prs_debug(ps, depth, desc, "sam_io_user_info21");
6255 depth++;
6257 if(!prs_align(ps))
6258 return False;
6260 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6261 return False;
6262 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6263 return False;
6264 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6265 return False;
6266 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6267 return False;
6268 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6269 return False;
6270 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6271 return False;
6273 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6274 return False;
6275 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6276 return False;
6277 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6278 return False;
6279 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6280 return False;
6281 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6282 return False;
6283 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6284 return False;
6285 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6286 return False;
6287 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6288 return False;
6289 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */
6290 return False;
6291 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6292 return False;
6294 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6295 return False;
6296 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6297 return False;
6299 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6300 return False;
6301 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6302 return False;
6303 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6304 return False;
6306 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6307 return False;
6308 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6309 return False;
6310 if(!prs_align(ps))
6311 return False;
6312 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6313 return False;
6315 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6316 return False;
6317 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6318 return False;
6320 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6321 return False;
6322 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6323 return False;
6324 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6325 return False;
6327 /* here begins pointed-to data */
6329 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6330 return False;
6331 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6332 return False;
6333 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6334 return False;
6335 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6336 return False;
6337 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6338 return False;
6339 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6340 return False;
6341 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6342 return False;
6343 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6344 return False;
6345 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */
6346 return False;
6347 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6348 return False;
6350 /* ok, this is only guess-work (as usual) */
6351 if (usr->ptr_logon_hrs) {
6352 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6353 return False;
6356 return True;
6359 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6361 const char *munged_dial = pdb_get_munged_dial(pw);
6362 DATA_BLOB blob = base64_decode_data_blob(munged_dial);
6364 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6365 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6366 data_blob_free(&blob);
6369 /*******************************************************************
6370 reads or writes a structure.
6371 ********************************************************************/
6373 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6374 prs_struct *ps, int depth)
6376 if (usr == NULL)
6377 return False;
6379 prs_debug(ps, depth, desc, "sam_io_user_info20");
6380 depth++;
6382 if(!prs_align(ps))
6383 return False;
6385 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6386 return False;
6388 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6389 return False;
6391 return True;
6394 /*******************************************************************
6395 inits a SAM_USERINFO_CTR structure.
6396 ********************************************************************/
6398 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6399 uint16 switch_value,
6400 SAM_USER_INFO_21 * usr)
6402 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6404 ctr->switch_value = switch_value;
6405 ctr->info.id = NULL;
6407 switch (switch_value) {
6408 case 16:
6409 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6410 if (ctr->info.id16 == NULL)
6411 return NT_STATUS_NO_MEMORY;
6413 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6414 break;
6415 #if 0
6416 /* whoops - got this wrong. i think. or don't understand what's happening. */
6417 case 17:
6419 NTTIME expire;
6420 info = (void *)&id11;
6422 expire.low = 0xffffffff;
6423 expire.high = 0x7fffffff;
6425 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6426 init_sam_user_info11(ctr->info.id17, &expire,
6427 "BROOKFIELDS$", /* name */
6428 0x03ef, /* user rid */
6429 0x201, /* group rid */
6430 0x0080); /* acb info */
6432 break;
6434 #endif
6435 case 18:
6436 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6437 if (ctr->info.id18 == NULL)
6438 return NT_STATUS_NO_MEMORY;
6440 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6441 break;
6442 case 21:
6444 SAM_USER_INFO_21 *cusr;
6445 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6446 ctr->info.id21 = cusr;
6447 if (ctr->info.id21 == NULL)
6448 return NT_STATUS_NO_MEMORY;
6449 memcpy(cusr, usr, sizeof(*usr));
6450 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6451 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6452 break;
6454 default:
6455 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6456 return NT_STATUS_INVALID_INFO_CLASS;
6459 return NT_STATUS_OK;
6462 /*******************************************************************
6463 inits a SAM_USERINFO_CTR structure.
6464 ********************************************************************/
6466 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6467 uint16 switch_value, void *info)
6469 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6471 ctr->switch_value = switch_value;
6472 ctr->info.id = info;
6474 switch (switch_value) {
6475 case 0x18:
6476 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6477 dump_data(100, (char *)sess_key->data, sess_key->length);
6478 dump_data(100, (char *)ctr->info.id24->pass, 516);
6479 break;
6480 case 0x17:
6481 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6482 dump_data(100, (char *)sess_key->data, sess_key->length);
6483 dump_data(100, (char *)ctr->info.id23->pass, 516);
6484 break;
6485 case 0x07:
6486 break;
6487 default:
6488 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6492 /*******************************************************************
6493 reads or writes a structure.
6494 ********************************************************************/
6496 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6497 prs_struct *ps, int depth)
6499 BOOL ret;
6500 SAM_USERINFO_CTR *ctr;
6502 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6503 depth++;
6505 if (UNMARSHALLING(ps)) {
6506 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6507 if (ctr == NULL)
6508 return False;
6509 *ppctr = ctr;
6510 } else {
6511 ctr = *ppctr;
6514 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6516 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6517 return False;
6518 if(!prs_align(ps))
6519 return False;
6521 ret = False;
6523 switch (ctr->switch_value) {
6524 case 7:
6525 if (UNMARSHALLING(ps))
6526 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6527 if (ctr->info.id7 == NULL) {
6528 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6529 return False;
6531 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6532 break;
6533 case 9:
6534 if (UNMARSHALLING(ps))
6535 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6536 if (ctr->info.id9 == NULL) {
6537 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6538 return False;
6540 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6541 break;
6542 case 16:
6543 if (UNMARSHALLING(ps))
6544 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6545 if (ctr->info.id16 == NULL) {
6546 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6547 return False;
6549 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6550 break;
6551 case 17:
6552 if (UNMARSHALLING(ps))
6553 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6555 if (ctr->info.id17 == NULL) {
6556 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6557 return False;
6559 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6560 break;
6561 case 18:
6562 if (UNMARSHALLING(ps))
6563 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6565 if (ctr->info.id18 == NULL) {
6566 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6567 return False;
6569 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6570 break;
6571 case 20:
6572 if (UNMARSHALLING(ps))
6573 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6575 if (ctr->info.id20 == NULL) {
6576 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6577 return False;
6579 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6580 break;
6581 case 21:
6582 if (UNMARSHALLING(ps))
6583 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6585 if (ctr->info.id21 == NULL) {
6586 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6587 return False;
6589 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6590 break;
6591 case 23:
6592 if (UNMARSHALLING(ps))
6593 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6595 if (ctr->info.id23 == NULL) {
6596 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6597 return False;
6599 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6600 break;
6601 case 24:
6602 if (UNMARSHALLING(ps))
6603 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6605 if (ctr->info.id24 == NULL) {
6606 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6607 return False;
6609 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6610 break;
6611 case 25:
6612 if (UNMARSHALLING(ps))
6613 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6615 if (ctr->info.id25 == NULL) {
6616 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6617 return False;
6619 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6620 break;
6621 case 26:
6622 if (UNMARSHALLING(ps))
6623 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6625 if (ctr->info.id26 == NULL) {
6626 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6627 return False;
6629 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6630 break;
6631 default:
6632 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6633 ret = False;
6634 break;
6637 return ret;
6640 /*******************************************************************
6641 inits a SAMR_R_QUERY_USERINFO structure.
6642 ********************************************************************/
6644 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6645 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6647 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6649 r_u->ptr = 0;
6650 r_u->ctr = NULL;
6652 if (NT_STATUS_IS_OK(status)) {
6653 r_u->ptr = 1;
6654 r_u->ctr = ctr;
6657 r_u->status = status; /* return status */
6660 /*******************************************************************
6661 reads or writes a structure.
6662 ********************************************************************/
6664 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6665 prs_struct *ps, int depth)
6667 if (r_u == NULL)
6668 return False;
6670 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6671 depth++;
6673 if(!prs_align(ps))
6674 return False;
6676 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6677 return False;
6679 if (r_u->ptr != 0) {
6680 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6681 return False;
6684 if(!prs_align(ps))
6685 return False;
6686 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6687 return False;
6689 return True;
6692 /*******************************************************************
6693 inits a SAMR_Q_SET_USERINFO structure.
6694 ********************************************************************/
6696 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6697 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6698 uint16 switch_value, void *info)
6700 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6702 q_u->pol = *hnd;
6703 q_u->switch_value = switch_value;
6704 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6707 /*******************************************************************
6708 reads or writes a structure.
6709 ********************************************************************/
6711 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6712 prs_struct *ps, int depth)
6714 if (q_u == NULL)
6715 return False;
6717 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6718 depth++;
6720 if(!prs_align(ps))
6721 return False;
6723 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6725 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6726 return False;
6727 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6728 return False;
6730 return True;
6733 /*******************************************************************
6734 inits a SAMR_R_SET_USERINFO structure.
6735 ********************************************************************/
6737 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6739 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6741 r_u->status = status; /* return status */
6744 /*******************************************************************
6745 reads or writes a structure.
6746 ********************************************************************/
6748 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6749 prs_struct *ps, int depth)
6751 if (r_u == NULL)
6752 return False;
6754 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6755 depth++;
6757 if(!prs_align(ps))
6758 return False;
6760 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6761 return False;
6763 return True;
6766 /*******************************************************************
6767 inits a SAMR_Q_SET_USERINFO2 structure.
6768 ********************************************************************/
6770 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6771 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6772 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6774 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6776 q_u->pol = *hnd;
6777 q_u->switch_value = switch_value;
6778 q_u->ctr = ctr;
6780 if (q_u->ctr != NULL)
6781 q_u->ctr->switch_value = switch_value;
6783 switch (switch_value) {
6784 case 18:
6785 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6786 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6787 dump_data(100, (char *)sess_key->data, sess_key->length);
6788 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6789 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6790 break;
6794 /*******************************************************************
6795 reads or writes a structure.
6796 ********************************************************************/
6798 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6799 prs_struct *ps, int depth)
6801 if (q_u == NULL)
6802 return False;
6804 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6805 depth++;
6807 if(!prs_align(ps))
6808 return False;
6810 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6811 return False;
6813 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6814 return False;
6815 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6816 return False;
6818 return True;
6821 /*******************************************************************
6822 inits a SAMR_R_SET_USERINFO2 structure.
6823 ********************************************************************/
6825 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6827 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6829 r_u->status = status; /* return status */
6832 /*******************************************************************
6833 reads or writes a structure.
6834 ********************************************************************/
6836 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6837 prs_struct *ps, int depth)
6839 if (r_u == NULL)
6840 return False;
6842 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6843 depth++;
6845 if(!prs_align(ps))
6846 return False;
6848 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6849 return False;
6851 return True;
6854 /*******************************************************************
6855 inits a SAMR_Q_CONNECT structure.
6856 ********************************************************************/
6858 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6859 char *srv_name, uint32 access_mask)
6861 DEBUG(5, ("init_samr_q_connect\n"));
6863 /* make PDC server name \\server */
6864 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6865 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6867 /* example values: 0x0000 0002 */
6868 q_u->access_mask = access_mask;
6871 /*******************************************************************
6872 reads or writes a structure.
6873 ********************************************************************/
6875 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6876 prs_struct *ps, int depth)
6878 if (q_u == NULL)
6879 return False;
6881 prs_debug(ps, depth, desc, "samr_io_q_connect");
6882 depth++;
6884 if(!prs_align(ps))
6885 return False;
6887 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6888 return False;
6889 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6890 return False;
6892 if(!prs_align(ps))
6893 return False;
6894 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6895 return False;
6897 return True;
6900 /*******************************************************************
6901 reads or writes a structure.
6902 ********************************************************************/
6904 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
6905 prs_struct *ps, int depth)
6907 if (r_u == NULL)
6908 return False;
6910 prs_debug(ps, depth, desc, "samr_io_r_connect");
6911 depth++;
6913 if(!prs_align(ps))
6914 return False;
6916 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6917 return False;
6919 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6920 return False;
6922 return True;
6925 /*******************************************************************
6926 inits a SAMR_Q_CONNECT4 structure.
6927 ********************************************************************/
6929 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
6930 char *srv_name, uint32 access_mask)
6932 DEBUG(5, ("init_samr_q_connect4\n"));
6934 /* make PDC server name \\server */
6935 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6936 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6938 /* Only value we've seen, possibly an address type ? */
6939 q_u->unk_0 = 2;
6941 /* example values: 0x0000 0002 */
6942 q_u->access_mask = access_mask;
6945 /*******************************************************************
6946 reads or writes a structure.
6947 ********************************************************************/
6949 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
6950 prs_struct *ps, int depth)
6952 if (q_u == NULL)
6953 return False;
6955 prs_debug(ps, depth, desc, "samr_io_q_connect4");
6956 depth++;
6958 if(!prs_align(ps))
6959 return False;
6961 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6962 return False;
6963 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6964 return False;
6966 if(!prs_align(ps))
6967 return False;
6968 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
6969 return False;
6970 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
6971 return False;
6973 return True;
6976 /*******************************************************************
6977 reads or writes a structure.
6978 ********************************************************************/
6980 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
6981 prs_struct *ps, int depth)
6983 if (r_u == NULL)
6984 return False;
6986 prs_debug(ps, depth, desc, "samr_io_r_connect4");
6987 depth++;
6989 if(!prs_align(ps))
6990 return False;
6992 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
6993 return False;
6995 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6996 return False;
6998 return True;
7001 /*******************************************************************
7002 inits a SAMR_Q_CONNECT5 structure.
7003 ********************************************************************/
7005 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7006 char *srv_name, uint32 access_mask)
7008 DEBUG(5, ("init_samr_q_connect5\n"));
7010 /* make PDC server name \\server */
7011 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7012 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7014 /* example values: 0x0000 0002 */
7015 q_u->access_mask = access_mask;
7017 q_u->level = 1;
7018 q_u->info1_unk1 = 3;
7019 q_u->info1_unk2 = 0;
7022 /*******************************************************************
7023 inits a SAMR_R_CONNECT5 structure.
7024 ********************************************************************/
7026 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7028 DEBUG(5, ("init_samr_q_connect5\n"));
7030 r_u->level = 1;
7031 r_u->info1_unk1 = 3;
7032 r_u->info1_unk2 = 0;
7034 r_u->connect_pol = *pol;
7035 r_u->status = status;
7038 /*******************************************************************
7039 reads or writes a structure.
7040 ********************************************************************/
7042 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7043 prs_struct *ps, int depth)
7045 if (q_u == NULL)
7046 return False;
7048 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7049 depth++;
7051 if(!prs_align(ps))
7052 return False;
7054 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7055 return False;
7056 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7057 return False;
7059 if(!prs_align(ps))
7060 return False;
7061 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7062 return False;
7064 if(!prs_uint32("level", ps, depth, &q_u->level))
7065 return False;
7066 if(!prs_uint32("level", ps, depth, &q_u->level))
7067 return False;
7069 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7070 return False;
7071 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7072 return False;
7074 return True;
7077 /*******************************************************************
7078 reads or writes a structure.
7079 ********************************************************************/
7081 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7082 prs_struct *ps, int depth)
7084 if (r_u == NULL)
7085 return False;
7087 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7088 depth++;
7090 if(!prs_align(ps))
7091 return False;
7093 if(!prs_uint32("level", ps, depth, &r_u->level))
7094 return False;
7095 if(!prs_uint32("level", ps, depth, &r_u->level))
7096 return False;
7097 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7098 return False;
7099 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7100 return False;
7102 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7103 return False;
7105 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7106 return False;
7108 return True;
7111 /*******************************************************************
7112 inits a SAMR_Q_CONNECT_ANON structure.
7113 ********************************************************************/
7115 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7117 DEBUG(5, ("init_samr_q_connect_anon\n"));
7119 q_u->ptr = 1;
7120 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7121 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7124 /*******************************************************************
7125 reads or writes a structure.
7126 ********************************************************************/
7128 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * 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_connect_anon");
7135 depth++;
7137 if(!prs_align(ps))
7138 return False;
7140 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7141 return False;
7142 if (q_u->ptr) {
7143 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7144 return False;
7146 if(!prs_align(ps))
7147 return False;
7148 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7149 return False;
7151 return True;
7154 /*******************************************************************
7155 reads or writes a structure.
7156 ********************************************************************/
7158 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7159 prs_struct *ps, int depth)
7161 if (r_u == NULL)
7162 return False;
7164 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7165 depth++;
7167 if(!prs_align(ps))
7168 return False;
7170 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7171 return False;
7173 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7174 return False;
7176 return True;
7179 /*******************************************************************
7180 inits a SAMR_Q_GET_DOM_PWINFO structure.
7181 ********************************************************************/
7183 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7184 char *srv_name)
7186 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7188 q_u->ptr = 1;
7189 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7190 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7193 /*******************************************************************
7194 reads or writes a structure.
7195 ********************************************************************/
7197 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7198 prs_struct *ps, int depth)
7200 if (q_u == NULL)
7201 return False;
7203 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7204 depth++;
7206 if(!prs_align(ps))
7207 return False;
7209 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7210 return False;
7211 if (q_u->ptr != 0) {
7212 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7213 return False;
7214 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7215 return False;
7218 return True;
7221 /*******************************************************************
7222 reads or writes a structure.
7223 ********************************************************************/
7225 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7226 prs_struct *ps, int depth)
7228 if (r_u == NULL)
7229 return False;
7231 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7232 depth++;
7234 if(!prs_align(ps))
7235 return False;
7237 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7238 return False;
7239 if(!prs_align(ps))
7240 return False;
7241 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7242 return False;
7244 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7245 return False;
7247 return True;
7250 /*******************************************************************
7251 make a SAMR_ENC_PASSWD structure.
7252 ********************************************************************/
7254 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7256 ZERO_STRUCTP(pwd);
7258 if (pass == NULL) {
7259 pwd->ptr = 0;
7260 } else {
7261 pwd->ptr = 1;
7262 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7266 /*******************************************************************
7267 reads or writes a SAMR_ENC_PASSWD structure.
7268 ********************************************************************/
7270 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7271 prs_struct *ps, int depth)
7273 if (pwd == NULL)
7274 return False;
7276 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7277 depth++;
7279 if(!prs_align(ps))
7280 return False;
7282 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7283 return False;
7285 if (pwd->ptr != 0) {
7286 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7287 return False;
7290 return True;
7293 /*******************************************************************
7294 inits a SAMR_ENC_HASH structure.
7295 ********************************************************************/
7297 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7299 ZERO_STRUCTP(hsh);
7301 if (hash == NULL) {
7302 hsh->ptr = 0;
7303 } else {
7304 hsh->ptr = 1;
7305 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7309 /*******************************************************************
7310 reads or writes a SAMR_ENC_HASH structure.
7311 ********************************************************************/
7313 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7314 prs_struct *ps, int depth)
7316 if (hsh == NULL)
7317 return False;
7319 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7320 depth++;
7322 if(!prs_align(ps))
7323 return False;
7325 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7326 return False;
7327 if (hsh->ptr != 0) {
7328 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7329 return False;
7332 return True;
7335 /*******************************************************************
7336 inits a SAMR_Q_CHGPASSWD_USER structure.
7337 ********************************************************************/
7339 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7340 const char *dest_host, const char *user_name,
7341 const uchar nt_newpass[516],
7342 const uchar nt_oldhash[16],
7343 const uchar lm_newpass[516],
7344 const uchar lm_oldhash[16])
7346 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7348 q_u->ptr_0 = 1;
7349 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7350 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7352 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7353 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7355 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7356 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7358 q_u->unknown = 0x01;
7360 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7361 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7364 /*******************************************************************
7365 reads or writes a structure.
7366 ********************************************************************/
7368 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7369 prs_struct *ps, int depth)
7371 if (q_u == NULL)
7372 return False;
7374 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7375 depth++;
7377 if(!prs_align(ps))
7378 return False;
7380 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7381 return False;
7383 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7384 return False;
7385 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7386 return False;
7388 if(!prs_align(ps))
7389 return False;
7390 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7391 return False;
7392 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7393 return False;
7395 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7396 return False;
7397 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7398 return False;
7400 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7401 return False;
7403 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7404 return False;
7405 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7406 return False;
7408 return True;
7411 /*******************************************************************
7412 inits a SAMR_R_CHGPASSWD_USER structure.
7413 ********************************************************************/
7415 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7417 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7419 r_u->status = status;
7422 /*******************************************************************
7423 reads or writes a structure.
7424 ********************************************************************/
7426 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7427 prs_struct *ps, int depth)
7429 if (r_u == NULL)
7430 return False;
7432 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7433 depth++;
7435 if(!prs_align(ps))
7436 return False;
7438 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7439 return False;
7441 return True;
7444 /*******************************************************************
7445 inits a SAMR_Q_CHGPASSWD3 structure.
7446 ********************************************************************/
7448 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7449 const char *dest_host, const char *user_name,
7450 const uchar nt_newpass[516],
7451 const uchar nt_oldhash[16],
7452 const uchar lm_newpass[516],
7453 const uchar lm_oldhash[16])
7455 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7457 q_u->ptr_0 = 1;
7458 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7459 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7461 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7462 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7464 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7465 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7467 q_u->lm_change = 0x01;
7469 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7470 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7472 init_enc_passwd(&q_u->password3, NULL);
7475 /*******************************************************************
7476 reads or writes a structure.
7477 ********************************************************************/
7479 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7480 prs_struct *ps, int depth)
7482 if (q_u == NULL)
7483 return False;
7485 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7486 depth++;
7488 if(!prs_align(ps))
7489 return False;
7491 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7492 return False;
7494 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7495 return False;
7496 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7497 return False;
7499 if(!prs_align(ps))
7500 return False;
7501 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7502 return False;
7503 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7504 return False;
7506 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7507 return False;
7508 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7509 return False;
7511 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7512 return False;
7514 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7515 return False;
7516 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7517 return False;
7519 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7520 return False;
7522 return True;
7525 /*******************************************************************
7526 inits a SAMR_R_CHGPASSWD_USER3 structure.
7527 ********************************************************************/
7529 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7530 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7532 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7534 r_u->status = status;
7535 r_u->info = 0;
7536 r_u->ptr_info = 0;
7537 r_u->reject = 0;
7538 r_u->ptr_reject = 0;
7540 if (info) {
7541 r_u->info = info;
7542 r_u->ptr_info = 1;
7544 if (reject && (reject->reject_reason != Undefined)) {
7545 r_u->reject = reject;
7546 r_u->ptr_reject = 1;
7550 /*******************************************************************
7551 Reads or writes an SAMR_CHANGE_REJECT structure.
7552 ********************************************************************/
7554 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7556 if (reject == NULL)
7557 return False;
7559 prs_debug(ps, depth, desc, "samr_io_change_reject");
7560 depth++;
7562 if(!prs_align(ps))
7563 return False;
7565 if(UNMARSHALLING(ps))
7566 ZERO_STRUCTP(reject);
7568 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7569 return False;
7571 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7572 return False;
7574 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7575 return False;
7577 return True;
7580 /*******************************************************************
7581 reads or writes a structure.
7582 ********************************************************************/
7584 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7585 prs_struct *ps, int depth)
7587 if (r_u == NULL)
7588 return False;
7590 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7591 depth++;
7593 if (!prs_align(ps))
7594 return False;
7596 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7597 return False;
7599 if (r_u->ptr_info && r_u->info != NULL) {
7600 /* SAM_UNK_INFO_1 */
7601 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7602 return False;
7605 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7606 return False;
7608 if (r_u->ptr_reject && r_u->reject != NULL) {
7609 /* SAMR_CHANGE_REJECT */
7610 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7611 return False;
7614 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7615 return False;
7617 return True;
7620 /*******************************************************************
7621 reads or writes a structure.
7622 ********************************************************************/
7624 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7625 POLICY_HND *domain_pol, uint16 switch_value)
7627 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7629 q_u->domain_pol = *domain_pol;
7630 q_u->switch_value = switch_value;
7633 /*******************************************************************
7634 reads or writes a structure.
7635 ********************************************************************/
7637 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7638 prs_struct *ps, int depth)
7640 if (q_u == NULL)
7641 return False;
7643 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7644 depth++;
7646 if(!prs_align(ps))
7647 return False;
7649 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7650 return False;
7652 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7653 return False;
7655 return True;
7658 /*******************************************************************
7659 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7660 ********************************************************************/
7662 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7663 uint16 switch_value, SAM_UNK_CTR * ctr,
7664 NTSTATUS status)
7666 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7668 r_u->ptr_0 = 0;
7669 r_u->switch_value = 0;
7670 r_u->status = status; /* return status */
7672 if (NT_STATUS_IS_OK(status)) {
7673 r_u->switch_value = switch_value;
7674 r_u->ptr_0 = 1;
7675 r_u->ctr = ctr;
7679 /*******************************************************************
7680 reads or writes a structure.
7681 ********************************************************************/
7683 BOOL samr_io_r_samr_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7684 prs_struct *ps, int depth)
7686 if (r_u == NULL)
7687 return False;
7689 prs_debug(ps, depth, desc, "samr_io_r_samr_query_domain_info2");
7690 depth++;
7692 if(!prs_align(ps))
7693 return False;
7695 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7696 return False;
7698 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7699 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7700 return False;
7701 if(!prs_align(ps))
7702 return False;
7704 switch (r_u->switch_value) {
7705 case 0x0c:
7706 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7707 return False;
7708 break;
7709 case 0x07:
7710 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7711 return False;
7712 break;
7713 case 0x06:
7714 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7715 return False;
7716 break;
7717 case 0x05:
7718 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7719 return False;
7720 break;
7721 case 0x03:
7722 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7723 return False;
7724 break;
7725 case 0x02:
7726 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7727 return False;
7728 break;
7729 case 0x01:
7730 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7731 return False;
7732 break;
7733 default:
7734 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7735 r_u->switch_value));
7736 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7737 return False;
7741 if(!prs_align(ps))
7742 return False;
7744 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7745 return False;
7747 return True;
7751 /*******************************************************************
7752 reads or writes a structure.
7753 ********************************************************************/
7755 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7756 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7758 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7760 q_u->domain_pol = *domain_pol;
7761 q_u->switch_value0 = switch_value;
7763 q_u->switch_value = switch_value;
7764 q_u->ctr = ctr;
7768 /*******************************************************************
7769 reads or writes a structure.
7770 ********************************************************************/
7772 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7773 prs_struct *ps, int depth)
7775 if (q_u == NULL)
7776 return False;
7778 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7779 depth++;
7781 if(!prs_align(ps))
7782 return False;
7784 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7785 return False;
7787 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7788 return False;
7790 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7791 return False;
7793 if(!prs_align(ps))
7794 return False;
7796 if (UNMARSHALLING(ps)) {
7797 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7798 return False;
7801 switch (q_u->switch_value) {
7803 case 0x0c:
7804 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7805 return False;
7806 break;
7807 case 0x07:
7808 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7809 return False;
7810 break;
7811 case 0x06:
7812 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7813 return False;
7814 break;
7815 case 0x05:
7816 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7817 return False;
7818 break;
7819 case 0x03:
7820 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7821 return False;
7822 break;
7823 case 0x02:
7824 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7825 return False;
7826 break;
7827 case 0x01:
7828 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7829 return False;
7830 break;
7831 default:
7832 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7833 q_u->switch_value));
7834 return False;
7837 return True;
7840 /*******************************************************************
7841 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7842 ********************************************************************/
7844 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7846 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7848 r_u->status = status; /* return status */
7851 /*******************************************************************
7852 reads or writes a structure.
7853 ********************************************************************/
7855 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7856 prs_struct *ps, int depth)
7858 if (r_u == NULL)
7859 return False;
7861 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7862 depth++;
7864 if(!prs_align(ps))
7865 return False;
7867 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7868 return False;
7870 return True;