r18722: Fix up password change times. The can change and must change times are
[Samba/bb.git] / source3 / rpc_parse / parse_samr.c
blob4173b0169b7ca67017f93034e171a1479d3f2cd6
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_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
467 DEBUG(5, ("samr_init_samr_q_query_domain_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_domain_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_domain_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;
498 /*******************************************************************
499 inits a structure.
500 ********************************************************************/
502 void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist,
503 uint32 password_properties, NTTIME nt_expire, NTTIME nt_min_age)
505 u_1->min_length_password = min_pass_len;
506 u_1->password_history = pass_hist;
508 if (lp_check_password_script() && *lp_check_password_script()) {
509 password_properties |= DOMAIN_PASSWORD_COMPLEX;
511 u_1->password_properties = password_properties;
513 /* password never expire */
514 u_1->expire = nt_expire;
516 /* can change the password now */
517 u_1->min_passwordage = nt_min_age;
521 /*******************************************************************
522 reads or writes a structure.
523 ********************************************************************/
525 static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
526 prs_struct *ps, int depth)
528 if (u_1 == NULL)
529 return False;
531 prs_debug(ps, depth, desc, "sam_io_unk_info1");
532 depth++;
534 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password))
535 return False;
536 if(!prs_uint16("password_history", ps, depth, &u_1->password_history))
537 return False;
538 if(!prs_uint32("password_properties", ps, depth, &u_1->password_properties))
539 return False;
540 if(!smb_io_time("expire", &u_1->expire, ps, depth))
541 return False;
542 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth))
543 return False;
545 return True;
548 /*******************************************************************
549 inits a structure.
550 ********************************************************************/
552 void init_unk_info2(SAM_UNK_INFO_2 * u_2,
553 const char *comment, const char *domain, const char *server,
554 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role)
556 u_2->logout = nt_logout;
558 u_2->seq_num = seq_num;
561 u_2->unknown_4 = 0x00000001;
562 u_2->server_role = server_role;
563 u_2->unknown_6 = 0x00000001;
564 u_2->num_domain_usrs = num_users;
565 u_2->num_domain_grps = num_groups;
566 u_2->num_local_grps = num_alias;
568 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE);
569 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment);
570 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
571 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
572 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
573 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
576 /*******************************************************************
577 reads or writes a structure.
578 ********************************************************************/
580 static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
581 prs_struct *ps, int depth)
583 if (u_2 == NULL)
584 return False;
586 prs_debug(ps, depth, desc, "sam_io_unk_info2");
587 depth++;
589 if(!smb_io_time("logout", &u_2->logout, ps, depth))
590 return False;
591 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth))
592 return False;
593 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth))
594 return False;
595 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth))
596 return False;
598 /* put all the data in here, at the moment, including what the above
599 pointer is referring to
602 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
603 return False;
605 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */
606 return False;
607 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role))
608 return False;
609 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */
610 return False;
611 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs))
612 return False;
613 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps))
614 return False;
615 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps))
616 return False;
618 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth))
619 return False;
620 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth))
621 return False;
622 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth))
623 return False;
625 return True;
628 /*******************************************************************
629 inits a structure.
630 ********************************************************************/
632 void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
634 u_3->logout = nt_logout;
637 /*******************************************************************
638 reads or writes a structure.
639 ********************************************************************/
641 static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
642 prs_struct *ps, int depth)
644 if (u_3 == NULL)
645 return False;
647 prs_debug(ps, depth, desc, "sam_io_unk_info3");
648 depth++;
650 if(!smb_io_time("logout", &u_3->logout, ps, depth))
651 return False;
653 return True;
656 /*******************************************************************
657 inits a structure.
658 ********************************************************************/
660 void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
662 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
663 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
666 /*******************************************************************
667 reads or writes a structure.
668 ********************************************************************/
670 static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
671 prs_struct *ps, int depth)
673 if (u_4 == NULL)
674 return False;
676 prs_debug(ps, depth, desc, "sam_io_unk_info4");
677 depth++;
679 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
680 return False;
682 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
683 return False;
685 return True;
688 /*******************************************************************
689 inits a structure.
690 ********************************************************************/
692 void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
694 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
695 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
698 /*******************************************************************
699 reads or writes a structure.
700 ********************************************************************/
702 static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
703 prs_struct *ps, int depth)
705 if (u_5 == NULL)
706 return False;
708 prs_debug(ps, depth, desc, "sam_io_unk_info5");
709 depth++;
711 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
712 return False;
714 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
715 return False;
717 return True;
720 /*******************************************************************
721 inits a structure.
722 ********************************************************************/
724 void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
726 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
727 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
730 /*******************************************************************
731 reads or writes a structure.
732 ********************************************************************/
734 static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
735 prs_struct *ps, int depth)
737 if (u_6 == NULL)
738 return False;
740 prs_debug(ps, depth, desc, "sam_io_unk_info6");
741 depth++;
743 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
744 return False;
746 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
747 return False;
749 return True;
752 /*******************************************************************
753 inits a structure.
754 ********************************************************************/
756 void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
758 u_7->server_role = server_role;
761 /*******************************************************************
762 reads or writes a structure.
763 ********************************************************************/
765 static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
766 prs_struct *ps, int depth)
768 if (u_7 == NULL)
769 return False;
771 prs_debug(ps, depth, desc, "sam_io_unk_info7");
772 depth++;
774 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
775 return False;
777 return True;
780 /*******************************************************************
781 inits a structure.
782 ********************************************************************/
784 void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
786 unix_to_nt_time(&u_8->domain_create_time, 0);
787 u_8->seq_num = seq_num;
790 /*******************************************************************
791 reads or writes a structure.
792 ********************************************************************/
794 static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
795 prs_struct *ps, int depth)
797 if (u_8 == NULL)
798 return False;
800 prs_debug(ps, depth, desc, "sam_io_unk_info8");
801 depth++;
803 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
804 return False;
806 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
807 return False;
809 return True;
812 /*******************************************************************
813 inits a structure.
814 ********************************************************************/
816 void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
818 u_9->unknown = unknown;
821 /*******************************************************************
822 reads or writes a structure.
823 ********************************************************************/
825 static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
826 prs_struct *ps, int depth)
828 if (u_9 == NULL)
829 return False;
831 prs_debug(ps, depth, desc, "sam_io_unk_info9");
832 depth++;
834 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
835 return False;
837 return True;
840 /*******************************************************************
841 inits a structure.
842 ********************************************************************/
844 void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
846 u_12->duration = nt_lock_duration;
847 u_12->reset_count = nt_reset_time;
849 u_12->bad_attempt_lockout = lockout;
852 /*******************************************************************
853 reads or writes a structure.
854 ********************************************************************/
856 static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
857 prs_struct *ps, int depth)
859 if (u_12 == NULL)
860 return False;
862 prs_debug(ps, depth, desc, "sam_io_unk_info12");
863 depth++;
865 if(!smb_io_time("duration", &u_12->duration, ps, depth))
866 return False;
867 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth))
868 return False;
869 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout))
870 return False;
872 return True;
875 /*******************************************************************
876 inits a structure.
877 ********************************************************************/
879 void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
881 unix_to_nt_time(&u_13->domain_create_time, 0);
882 u_13->seq_num = seq_num;
883 u_13->unknown1 = 0;
884 u_13->unknown2 = 0;
887 /*******************************************************************
888 reads or writes a structure.
889 ********************************************************************/
891 static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
892 prs_struct *ps, int depth)
894 if (u_13 == NULL)
895 return False;
897 prs_debug(ps, depth, desc, "sam_io_unk_info13");
898 depth++;
900 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
901 return False;
903 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
904 return False;
906 if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1))
907 return False;
908 if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2))
909 return False;
911 return True;
914 /*******************************************************************
915 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
916 ********************************************************************/
918 void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
919 uint16 switch_value, SAM_UNK_CTR * ctr,
920 NTSTATUS status)
922 DEBUG(5, ("init_samr_r_query_domain_info\n"));
924 r_u->ptr_0 = 0;
925 r_u->switch_value = 0;
926 r_u->status = status; /* return status */
928 if (NT_STATUS_IS_OK(status)) {
929 r_u->switch_value = switch_value;
930 r_u->ptr_0 = 1;
931 r_u->ctr = ctr;
935 /*******************************************************************
936 reads or writes a structure.
937 ********************************************************************/
939 BOOL samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
940 prs_struct *ps, int depth)
942 if (r_u == NULL)
943 return False;
945 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
946 depth++;
948 if(!prs_align(ps))
949 return False;
951 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
952 return False;
954 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
955 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
956 return False;
957 if(!prs_align(ps))
958 return False;
960 switch (r_u->switch_value) {
961 case 0x0d:
962 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
963 return False;
964 break;
965 case 0x0c:
966 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
967 return False;
968 break;
969 case 0x09:
970 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
971 return False;
972 break;
973 case 0x08:
974 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
975 return False;
976 break;
977 case 0x07:
978 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
979 return False;
980 break;
981 case 0x06:
982 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
983 return False;
984 break;
985 case 0x05:
986 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
987 return False;
988 break;
989 case 0x04:
990 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
991 return False;
992 break;
993 case 0x03:
994 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
995 return False;
996 break;
997 case 0x02:
998 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
999 return False;
1000 break;
1001 case 0x01:
1002 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
1003 return False;
1004 break;
1005 default:
1006 DEBUG(0, ("samr_io_r_query_domain_info: unknown switch level 0x%x\n",
1007 r_u->switch_value));
1008 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
1009 return False;
1013 if(!prs_align(ps))
1014 return False;
1016 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1017 return False;
1019 return True;
1022 /*******************************************************************
1023 reads or writes a structure.
1024 ********************************************************************/
1026 void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
1027 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
1029 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
1031 q_u->pol = *pol;
1032 q_u->sec_info = sec_info;
1033 q_u->buf = buf;
1037 /*******************************************************************
1038 reads or writes a SAMR_R_SET_SEC_OBJ structure.
1039 ********************************************************************/
1041 BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
1042 prs_struct *ps, int depth)
1044 if (r_u == NULL)
1045 return False;
1047 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
1048 depth++;
1050 if(!prs_align(ps))
1051 return False;
1053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1054 return False;
1056 return True;
1059 /*******************************************************************
1060 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
1061 ********************************************************************/
1063 BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
1064 prs_struct *ps, int depth)
1066 if (r_u == NULL)
1067 return False;
1069 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
1070 depth++;
1072 if(!prs_align(ps))
1073 return False;
1075 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
1076 return False;
1077 if (r_u->ptr != 0) {
1078 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
1079 return False;
1082 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1083 return False;
1085 return True;
1088 /*******************************************************************
1089 reads or writes a SAM_STR1 structure.
1090 ********************************************************************/
1092 static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
1093 uint32 name_buf, uint32 desc_buf,
1094 prs_struct *ps, int depth)
1096 if (sam == NULL)
1097 return False;
1099 prs_debug(ps, depth, desc, "sam_io_sam_str1");
1100 depth++;
1102 if(!prs_align(ps))
1103 return False;
1104 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth))
1105 return False;
1107 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1108 return False;
1110 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1111 return False;
1113 return True;
1116 /*******************************************************************
1117 inits a SAM_ENTRY1 structure.
1118 ********************************************************************/
1120 static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
1121 UNISTR2 *sam_name, UNISTR2 *sam_full,
1122 UNISTR2 *sam_desc, uint32 rid_user,
1123 uint32 acb_info)
1125 DEBUG(5, ("init_sam_entry1\n"));
1127 ZERO_STRUCTP(sam);
1129 sam->user_idx = user_idx;
1130 sam->rid_user = rid_user;
1131 sam->acb_info = acb_info;
1133 init_uni_hdr(&sam->hdr_acct_name, sam_name);
1134 init_uni_hdr(&sam->hdr_user_name, sam_full);
1135 init_uni_hdr(&sam->hdr_user_desc, sam_desc);
1138 /*******************************************************************
1139 reads or writes a SAM_ENTRY1 structure.
1140 ********************************************************************/
1142 static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1143 prs_struct *ps, int depth)
1145 if (sam == NULL)
1146 return False;
1148 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1149 depth++;
1151 if(!prs_align(ps))
1152 return False;
1154 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1155 return False;
1157 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1158 return False;
1159 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1160 return False;
1162 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth))
1163 return False;
1164 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth))
1165 return False;
1166 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth))
1167 return False;
1169 return True;
1172 /*******************************************************************
1173 reads or writes a SAM_STR2 structure.
1174 ********************************************************************/
1176 static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1177 uint32 desc_buf, prs_struct *ps, int depth)
1179 if (sam == NULL)
1180 return False;
1182 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1183 depth++;
1185 if(!prs_align(ps))
1186 return False;
1188 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */
1189 return False;
1190 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */
1191 return False;
1193 return True;
1196 /*******************************************************************
1197 inits a SAM_ENTRY2 structure.
1198 ********************************************************************/
1199 static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1200 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1201 uint32 rid_user, uint32 acb_info)
1203 DEBUG(5, ("init_sam_entry2\n"));
1205 sam->user_idx = user_idx;
1206 sam->rid_user = rid_user;
1207 sam->acb_info = acb_info;
1209 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1210 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1213 /*******************************************************************
1214 reads or writes a SAM_ENTRY2 structure.
1215 ********************************************************************/
1217 static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1218 prs_struct *ps, int depth)
1220 if (sam == NULL)
1221 return False;
1223 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1224 depth++;
1226 if(!prs_align(ps))
1227 return False;
1229 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1230 return False;
1232 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user))
1233 return False;
1234 if(!prs_uint32("acb_info ", ps, depth, &sam->acb_info))
1235 return False;
1237 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */
1238 return False;
1239 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */
1240 return False;
1242 return True;
1245 /*******************************************************************
1246 reads or writes a SAM_STR3 structure.
1247 ********************************************************************/
1249 static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1250 uint32 desc_buf, prs_struct *ps, int depth)
1252 if (sam == NULL)
1253 return False;
1255 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1256 depth++;
1258 if(!prs_align(ps))
1259 return False;
1261 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */
1262 return False;
1263 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */
1264 return False;
1266 return True;
1269 /*******************************************************************
1270 inits a SAM_ENTRY3 structure.
1271 ********************************************************************/
1273 static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1274 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1275 uint32 rid_grp)
1277 DEBUG(5, ("init_sam_entry3\n"));
1279 sam->grp_idx = grp_idx;
1280 sam->rid_grp = rid_grp;
1281 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1283 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1284 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1287 /*******************************************************************
1288 reads or writes a SAM_ENTRY3 structure.
1289 ********************************************************************/
1291 static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1292 prs_struct *ps, int depth)
1294 if (sam == NULL)
1295 return False;
1297 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1298 depth++;
1300 if(!prs_align(ps))
1301 return False;
1303 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1304 return False;
1306 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp))
1307 return False;
1308 if(!prs_uint32("attr ", ps, depth, &sam->attr))
1309 return False;
1311 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */
1312 return False;
1313 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */
1314 return False;
1316 return True;
1319 /*******************************************************************
1320 inits a SAM_ENTRY4 structure.
1321 ********************************************************************/
1323 static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1324 uint32 len_acct_name)
1326 DEBUG(5, ("init_sam_entry4\n"));
1328 sam->user_idx = user_idx;
1329 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0);
1332 /*******************************************************************
1333 reads or writes a SAM_ENTRY4 structure.
1334 ********************************************************************/
1336 static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1337 prs_struct *ps, int depth)
1339 if (sam == NULL)
1340 return False;
1342 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1343 depth++;
1345 if(!prs_align(ps))
1346 return False;
1348 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx))
1349 return False;
1350 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth))
1351 return False;
1353 return True;
1356 /*******************************************************************
1357 inits a SAM_ENTRY5 structure.
1358 ********************************************************************/
1360 static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1361 uint32 len_grp_name)
1363 DEBUG(5, ("init_sam_entry5\n"));
1365 sam->grp_idx = grp_idx;
1366 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name,
1367 len_grp_name != 0);
1370 /*******************************************************************
1371 reads or writes a SAM_ENTRY5 structure.
1372 ********************************************************************/
1374 static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1375 prs_struct *ps, int depth)
1377 if (sam == NULL)
1378 return False;
1380 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1381 depth++;
1383 if(!prs_align(ps))
1384 return False;
1386 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1387 return False;
1388 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth))
1389 return False;
1391 return True;
1394 /*******************************************************************
1395 inits a SAM_ENTRY structure.
1396 ********************************************************************/
1398 void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1400 DEBUG(10, ("init_sam_entry: %d\n", rid));
1402 sam->rid = rid;
1403 init_uni_hdr(&sam->hdr_name, uni2);
1406 /*******************************************************************
1407 reads or writes a SAM_ENTRY structure.
1408 ********************************************************************/
1410 static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1411 prs_struct *ps, int depth)
1413 if (sam == NULL)
1414 return False;
1416 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1417 depth++;
1419 if(!prs_align(ps))
1420 return False;
1421 if(!prs_uint32("rid", ps, depth, &sam->rid))
1422 return False;
1423 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */
1424 return False;
1426 return True;
1429 /*******************************************************************
1430 inits a SAMR_Q_ENUM_DOM_USERS structure.
1431 ********************************************************************/
1433 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol,
1434 uint32 start_idx,
1435 uint32 acb_mask, uint32 size)
1437 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1439 q_e->pol = *pol;
1441 q_e->start_idx = start_idx; /* zero indicates lots */
1442 q_e->acb_mask = acb_mask;
1443 q_e->max_size = size;
1446 /*******************************************************************
1447 reads or writes a structure.
1448 ********************************************************************/
1450 BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1451 prs_struct *ps, int depth)
1453 if (q_e == NULL)
1454 return False;
1456 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1457 depth++;
1459 if(!prs_align(ps))
1460 return False;
1462 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1463 return False;
1465 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
1466 return False;
1467 if(!prs_uint32("acb_mask ", ps, depth, &q_e->acb_mask))
1468 return False;
1470 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1471 return False;
1473 return True;
1477 /*******************************************************************
1478 inits a SAMR_R_ENUM_DOM_USERS structure.
1479 ********************************************************************/
1481 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1482 uint32 next_idx, uint32 num_sam_entries)
1484 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1486 r_u->next_idx = next_idx;
1488 if (num_sam_entries != 0) {
1489 r_u->ptr_entries1 = 1;
1490 r_u->ptr_entries2 = 1;
1491 r_u->num_entries2 = num_sam_entries;
1492 r_u->num_entries3 = num_sam_entries;
1494 r_u->num_entries4 = num_sam_entries;
1495 } else {
1496 r_u->ptr_entries1 = 0;
1497 r_u->num_entries2 = num_sam_entries;
1498 r_u->ptr_entries2 = 1;
1502 /*******************************************************************
1503 reads or writes a structure.
1504 ********************************************************************/
1506 BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1507 prs_struct *ps, int depth)
1509 uint32 i;
1511 if (r_u == NULL)
1512 return False;
1514 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1515 depth++;
1517 if(!prs_align(ps))
1518 return False;
1520 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
1521 return False;
1522 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
1523 return False;
1525 if (r_u->ptr_entries1 != 0) {
1526 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
1527 return False;
1528 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
1529 return False;
1530 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
1531 return False;
1533 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) {
1534 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2);
1535 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2);
1538 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) {
1539 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1540 r_u->num_entries4 = 0;
1541 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
1542 return False;
1545 for (i = 0; i < r_u->num_entries2; i++) {
1546 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
1547 return False;
1550 for (i = 0; i < r_u->num_entries2; i++) {
1551 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth))
1552 return False;
1557 if(!prs_align(ps))
1558 return False;
1560 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
1561 return False;
1562 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1563 return False;
1565 return True;
1568 /*******************************************************************
1569 inits a SAMR_Q_QUERY_DISPINFO structure.
1570 ********************************************************************/
1572 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol,
1573 uint16 switch_level, uint32 start_idx,
1574 uint32 max_entries, uint32 max_size)
1576 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1578 q_e->domain_pol = *pol;
1580 q_e->switch_level = switch_level;
1582 q_e->start_idx = start_idx;
1583 q_e->max_entries = max_entries;
1584 q_e->max_size = max_size;
1587 /*******************************************************************
1588 reads or writes a structure.
1589 ********************************************************************/
1591 BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1592 prs_struct *ps, int depth)
1594 if (q_e == NULL)
1595 return False;
1597 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1598 depth++;
1600 if(!prs_align(ps))
1601 return False;
1603 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1604 return False;
1606 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1607 return False;
1608 if(!prs_align(ps))
1609 return False;
1611 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx))
1612 return False;
1613 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))
1614 return False;
1615 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1616 return False;
1618 return True;
1621 /*******************************************************************
1622 inits a SAM_DISPINFO_1 structure.
1623 ********************************************************************/
1625 NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1626 uint32 num_entries, uint32 start_idx,
1627 struct samr_displayentry *entries)
1629 uint32 i;
1631 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1633 if (num_entries==0)
1634 return NT_STATUS_OK;
1636 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1637 if (*sam == NULL)
1638 return NT_STATUS_NO_MEMORY;
1640 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1641 if ((*sam)->sam == NULL)
1642 return NT_STATUS_NO_MEMORY;
1644 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1645 if ((*sam)->str == NULL)
1646 return NT_STATUS_NO_MEMORY;
1648 for (i = 0; i < num_entries ; i++) {
1649 init_unistr2(&(*sam)->str[i].uni_acct_name,
1650 entries[i].account_name, UNI_FLAGS_NONE);
1651 init_unistr2(&(*sam)->str[i].uni_full_name,
1652 entries[i].fullname, UNI_FLAGS_NONE);
1653 init_unistr2(&(*sam)->str[i].uni_acct_desc,
1654 entries[i].description, UNI_FLAGS_NONE);
1656 init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,
1657 &(*sam)->str[i].uni_acct_name,
1658 &(*sam)->str[i].uni_full_name,
1659 &(*sam)->str[i].uni_acct_desc,
1660 entries[i].rid, entries[i].acct_flags);
1663 return NT_STATUS_OK;
1666 /*******************************************************************
1667 reads or writes a structure.
1668 ********************************************************************/
1670 static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1671 uint32 num_entries,
1672 prs_struct *ps, int depth)
1674 uint32 i;
1676 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1677 depth++;
1679 if(!prs_align(ps))
1680 return False;
1682 if (UNMARSHALLING(ps) && num_entries > 0) {
1684 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {
1685 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1686 return False;
1689 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {
1690 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1691 return False;
1695 for (i = 0; i < num_entries; i++) {
1696 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1697 return False;
1700 for (i = 0; i < num_entries; i++) {
1701 if(!sam_io_sam_str1("", &sam->str[i],
1702 sam->sam[i].hdr_acct_name.buffer,
1703 sam->sam[i].hdr_user_name.buffer,
1704 sam->sam[i].hdr_user_desc.buffer, ps, depth))
1705 return False;
1708 return True;
1711 /*******************************************************************
1712 inits a SAM_DISPINFO_2 structure.
1713 ********************************************************************/
1715 NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1716 uint32 num_entries, uint32 start_idx,
1717 struct samr_displayentry *entries)
1719 uint32 i;
1721 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1723 if (num_entries==0)
1724 return NT_STATUS_OK;
1726 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1727 if (*sam == NULL)
1728 return NT_STATUS_NO_MEMORY;
1730 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1731 if ((*sam)->sam == NULL)
1732 return NT_STATUS_NO_MEMORY;
1734 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1735 if ((*sam)->str == NULL)
1736 return NT_STATUS_NO_MEMORY;
1738 for (i = 0; i < num_entries; i++) {
1739 init_unistr2(&(*sam)->str[i].uni_srv_name,
1740 entries[i].account_name, UNI_FLAGS_NONE);
1741 init_unistr2(&(*sam)->str[i].uni_srv_desc,
1742 entries[i].description, UNI_FLAGS_NONE);
1744 init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,
1745 &(*sam)->str[i].uni_srv_name,
1746 &(*sam)->str[i].uni_srv_desc,
1747 entries[i].rid, entries[i].acct_flags);
1750 return NT_STATUS_OK;
1753 /*******************************************************************
1754 reads or writes a structure.
1755 ********************************************************************/
1757 static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1758 uint32 num_entries,
1759 prs_struct *ps, int depth)
1761 uint32 i;
1763 if (sam == NULL)
1764 return False;
1766 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1767 depth++;
1769 if(!prs_align(ps))
1770 return False;
1772 if (UNMARSHALLING(ps) && num_entries > 0) {
1774 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {
1775 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1776 return False;
1779 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {
1780 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1781 return False;
1785 for (i = 0; i < num_entries; i++) {
1786 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1787 return False;
1790 for (i = 0; i < num_entries; i++) {
1791 if(!sam_io_sam_str2("", &sam->str[i],
1792 sam->sam[i].hdr_srv_name.buffer,
1793 sam->sam[i].hdr_srv_desc.buffer, ps, depth))
1794 return False;
1797 return True;
1800 /*******************************************************************
1801 inits a SAM_DISPINFO_3 structure.
1802 ********************************************************************/
1804 NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1805 uint32 num_entries, uint32 start_idx,
1806 struct samr_displayentry *entries)
1808 uint32 i;
1810 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1812 if (num_entries==0)
1813 return NT_STATUS_OK;
1815 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1816 if (*sam == NULL)
1817 return NT_STATUS_NO_MEMORY;
1819 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1820 return NT_STATUS_NO_MEMORY;
1822 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1823 return NT_STATUS_NO_MEMORY;
1825 for (i = 0; i < num_entries; i++) {
1826 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1828 init_unistr2(&(*sam)->str[i].uni_grp_name,
1829 entries[i].account_name, UNI_FLAGS_NONE);
1830 init_unistr2(&(*sam)->str[i].uni_grp_desc,
1831 entries[i].description, UNI_FLAGS_NONE);
1833 init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,
1834 &(*sam)->str[i].uni_grp_name,
1835 &(*sam)->str[i].uni_grp_desc,
1836 entries[i].rid);
1839 return NT_STATUS_OK;
1842 /*******************************************************************
1843 reads or writes a structure.
1844 ********************************************************************/
1846 static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1847 uint32 num_entries,
1848 prs_struct *ps, int depth)
1850 uint32 i;
1852 if (sam == NULL)
1853 return False;
1855 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1856 depth++;
1858 if(!prs_align(ps))
1859 return False;
1861 if (UNMARSHALLING(ps) && num_entries > 0) {
1863 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {
1864 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1865 return False;
1868 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {
1869 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1870 return False;
1874 for (i = 0; i < num_entries; i++) {
1875 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1876 return False;
1879 for (i = 0; i < num_entries; i++) {
1880 if(!sam_io_sam_str3("", &sam->str[i],
1881 sam->sam[i].hdr_grp_name.buffer,
1882 sam->sam[i].hdr_grp_desc.buffer, ps, depth))
1883 return False;
1886 return True;
1889 /*******************************************************************
1890 inits a SAM_DISPINFO_4 structure.
1891 ********************************************************************/
1893 NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1894 uint32 num_entries, uint32 start_idx,
1895 struct samr_displayentry *entries)
1897 uint32 i;
1899 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1901 if (num_entries==0)
1902 return NT_STATUS_OK;
1904 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1905 if (*sam == NULL)
1906 return NT_STATUS_NO_MEMORY;
1908 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1909 if ((*sam)->sam == NULL)
1910 return NT_STATUS_NO_MEMORY;
1912 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1913 if ((*sam)->str == NULL)
1914 return NT_STATUS_NO_MEMORY;
1916 for (i = 0; i < num_entries; i++) {
1917 size_t len_sam_name = strlen(entries[i].account_name);
1919 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1921 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1922 len_sam_name);
1924 init_string2(&(*sam)->str[i].acct_name,
1925 entries[i].account_name, len_sam_name+1,
1926 len_sam_name);
1929 return NT_STATUS_OK;
1932 /*******************************************************************
1933 reads or writes a structure.
1934 ********************************************************************/
1936 static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1937 uint32 num_entries,
1938 prs_struct *ps, int depth)
1940 uint32 i;
1942 if (sam == NULL)
1943 return False;
1945 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1946 depth++;
1948 if(!prs_align(ps))
1949 return False;
1951 if (UNMARSHALLING(ps) && num_entries > 0) {
1953 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {
1954 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1955 return False;
1958 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {
1959 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1960 return False;
1964 for (i = 0; i < num_entries; i++) {
1965 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1966 return False;
1969 for (i = 0; i < num_entries; i++) {
1970 if(!smb_io_string2("acct_name", &sam->str[i].acct_name,
1971 sam->sam[i].hdr_acct_name.buffer, ps, depth))
1972 return False;
1975 return True;
1978 /*******************************************************************
1979 inits a SAM_DISPINFO_5 structure.
1980 ********************************************************************/
1982 NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1983 uint32 num_entries, uint32 start_idx,
1984 struct samr_displayentry *entries)
1986 uint32 len_sam_name;
1987 uint32 i;
1989 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1991 if (num_entries==0)
1992 return NT_STATUS_OK;
1994 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1995 if (*sam == NULL)
1996 return NT_STATUS_NO_MEMORY;
1998 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1999 return NT_STATUS_NO_MEMORY;
2001 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
2002 return NT_STATUS_NO_MEMORY;
2004 for (i = 0; i < num_entries; i++) {
2005 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
2007 len_sam_name = strlen(entries[i].account_name);
2009 init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);
2010 init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,
2011 len_sam_name+1, len_sam_name);
2014 return NT_STATUS_OK;
2017 /*******************************************************************
2018 reads or writes a structure.
2019 ********************************************************************/
2021 static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
2022 uint32 num_entries,
2023 prs_struct *ps, int depth)
2025 uint32 i;
2027 if (sam == NULL)
2028 return False;
2030 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
2031 depth++;
2033 if(!prs_align(ps))
2034 return False;
2036 if (UNMARSHALLING(ps) && num_entries > 0) {
2038 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {
2039 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
2040 return False;
2043 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {
2044 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
2045 return False;
2049 for (i = 0; i < num_entries; i++) {
2050 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2051 return False;
2054 for (i = 0; i < num_entries; i++) {
2055 if(!smb_io_string2("grp_name", &sam->str[i].grp_name,
2056 sam->sam[i].hdr_grp_name.buffer, ps, depth))
2057 return False;
2060 return True;
2063 /*******************************************************************
2064 inits a SAMR_R_QUERY_DISPINFO structure.
2065 ********************************************************************/
2067 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u,
2068 uint32 num_entries, uint32 total_size, uint32 data_size,
2069 uint16 switch_level, SAM_DISPINFO_CTR * ctr,
2070 NTSTATUS status)
2072 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2074 r_u->total_size = total_size;
2076 r_u->data_size = data_size;
2078 r_u->switch_level = switch_level;
2079 r_u->num_entries = num_entries;
2081 if (num_entries==0)
2082 r_u->ptr_entries = 0;
2083 else
2084 r_u->ptr_entries = 1;
2086 r_u->num_entries2 = num_entries;
2087 r_u->ctr = ctr;
2089 r_u->status = status;
2092 /*******************************************************************
2093 reads or writes a structure.
2094 ********************************************************************/
2096 BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2097 prs_struct *ps, int depth)
2099 if (r_u == NULL)
2100 return False;
2102 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2103 depth++;
2105 if(!prs_align(ps))
2106 return False;
2108 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size))
2109 return False;
2110 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size))
2111 return False;
2112 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level))
2113 return False;
2114 if(!prs_align(ps))
2115 return False;
2117 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
2118 return False;
2119 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries))
2120 return False;
2122 if (r_u->ptr_entries==0) {
2123 if(!prs_align(ps))
2124 return False;
2125 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2126 return False;
2128 return True;
2131 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2132 return False;
2134 switch (r_u->switch_level) {
2135 case 0x1:
2136 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1,
2137 r_u->num_entries, ps, depth))
2138 return False;
2139 break;
2140 case 0x2:
2141 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2,
2142 r_u->num_entries, ps, depth))
2143 return False;
2144 break;
2145 case 0x3:
2146 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3,
2147 r_u->num_entries, ps, depth))
2148 return False;
2149 break;
2150 case 0x4:
2151 if(!sam_io_sam_dispinfo_4("user list",
2152 r_u->ctr->sam.info4,
2153 r_u->num_entries, ps, depth))
2154 return False;
2155 break;
2156 case 0x5:
2157 if(!sam_io_sam_dispinfo_5("group list",
2158 r_u->ctr->sam.info5,
2159 r_u->num_entries, ps, depth))
2160 return False;
2161 break;
2162 default:
2163 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2164 break;
2167 if(!prs_align(ps))
2168 return False;
2169 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2170 return False;
2172 return True;
2175 /*******************************************************************
2176 inits a SAMR_Q_GET_DISPENUM_INDEX structure.
2177 ********************************************************************/
2179 void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
2180 uint16 switch_level, const char *name)
2182 DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
2184 q_e->domain_pol = *pol;
2186 q_e->switch_level = switch_level;
2188 init_lsa_string(&q_e->name, name);
2191 /*******************************************************************
2192 reads or writes a structure.
2193 ********************************************************************/
2195 BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
2196 prs_struct *ps, int depth)
2198 if (q_e == NULL)
2199 return False;
2201 prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
2202 depth++;
2204 if(!prs_align(ps))
2205 return False;
2207 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
2208 return False;
2210 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2211 return False;
2213 if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
2214 return False;
2216 return True;
2219 /*******************************************************************
2220 reads or writes a structure.
2221 ********************************************************************/
2223 BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
2224 prs_struct *ps, int depth)
2226 if (r_u == NULL)
2227 return False;
2229 prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
2230 depth++;
2232 if(!prs_align(ps))
2233 return False;
2235 if(!prs_uint32("idx", ps, depth, &r_u->idx))
2236 return False;
2238 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2239 return False;
2241 return True;
2245 /*******************************************************************
2246 inits a SAMR_Q_OPEN_GROUP structure.
2247 ********************************************************************/
2249 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2250 POLICY_HND *hnd,
2251 uint32 access_mask, uint32 rid)
2253 DEBUG(5, ("init_samr_q_open_group\n"));
2255 q_c->domain_pol = *hnd;
2256 q_c->access_mask = access_mask;
2257 q_c->rid_group = rid;
2260 /*******************************************************************
2261 reads or writes a structure.
2262 ********************************************************************/
2264 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2265 prs_struct *ps, int depth)
2267 if (q_u == NULL)
2268 return False;
2270 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2271 depth++;
2273 if(!prs_align(ps))
2274 return False;
2276 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2277 return False;
2279 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2280 return False;
2281 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2282 return False;
2284 return True;
2287 /*******************************************************************
2288 reads or writes a structure.
2289 ********************************************************************/
2291 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2292 prs_struct *ps, int depth)
2294 if (r_u == NULL)
2295 return False;
2297 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2298 depth++;
2300 if(!prs_align(ps))
2301 return False;
2303 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2304 return False;
2306 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2307 return False;
2309 return True;
2312 /*******************************************************************
2313 inits a GROUP_INFO1 structure.
2314 ********************************************************************/
2316 void init_samr_group_info1(GROUP_INFO1 * gr1,
2317 char *acct_name, char *acct_desc,
2318 uint32 num_members)
2320 DEBUG(5, ("init_samr_group_info1\n"));
2322 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2323 gr1->num_members = num_members;
2325 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2326 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2327 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2328 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2331 /*******************************************************************
2332 reads or writes a structure.
2333 ********************************************************************/
2335 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2336 prs_struct *ps, int depth)
2338 uint16 dummy = 1;
2340 if (gr1 == NULL)
2341 return False;
2343 prs_debug(ps, depth, desc, "samr_io_group_info1");
2344 depth++;
2346 if(!prs_uint16("level", ps, depth, &dummy))
2347 return False;
2349 if(!prs_align(ps))
2350 return False;
2352 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2353 return False;
2355 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2356 return False;
2357 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2358 return False;
2360 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2361 return False;
2363 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2364 gr1->hdr_acct_name.buffer, ps, depth))
2365 return False;
2367 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2368 gr1->hdr_acct_desc.buffer, ps, depth))
2369 return False;
2371 return True;
2374 /*******************************************************************
2375 inits a GROUP_INFO2 structure.
2376 ********************************************************************/
2378 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2380 DEBUG(5, ("init_samr_group_info2\n"));
2382 gr2->level = 2;
2383 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2384 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2387 /*******************************************************************
2388 reads or writes a structure.
2389 ********************************************************************/
2391 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2393 if (gr2 == NULL)
2394 return False;
2396 prs_debug(ps, depth, desc, "samr_io_group_info2");
2397 depth++;
2399 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2400 return False;
2402 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2403 return False;
2404 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2405 gr2->hdr_acct_name.buffer, ps, depth))
2406 return False;
2408 return True;
2411 /*******************************************************************
2412 inits a GROUP_INFO3 structure.
2413 ********************************************************************/
2415 void init_samr_group_info3(GROUP_INFO3 *gr3)
2417 DEBUG(5, ("init_samr_group_info3\n"));
2419 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2422 /*******************************************************************
2423 reads or writes a structure.
2424 ********************************************************************/
2426 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2428 if (gr3 == NULL)
2429 return False;
2431 prs_debug(ps, depth, desc, "samr_io_group_info3");
2432 depth++;
2434 if(!prs_align(ps))
2435 return False;
2437 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2438 return False;
2440 return True;
2443 /*******************************************************************
2444 inits a GROUP_INFO4 structure.
2445 ********************************************************************/
2447 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2449 DEBUG(5, ("init_samr_group_info4\n"));
2451 gr4->level = 4;
2452 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2453 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2456 /*******************************************************************
2457 reads or writes a structure.
2458 ********************************************************************/
2460 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2461 prs_struct *ps, int depth)
2463 if (gr4 == NULL)
2464 return False;
2466 prs_debug(ps, depth, desc, "samr_io_group_info4");
2467 depth++;
2469 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2470 return False;
2471 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2472 return False;
2473 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2474 gr4->hdr_acct_desc.buffer, ps, depth))
2475 return False;
2477 return True;
2480 /*******************************************************************
2481 inits a GROUP_INFO5 structure.
2482 ********************************************************************/
2484 void init_samr_group_info5(GROUP_INFO5 * gr5,
2485 char *acct_name, char *acct_desc,
2486 uint32 num_members)
2488 DEBUG(5, ("init_samr_group_info5\n"));
2490 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2491 gr5->num_members = num_members;
2493 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2494 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2495 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2496 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2499 /*******************************************************************
2500 reads or writes a structure.
2501 ********************************************************************/
2503 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2504 prs_struct *ps, int depth)
2506 uint16 dummy = 1;
2508 if (gr5 == NULL)
2509 return False;
2511 prs_debug(ps, depth, desc, "samr_io_group_info5");
2512 depth++;
2514 if(!prs_uint16("level", ps, depth, &dummy))
2515 return False;
2517 if(!prs_align(ps))
2518 return False;
2520 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2521 return False;
2523 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2524 return False;
2525 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2526 return False;
2528 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2529 return False;
2531 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2532 gr5->hdr_acct_name.buffer, ps, depth))
2533 return False;
2535 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2536 gr5->hdr_acct_desc.buffer, ps, depth))
2537 return False;
2539 return True;
2543 /*******************************************************************
2544 reads or writes a structure.
2545 ********************************************************************/
2547 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2548 prs_struct *ps, int depth)
2550 if (UNMARSHALLING(ps))
2551 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2553 if (*ctr == NULL)
2554 return False;
2556 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2557 depth++;
2559 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2560 return False;
2562 switch ((*ctr)->switch_value1) {
2563 case 1:
2564 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2565 return False;
2566 break;
2567 case 2:
2568 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2569 return False;
2570 break;
2571 case 3:
2572 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2573 return False;
2574 break;
2575 case 4:
2576 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2577 return False;
2578 break;
2579 case 5:
2580 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2581 return False;
2582 break;
2583 default:
2584 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2585 break;
2588 return True;
2591 /*******************************************************************
2592 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2593 ********************************************************************/
2595 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2596 POLICY_HND *pol, const char *acct_desc,
2597 uint32 access_mask)
2599 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2601 q_e->pol = *pol;
2603 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2604 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2606 q_e->access_mask = access_mask;
2609 /*******************************************************************
2610 reads or writes a structure.
2611 ********************************************************************/
2613 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2614 prs_struct *ps, int depth)
2616 if (q_e == NULL)
2617 return False;
2619 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2620 depth++;
2622 if(!prs_align(ps))
2623 return False;
2625 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2626 return False;
2628 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2629 return False;
2630 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2631 q_e->hdr_acct_desc.buffer, ps, depth))
2632 return False;
2634 if(!prs_align(ps))
2635 return False;
2636 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2637 return False;
2639 return True;
2642 /*******************************************************************
2643 reads or writes a structure.
2644 ********************************************************************/
2646 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2647 prs_struct *ps, int depth)
2649 if (r_u == NULL)
2650 return False;
2652 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2653 depth++;
2655 if(!prs_align(ps))
2656 return False;
2658 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2659 return False;
2661 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2662 return False;
2663 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2664 return False;
2666 return True;
2669 /*******************************************************************
2670 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2671 ********************************************************************/
2673 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2674 POLICY_HND *hnd)
2676 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2678 q_c->group_pol = *hnd;
2681 /*******************************************************************
2682 reads or writes a structure.
2683 ********************************************************************/
2685 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2686 prs_struct *ps, int depth)
2688 if (q_u == NULL)
2689 return False;
2691 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2692 depth++;
2694 if(!prs_align(ps))
2695 return False;
2697 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2698 return False;
2700 return True;
2703 /*******************************************************************
2704 reads or writes a structure.
2705 ********************************************************************/
2707 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2708 prs_struct *ps, int depth)
2710 if (r_u == NULL)
2711 return False;
2713 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2714 depth++;
2716 if(!prs_align(ps))
2717 return False;
2719 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2720 return False;
2722 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2723 return False;
2725 return True;
2728 /*******************************************************************
2729 inits a SAMR_Q_DEL_GROUPMEM structure.
2730 ********************************************************************/
2732 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2733 POLICY_HND *pol, uint32 rid)
2735 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2737 q_e->pol = *pol;
2738 q_e->rid = rid;
2741 /*******************************************************************
2742 reads or writes a structure.
2743 ********************************************************************/
2745 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2746 prs_struct *ps, int depth)
2748 if (q_e == NULL)
2749 return False;
2751 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2752 depth++;
2754 if(!prs_align(ps))
2755 return False;
2757 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2758 return False;
2760 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2761 return False;
2763 return True;
2766 /*******************************************************************
2767 inits a SAMR_R_DEL_GROUPMEM structure.
2768 ********************************************************************/
2770 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2771 NTSTATUS status)
2773 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2775 r_u->status = status;
2778 /*******************************************************************
2779 reads or writes a structure.
2780 ********************************************************************/
2782 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2783 prs_struct *ps, int depth)
2785 if (r_u == NULL)
2786 return False;
2788 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2789 depth++;
2791 if(!prs_align(ps))
2792 return False;
2794 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2795 return False;
2797 return True;
2800 /*******************************************************************
2801 inits a SAMR_Q_ADD_GROUPMEM structure.
2802 ********************************************************************/
2804 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2805 POLICY_HND *pol, uint32 rid)
2807 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2809 q_e->pol = *pol;
2810 q_e->rid = rid;
2811 q_e->unknown = 0x0005;
2814 /*******************************************************************
2815 reads or writes a structure.
2816 ********************************************************************/
2818 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2819 prs_struct *ps, int depth)
2821 if (q_e == NULL)
2822 return False;
2824 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2825 depth++;
2827 if(!prs_align(ps))
2828 return False;
2830 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2831 return False;
2833 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2834 return False;
2835 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2836 return False;
2838 return True;
2841 /*******************************************************************
2842 inits a SAMR_R_ADD_GROUPMEM structure.
2843 ********************************************************************/
2845 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2846 NTSTATUS status)
2848 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2850 r_u->status = status;
2853 /*******************************************************************
2854 reads or writes a structure.
2855 ********************************************************************/
2857 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2858 prs_struct *ps, int depth)
2860 if (r_u == NULL)
2861 return False;
2863 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2864 depth++;
2866 if(!prs_align(ps))
2867 return False;
2869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2870 return False;
2872 return True;
2875 /*******************************************************************
2876 inits a SAMR_Q_SET_GROUPINFO structure.
2877 ********************************************************************/
2879 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2880 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2882 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2884 q_e->pol = *pol;
2885 q_e->ctr = ctr;
2888 /*******************************************************************
2889 reads or writes a structure.
2890 ********************************************************************/
2892 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2893 prs_struct *ps, int depth)
2895 if (q_e == NULL)
2896 return False;
2898 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2899 depth++;
2901 if(!prs_align(ps))
2902 return False;
2904 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2905 return False;
2907 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2908 return False;
2910 return True;
2913 /*******************************************************************
2914 inits a SAMR_R_SET_GROUPINFO structure.
2915 ********************************************************************/
2917 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2919 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2921 r_u->status = status;
2924 /*******************************************************************
2925 reads or writes a structure.
2926 ********************************************************************/
2928 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2929 prs_struct *ps, int depth)
2931 if (r_u == NULL)
2932 return False;
2934 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2935 depth++;
2937 if(!prs_align(ps))
2938 return False;
2940 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2941 return False;
2943 return True;
2946 /*******************************************************************
2947 inits a SAMR_Q_QUERY_GROUPINFO structure.
2948 ********************************************************************/
2950 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2951 POLICY_HND *pol, uint16 switch_level)
2953 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2955 q_e->pol = *pol;
2957 q_e->switch_level = switch_level;
2960 /*******************************************************************
2961 reads or writes a structure.
2962 ********************************************************************/
2964 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2965 prs_struct *ps, int depth)
2967 if (q_e == NULL)
2968 return False;
2970 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2971 depth++;
2973 if(!prs_align(ps))
2974 return False;
2976 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2977 return False;
2979 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2980 return False;
2982 return True;
2985 /*******************************************************************
2986 inits a SAMR_R_QUERY_GROUPINFO structure.
2987 ********************************************************************/
2989 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2990 GROUP_INFO_CTR * ctr, NTSTATUS status)
2992 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2994 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2995 r_u->ctr = ctr;
2996 r_u->status = status;
2999 /*******************************************************************
3000 reads or writes a structure.
3001 ********************************************************************/
3003 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
3004 prs_struct *ps, int depth)
3006 if (r_u == NULL)
3007 return False;
3009 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
3010 depth++;
3012 if(!prs_align(ps))
3013 return False;
3015 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3016 return False;
3018 if (r_u->ptr != 0) {
3019 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
3020 return False;
3023 if(!prs_align(ps))
3024 return False;
3025 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3026 return False;
3028 return True;
3031 /*******************************************************************
3032 inits a SAMR_Q_QUERY_GROUPMEM structure.
3033 ********************************************************************/
3035 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
3037 DEBUG(5, ("init_samr_q_query_groupmem\n"));
3039 q_c->group_pol = *hnd;
3042 /*******************************************************************
3043 reads or writes a structure.
3044 ********************************************************************/
3046 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
3047 prs_struct *ps, int depth)
3049 if (q_u == NULL)
3050 return False;
3052 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
3053 depth++;
3055 if(!prs_align(ps))
3056 return False;
3058 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
3059 return False;
3061 return True;
3064 /*******************************************************************
3065 inits a SAMR_R_QUERY_GROUPMEM structure.
3066 ********************************************************************/
3068 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
3069 uint32 num_entries, uint32 *rid,
3070 uint32 *attr, NTSTATUS status)
3072 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3074 if (NT_STATUS_IS_OK(status)) {
3075 r_u->ptr = 1;
3076 r_u->num_entries = num_entries;
3078 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3079 r_u->ptr_rids = rid != NULL ? 1 : 0;
3081 r_u->num_rids = num_entries;
3082 r_u->rid = rid;
3084 r_u->num_attrs = num_entries;
3085 r_u->attr = attr;
3086 } else {
3087 r_u->ptr = 0;
3088 r_u->num_entries = 0;
3091 r_u->status = status;
3094 /*******************************************************************
3095 reads or writes a structure.
3096 ********************************************************************/
3098 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3099 prs_struct *ps, int depth)
3101 uint32 i;
3103 if (r_u == NULL)
3104 return False;
3106 if (UNMARSHALLING(ps))
3107 ZERO_STRUCTP(r_u);
3109 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3110 depth++;
3112 if(!prs_align(ps))
3113 return False;
3115 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3116 return False;
3117 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3118 return False;
3120 if (r_u->ptr != 0) {
3121 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3122 return False;
3123 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3124 return False;
3126 if (r_u->ptr_rids != 0) {
3127 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3128 return False;
3129 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3130 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3131 if (r_u->rid == NULL)
3132 return False;
3135 for (i = 0; i < r_u->num_rids; i++) {
3136 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3137 return False;
3141 if (r_u->ptr_attrs != 0) {
3142 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3143 return False;
3145 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3146 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3147 if (r_u->attr == NULL)
3148 return False;
3151 for (i = 0; i < r_u->num_attrs; i++) {
3152 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3153 return False;
3158 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3159 return False;
3161 return True;
3164 /*******************************************************************
3165 inits a SAMR_Q_QUERY_USERGROUPS structure.
3166 ********************************************************************/
3168 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3169 POLICY_HND *hnd)
3171 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3173 q_u->pol = *hnd;
3176 /*******************************************************************
3177 reads or writes a structure.
3178 ********************************************************************/
3180 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3181 prs_struct *ps, int depth)
3183 if (q_u == NULL)
3184 return False;
3186 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3187 depth++;
3189 if(!prs_align(ps))
3190 return False;
3192 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3193 return False;
3195 return True;
3198 /*******************************************************************
3199 inits a SAMR_R_QUERY_USERGROUPS structure.
3200 ********************************************************************/
3202 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3203 uint32 num_gids, DOM_GID * gid,
3204 NTSTATUS status)
3206 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3208 if (NT_STATUS_IS_OK(status)) {
3209 r_u->ptr_0 = 1;
3210 r_u->num_entries = num_gids;
3211 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3212 r_u->num_entries2 = num_gids;
3214 r_u->gid = gid;
3215 } else {
3216 r_u->ptr_0 = 0;
3217 r_u->num_entries = 0;
3218 r_u->ptr_1 = 0;
3219 r_u->gid = NULL;
3222 r_u->status = status;
3225 /*******************************************************************
3226 reads or writes a structure.
3227 ********************************************************************/
3229 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3230 prs_struct *ps, int depth)
3232 uint32 i;
3233 if (gid == NULL)
3234 return False;
3236 prs_debug(ps, depth, desc, "samr_io_gids");
3237 depth++;
3239 if(!prs_align(ps))
3240 return False;
3242 if(!prs_uint32("num_gids", ps, depth, num_gids))
3243 return False;
3245 if ((*num_gids) != 0) {
3246 if (UNMARSHALLING(ps)) {
3247 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3250 if ((*gid) == NULL) {
3251 return False;
3254 for (i = 0; i < (*num_gids); i++) {
3255 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3256 return False;
3260 return True;
3263 /*******************************************************************
3264 reads or writes a structure.
3265 ********************************************************************/
3267 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3268 prs_struct *ps, int depth)
3270 if (r_u == NULL)
3271 return False;
3273 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3274 depth++;
3276 if(!prs_align(ps))
3277 return False;
3279 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3280 return False;
3282 if (r_u->ptr_0 != 0) {
3283 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3284 return False;
3285 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3286 return False;
3288 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3289 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3290 return False;
3294 if(!prs_align(ps))
3295 return False;
3296 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3297 return False;
3299 return True;
3302 /*******************************************************************
3303 inits a SAMR_Q_ENUM_DOMAINS structure.
3304 ********************************************************************/
3306 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3307 POLICY_HND *pol,
3308 uint32 start_idx, uint32 size)
3310 DEBUG(5, ("init_samr_q_enum_domains\n"));
3312 q_e->pol = *pol;
3314 q_e->start_idx = start_idx;
3315 q_e->max_size = size;
3318 /*******************************************************************
3319 reads or writes a structure.
3320 ********************************************************************/
3322 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3323 prs_struct *ps, int depth)
3325 if (q_e == NULL)
3326 return False;
3328 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3329 depth++;
3331 if(!prs_align(ps))
3332 return False;
3334 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3335 return False;
3337 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3338 return False;
3339 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3340 return False;
3342 return True;
3345 /*******************************************************************
3346 inits a SAMR_R_ENUM_DOMAINS structure.
3347 ********************************************************************/
3349 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3350 uint32 next_idx, uint32 num_sam_entries)
3352 DEBUG(5, ("init_samr_r_enum_domains\n"));
3354 r_u->next_idx = next_idx;
3356 if (num_sam_entries != 0) {
3357 r_u->ptr_entries1 = 1;
3358 r_u->ptr_entries2 = 1;
3359 r_u->num_entries2 = num_sam_entries;
3360 r_u->num_entries3 = num_sam_entries;
3362 r_u->num_entries4 = num_sam_entries;
3363 } else {
3364 r_u->ptr_entries1 = 0;
3365 r_u->num_entries2 = num_sam_entries;
3366 r_u->ptr_entries2 = 1;
3370 /*******************************************************************
3371 reads or writes a structure.
3372 ********************************************************************/
3374 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3375 prs_struct *ps, int depth)
3377 uint32 i;
3379 if (r_u == NULL)
3380 return False;
3382 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3383 depth++;
3385 if(!prs_align(ps))
3386 return False;
3388 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3389 return False;
3390 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3391 return False;
3393 if (r_u->ptr_entries1 != 0) {
3394 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3395 return False;
3396 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3397 return False;
3398 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3399 return False;
3401 if (UNMARSHALLING(ps)) {
3402 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3403 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3406 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3407 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3408 r_u->num_entries4 = 0;
3409 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3410 return False;
3413 for (i = 0; i < r_u->num_entries2; i++) {
3414 fstring tmp;
3415 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3416 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3417 return False;
3420 for (i = 0; i < r_u->num_entries2; i++) {
3421 fstring tmp;
3422 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3423 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3424 r_u->sam[i].hdr_name.buffer, ps,
3425 depth))
3426 return False;
3431 if(!prs_align(ps))
3432 return False;
3433 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3434 return False;
3435 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3436 return False;
3438 return True;
3441 /*******************************************************************
3442 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3443 ********************************************************************/
3445 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3446 POLICY_HND *pol,
3447 uint32 start_idx, uint32 size)
3449 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3451 q_e->pol = *pol;
3453 q_e->start_idx = start_idx;
3454 q_e->max_size = size;
3457 /*******************************************************************
3458 reads or writes a structure.
3459 ********************************************************************/
3461 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3462 prs_struct *ps, int depth)
3464 if (q_e == NULL)
3465 return False;
3467 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3468 depth++;
3470 if(!prs_align(ps))
3471 return False;
3473 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3474 return False;
3476 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3477 return False;
3478 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3479 return False;
3481 return True;
3484 /*******************************************************************
3485 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3486 ********************************************************************/
3488 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3489 uint32 next_idx, uint32 num_sam_entries)
3491 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3493 r_u->next_idx = next_idx;
3495 if (num_sam_entries != 0) {
3496 r_u->ptr_entries1 = 1;
3497 r_u->ptr_entries2 = 1;
3498 r_u->num_entries2 = num_sam_entries;
3499 r_u->num_entries3 = num_sam_entries;
3501 r_u->num_entries4 = num_sam_entries;
3502 } else {
3503 r_u->ptr_entries1 = 0;
3504 r_u->num_entries2 = num_sam_entries;
3505 r_u->ptr_entries2 = 1;
3509 /*******************************************************************
3510 reads or writes a structure.
3511 ********************************************************************/
3513 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3514 prs_struct *ps, int depth)
3516 uint32 i;
3518 if (r_u == NULL)
3519 return False;
3521 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3522 depth++;
3524 if(!prs_align(ps))
3525 return False;
3527 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3528 return False;
3529 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3530 return False;
3532 if (r_u->ptr_entries1 != 0) {
3533 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3534 return False;
3535 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3536 return False;
3537 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3538 return False;
3540 if (UNMARSHALLING(ps)) {
3541 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3542 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3545 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3546 DEBUG(0,
3547 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3548 r_u->num_entries4 = 0;
3549 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3550 return False;
3553 for (i = 0; i < r_u->num_entries2; i++) {
3554 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3555 return False;
3558 for (i = 0; i < r_u->num_entries2; i++) {
3559 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3560 r_u->sam[i].hdr_name.buffer, ps, depth))
3561 return False;
3565 if(!prs_align(ps))
3566 return False;
3567 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3568 return False;
3569 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3570 return False;
3572 return True;
3575 /*******************************************************************
3576 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3577 ********************************************************************/
3579 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3580 POLICY_HND *pol, uint32 start_idx,
3581 uint32 size)
3583 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3585 q_e->pol = *pol;
3587 q_e->start_idx = start_idx;
3588 q_e->max_size = size;
3592 /*******************************************************************
3593 reads or writes a structure.
3594 ********************************************************************/
3596 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3597 prs_struct *ps, int depth)
3599 if (q_e == NULL)
3600 return False;
3602 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3603 depth++;
3605 if(!prs_align(ps))
3606 return False;
3608 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3609 return False;
3611 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3612 return False;
3613 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3614 return False;
3616 return True;
3619 /*******************************************************************
3620 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3621 ********************************************************************/
3623 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3625 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3627 r_u->next_idx = next_idx;
3629 if (num_sam_entries != 0) {
3630 r_u->ptr_entries1 = 1;
3631 r_u->ptr_entries2 = 1;
3632 r_u->num_entries2 = num_sam_entries;
3633 r_u->num_entries3 = num_sam_entries;
3635 r_u->num_entries4 = num_sam_entries;
3636 } else {
3637 r_u->ptr_entries1 = 0;
3638 r_u->num_entries2 = num_sam_entries;
3639 r_u->ptr_entries2 = 1;
3643 /*******************************************************************
3644 reads or writes a structure.
3645 ********************************************************************/
3647 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3648 prs_struct *ps, int depth)
3650 uint32 i;
3652 if (r_u == NULL)
3653 return False;
3655 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3656 depth++;
3658 if(!prs_align(ps))
3659 return False;
3661 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3662 return False;
3663 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3664 return False;
3666 if (r_u->ptr_entries1 != 0) {
3667 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3668 return False;
3669 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3670 return False;
3671 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3672 return False;
3674 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3675 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3676 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3679 if (r_u->num_entries2 != 0 &&
3680 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3681 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3682 r_u->num_entries4 = 0;
3683 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3684 return False;
3687 for (i = 0; i < r_u->num_entries2; i++) {
3688 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3689 return False;
3692 for (i = 0; i < r_u->num_entries2; i++) {
3693 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3694 r_u->sam[i].hdr_name.buffer, ps,
3695 depth))
3696 return False;
3700 if(!prs_align(ps))
3701 return False;
3702 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3703 return False;
3704 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3705 return False;
3707 return True;
3710 /*******************************************************************
3711 inits a ALIAS_INFO1 structure.
3712 ********************************************************************/
3714 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3716 DEBUG(5, ("init_samr_alias_info1\n"));
3718 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3719 al1->num_member = num_member;
3720 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3723 /*******************************************************************
3724 reads or writes a structure.
3725 ********************************************************************/
3727 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3728 prs_struct *ps, int depth)
3730 if (al1 == NULL)
3731 return False;
3733 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3734 depth++;
3736 if(!prs_align(ps))
3737 return False;
3739 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3740 return False;
3741 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3742 return False;
3743 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3744 return False;
3746 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3747 return False;
3748 if ( !prs_align(ps) )
3749 return False;
3750 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3751 return False;
3752 if ( !prs_align(ps) )
3753 return False;
3755 return True;
3758 /*******************************************************************
3759 inits a ALIAS_INFO3 structure.
3760 ********************************************************************/
3762 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3764 DEBUG(5, ("init_samr_alias_info3\n"));
3766 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3769 /*******************************************************************
3770 reads or writes a structure.
3771 ********************************************************************/
3773 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3774 prs_struct *ps, int depth)
3776 if (al3 == NULL)
3777 return False;
3779 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3780 depth++;
3782 if(!prs_align(ps))
3783 return False;
3785 if (!prs_unistr4("description", ps, depth, &al3->description))
3786 return False;
3788 return True;
3791 /*******************************************************************
3792 reads or writes a structure.
3793 ********************************************************************/
3795 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3796 prs_struct *ps, int depth)
3798 if (al2 == NULL)
3799 return False;
3801 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3802 depth++;
3804 if(!prs_align(ps))
3805 return False;
3807 if (!prs_unistr4("name", ps, depth, &al2->name))
3808 return False;
3810 return True;
3813 /*******************************************************************
3814 reads or writes a structure.
3815 ********************************************************************/
3817 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3819 if ( !ctr )
3820 return False;
3822 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3823 depth++;
3825 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3826 return False;
3828 if(!prs_align(ps))
3829 return False;
3830 switch (ctr->level) {
3831 case 1:
3832 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3833 return False;
3834 break;
3835 case 2:
3836 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3837 return False;
3838 break;
3839 case 3:
3840 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3841 return False;
3842 break;
3843 default:
3844 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3845 break;
3848 return True;
3851 /*******************************************************************
3852 inits a SAMR_Q_QUERY_ALIASINFO structure.
3853 ********************************************************************/
3855 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3856 POLICY_HND *pol, uint32 switch_level)
3858 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3860 q_e->pol = *pol;
3861 q_e->level = switch_level;
3864 /*******************************************************************
3865 reads or writes a structure.
3866 ********************************************************************/
3868 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3869 prs_struct *ps, int depth)
3871 if ( !in )
3872 return False;
3874 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3875 depth++;
3877 if(!prs_align(ps))
3878 return False;
3880 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3881 return False;
3883 if ( !prs_uint16("level", ps, depth, &in->level) )
3884 return False;
3886 return True;
3889 /*******************************************************************
3890 inits a SAMR_R_QUERY_ALIASINFO structure.
3891 ********************************************************************/
3893 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3894 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3896 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3898 out->ctr = ctr;
3899 out->status = status;
3902 /*******************************************************************
3903 reads or writes a structure.
3904 ********************************************************************/
3906 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3907 prs_struct *ps, int depth)
3909 if ( !out )
3910 return False;
3912 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3913 depth++;
3915 if(!prs_align(ps))
3916 return False;
3918 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3919 return False;
3920 if(!prs_align(ps))
3921 return False;
3923 if(!prs_ntstatus("status", ps, depth, &out->status))
3924 return False;
3926 return True;
3929 /*******************************************************************
3930 inits a SAMR_Q_SET_ALIASINFO structure.
3931 ********************************************************************/
3933 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3934 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3936 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3938 q_u->alias_pol = *hnd;
3939 q_u->ctr = *ctr;
3942 /*******************************************************************
3943 reads or writes a structure.
3944 ********************************************************************/
3946 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3947 prs_struct *ps, int depth)
3949 if (q_u == NULL)
3950 return False;
3952 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3953 depth++;
3955 if(!prs_align(ps))
3956 return False;
3958 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3959 return False;
3960 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3961 return False;
3963 return True;
3966 /*******************************************************************
3967 reads or writes a structure.
3968 ********************************************************************/
3970 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3971 prs_struct *ps, int depth)
3973 if (r_u == NULL)
3974 return False;
3976 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3977 depth++;
3979 if(!prs_align(ps))
3980 return False;
3981 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3982 return False;
3984 return True;
3987 /*******************************************************************
3988 inits a SAMR_Q_QUERY_USERALIASES structure.
3989 ********************************************************************/
3991 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3992 POLICY_HND *hnd,
3993 uint32 num_sids,
3994 uint32 *ptr_sid, DOM_SID2 * sid)
3996 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3998 q_u->pol = *hnd;
4000 q_u->num_sids1 = num_sids;
4001 q_u->ptr = 1;
4002 q_u->num_sids2 = num_sids;
4004 q_u->ptr_sid = ptr_sid;
4005 q_u->sid = sid;
4008 /*******************************************************************
4009 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
4010 ********************************************************************/
4012 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
4013 prs_struct *ps, int depth)
4015 fstring tmp;
4016 uint32 i;
4018 if (q_u == NULL)
4019 return False;
4021 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
4022 depth++;
4024 if(!prs_align(ps))
4025 return False;
4027 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4028 return False;
4030 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
4031 return False;
4032 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4033 return False;
4035 if (q_u->ptr==0)
4036 return True;
4038 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
4039 return False;
4041 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
4042 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
4043 if (q_u->ptr_sid == NULL)
4044 return False;
4046 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
4047 if (q_u->sid == NULL)
4048 return False;
4051 for (i = 0; i < q_u->num_sids2; i++) {
4052 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
4053 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
4054 return False;
4057 for (i = 0; i < q_u->num_sids2; i++) {
4058 if (q_u->ptr_sid[i] != 0) {
4059 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
4060 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
4061 return False;
4065 return True;
4068 /*******************************************************************
4069 inits a SAMR_R_QUERY_USERALIASES structure.
4070 ********************************************************************/
4072 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4073 uint32 num_rids, uint32 *rid,
4074 NTSTATUS status)
4076 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4078 if (NT_STATUS_IS_OK(status)) {
4079 r_u->num_entries = num_rids;
4080 r_u->ptr = 1;
4081 r_u->num_entries2 = num_rids;
4083 r_u->rid = rid;
4084 } else {
4085 r_u->num_entries = 0;
4086 r_u->ptr = 0;
4087 r_u->num_entries2 = 0;
4090 r_u->status = status;
4093 /*******************************************************************
4094 reads or writes a structure.
4095 ********************************************************************/
4097 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4098 prs_struct *ps, int depth)
4100 fstring tmp;
4101 uint32 i;
4102 if (rid == NULL)
4103 return False;
4105 prs_debug(ps, depth, desc, "samr_io_rids");
4106 depth++;
4108 if(!prs_align(ps))
4109 return False;
4111 if(!prs_uint32("num_rids", ps, depth, num_rids))
4112 return False;
4114 if ((*num_rids) != 0) {
4115 if (UNMARSHALLING(ps)) {
4116 /* reading */
4117 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4119 if ((*rid) == NULL)
4120 return False;
4122 for (i = 0; i < (*num_rids); i++) {
4123 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4124 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4125 return False;
4129 return True;
4132 /*******************************************************************
4133 reads or writes a structure.
4134 ********************************************************************/
4136 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4137 prs_struct *ps, int depth)
4139 if (r_u == NULL)
4140 return False;
4142 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4143 depth++;
4145 if(!prs_align(ps))
4146 return False;
4148 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4149 return False;
4150 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4151 return False;
4153 if (r_u->ptr != 0) {
4154 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4155 return False;
4158 if(!prs_align(ps))
4159 return False;
4160 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4161 return False;
4163 return True;
4166 /*******************************************************************
4167 inits a SAMR_Q_OPEN_ALIAS structure.
4168 ********************************************************************/
4170 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4171 uint32 access_mask, uint32 rid)
4173 DEBUG(5, ("init_samr_q_open_alias\n"));
4175 q_u->dom_pol = *pol;
4176 q_u->access_mask = access_mask;
4177 q_u->rid_alias = rid;
4180 /*******************************************************************
4181 reads or writes a structure.
4182 ********************************************************************/
4184 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4185 prs_struct *ps, int depth)
4187 if (q_u == NULL)
4188 return False;
4190 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4191 depth++;
4193 if(!prs_align(ps))
4194 return False;
4196 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4197 return False;
4199 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4200 return False;
4201 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4202 return False;
4204 return True;
4207 /*******************************************************************
4208 reads or writes a structure.
4209 ********************************************************************/
4211 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4212 prs_struct *ps, int depth)
4214 if (r_u == NULL)
4215 return False;
4217 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4218 depth++;
4220 if(!prs_align(ps))
4221 return False;
4223 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4224 return False;
4226 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4227 return False;
4229 return True;
4232 /*******************************************************************
4233 inits a SAMR_Q_LOOKUP_RIDS structure.
4234 ********************************************************************/
4236 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4237 POLICY_HND *pol, uint32 flags,
4238 uint32 num_rids, uint32 *rid)
4240 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4242 q_u->pol = *pol;
4244 q_u->num_rids1 = num_rids;
4245 q_u->flags = flags;
4246 q_u->ptr = 0;
4247 q_u->num_rids2 = num_rids;
4248 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4249 if (q_u->rid == NULL) {
4250 q_u->num_rids1 = 0;
4251 q_u->num_rids2 = 0;
4252 } else {
4253 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4257 /*******************************************************************
4258 reads or writes a structure.
4259 ********************************************************************/
4261 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4262 prs_struct *ps, int depth)
4264 uint32 i;
4265 fstring tmp;
4267 if (q_u == NULL)
4268 return False;
4270 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4271 depth++;
4273 if (UNMARSHALLING(ps))
4274 ZERO_STRUCTP(q_u);
4276 if(!prs_align(ps))
4277 return False;
4279 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4280 return False;
4282 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4283 return False;
4284 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4285 return False;
4286 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4287 return False;
4288 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4289 return False;
4291 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4292 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4293 if (q_u->rid == NULL)
4294 return False;
4297 for (i = 0; i < q_u->num_rids2; i++) {
4298 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4299 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4300 return False;
4303 return True;
4306 /*******************************************************************
4307 inits a SAMR_R_LOOKUP_RIDS structure.
4308 ********************************************************************/
4310 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4311 uint32 num_names, UNIHDR * hdr_name,
4312 UNISTR2 *uni_name, uint32 *type)
4314 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4316 r_u->hdr_name = NULL;
4317 r_u->uni_name = NULL;
4318 r_u->type = NULL;
4320 if (num_names != 0) {
4321 r_u->num_names1 = num_names;
4322 r_u->ptr_names = 1;
4323 r_u->num_names2 = num_names;
4325 r_u->num_types1 = num_names;
4326 r_u->ptr_types = 1;
4327 r_u->num_types2 = num_names;
4329 r_u->hdr_name = hdr_name;
4330 r_u->uni_name = uni_name;
4331 r_u->type = type;
4332 } else {
4333 r_u->num_names1 = num_names;
4334 r_u->ptr_names = 0;
4335 r_u->num_names2 = num_names;
4337 r_u->num_types1 = num_names;
4338 r_u->ptr_types = 0;
4339 r_u->num_types2 = num_names;
4343 /*******************************************************************
4344 reads or writes a structure.
4345 ********************************************************************/
4347 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4348 prs_struct *ps, int depth)
4350 uint32 i;
4351 fstring tmp;
4352 if (r_u == NULL)
4353 return False;
4355 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4356 depth++;
4358 if(!prs_align(ps))
4359 return False;
4361 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4362 return False;
4363 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4364 return False;
4366 if (r_u->ptr_names != 0) {
4368 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4369 return False;
4372 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4373 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4374 if (r_u->hdr_name == NULL)
4375 return False;
4377 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4378 if (r_u->uni_name == NULL)
4379 return False;
4382 for (i = 0; i < r_u->num_names2; i++) {
4383 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4384 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4385 return False;
4387 for (i = 0; i < r_u->num_names2; i++) {
4388 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4389 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4390 return False;
4395 if(!prs_align(ps))
4396 return False;
4397 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4398 return False;
4399 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4400 return False;
4402 if (r_u->ptr_types != 0) {
4404 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4405 return False;
4407 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4408 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4409 if (r_u->type == NULL)
4410 return False;
4413 for (i = 0; i < r_u->num_types2; i++) {
4414 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4415 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4416 return False;
4420 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4421 return False;
4423 return True;
4426 /*******************************************************************
4427 inits a SAMR_Q_OPEN_ALIAS structure.
4428 ********************************************************************/
4430 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4432 DEBUG(5, ("init_samr_q_delete_alias\n"));
4434 q_u->alias_pol = *hnd;
4437 /*******************************************************************
4438 reads or writes a structure.
4439 ********************************************************************/
4441 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4442 prs_struct *ps, int depth)
4444 if (q_u == NULL)
4445 return False;
4447 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4448 depth++;
4450 if(!prs_align(ps))
4451 return False;
4453 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4454 return False;
4456 return True;
4459 /*******************************************************************
4460 reads or writes a structure.
4461 ********************************************************************/
4463 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4464 prs_struct *ps, int depth)
4466 if (r_u == NULL)
4467 return False;
4469 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4470 depth++;
4472 if(!prs_align(ps))
4473 return False;
4475 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4476 return False;
4477 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4478 return False;
4480 return True;
4483 /*******************************************************************
4484 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4485 ********************************************************************/
4487 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4488 POLICY_HND *hnd, const char *acct_desc)
4490 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4492 q_u->dom_pol = *hnd;
4494 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4495 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4497 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4500 /*******************************************************************
4501 reads or writes a structure.
4502 ********************************************************************/
4504 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4505 prs_struct *ps, int depth)
4507 if (q_u == NULL)
4508 return False;
4510 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4511 depth++;
4513 if(!prs_align(ps))
4514 return False;
4516 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4517 return False;
4519 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4520 return False;
4521 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4522 q_u->hdr_acct_desc.buffer, ps, depth))
4523 return False;
4525 if(!prs_align(ps))
4526 return False;
4527 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4528 return False;
4530 return True;
4533 /*******************************************************************
4534 reads or writes a structure.
4535 ********************************************************************/
4537 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4538 prs_struct *ps, int depth)
4540 if (r_u == NULL)
4541 return False;
4543 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4544 depth++;
4546 if(!prs_align(ps))
4547 return False;
4549 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4550 return False;
4552 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4553 return False;
4555 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4556 return False;
4558 return True;
4561 /*******************************************************************
4562 inits a SAMR_Q_ADD_ALIASMEM structure.
4563 ********************************************************************/
4565 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4566 DOM_SID *sid)
4568 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4570 q_u->alias_pol = *hnd;
4571 init_dom_sid2(&q_u->sid, sid);
4574 /*******************************************************************
4575 reads or writes a structure.
4576 ********************************************************************/
4578 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4579 prs_struct *ps, int depth)
4581 if (q_u == NULL)
4582 return False;
4584 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4585 depth++;
4587 if(!prs_align(ps))
4588 return False;
4590 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4591 return False;
4592 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4593 return False;
4595 return True;
4598 /*******************************************************************
4599 reads or writes a structure.
4600 ********************************************************************/
4602 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4603 prs_struct *ps, int depth)
4605 if (r_u == NULL)
4606 return False;
4608 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4609 depth++;
4611 if(!prs_align(ps))
4612 return False;
4614 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4615 return False;
4617 return True;
4620 /*******************************************************************
4621 inits a SAMR_Q_DEL_ALIASMEM structure.
4622 ********************************************************************/
4624 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4625 DOM_SID *sid)
4627 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4629 q_u->alias_pol = *hnd;
4630 init_dom_sid2(&q_u->sid, sid);
4633 /*******************************************************************
4634 reads or writes a structure.
4635 ********************************************************************/
4637 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4638 prs_struct *ps, int depth)
4640 if (q_u == NULL)
4641 return False;
4643 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4644 depth++;
4646 if(!prs_align(ps))
4647 return False;
4649 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4650 return False;
4651 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4652 return False;
4654 return True;
4657 /*******************************************************************
4658 reads or writes a structure.
4659 ********************************************************************/
4661 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4662 prs_struct *ps, int depth)
4664 if (r_u == NULL)
4665 return False;
4667 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4668 depth++;
4670 if(!prs_align(ps))
4671 return False;
4673 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4674 return False;
4676 return True;
4679 /*******************************************************************
4680 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4681 ********************************************************************/
4683 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4684 POLICY_HND *hnd)
4686 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4688 q_c->alias_pol = *hnd;
4691 /*******************************************************************
4692 reads or writes a structure.
4693 ********************************************************************/
4695 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4696 prs_struct *ps, int depth)
4698 if (q_u == NULL)
4699 return False;
4701 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4702 depth++;
4704 if(!prs_align(ps))
4705 return False;
4707 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4708 return False;
4710 return True;
4713 /*******************************************************************
4714 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4715 ********************************************************************/
4717 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4718 NTSTATUS status)
4720 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4722 r_u->status = status;
4725 /*******************************************************************
4726 reads or writes a structure.
4727 ********************************************************************/
4729 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4730 prs_struct *ps, int depth)
4732 if (r_u == NULL)
4733 return False;
4735 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4736 depth++;
4738 if(!prs_align(ps))
4739 return False;
4741 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4742 return False;
4744 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4745 return False;
4747 return True;
4750 /*******************************************************************
4751 inits a SAMR_Q_QUERY_ALIASMEM structure.
4752 ********************************************************************/
4754 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4755 POLICY_HND *hnd)
4757 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4759 q_c->alias_pol = *hnd;
4762 /*******************************************************************
4763 reads or writes a structure.
4764 ********************************************************************/
4766 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4767 prs_struct *ps, int depth)
4769 if (q_u == NULL)
4770 return False;
4772 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4773 depth++;
4775 if(!prs_align(ps))
4776 return False;
4778 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4779 return False;
4781 return True;
4784 /*******************************************************************
4785 inits a SAMR_R_QUERY_ALIASMEM structure.
4786 ********************************************************************/
4788 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4789 uint32 num_sids, DOM_SID2 * sid,
4790 NTSTATUS status)
4792 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4794 if (NT_STATUS_IS_OK(status)) {
4795 r_u->num_sids = num_sids;
4796 r_u->ptr = (num_sids != 0) ? 1 : 0;
4797 r_u->num_sids1 = num_sids;
4799 r_u->sid = sid;
4800 } else {
4801 r_u->ptr = 0;
4802 r_u->num_sids = 0;
4805 r_u->status = status;
4808 /*******************************************************************
4809 reads or writes a structure.
4810 ********************************************************************/
4812 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4813 prs_struct *ps, int depth)
4815 uint32 i;
4817 if (r_u == NULL)
4818 return False;
4820 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4821 depth++;
4823 if(!prs_align(ps))
4824 return False;
4826 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4827 return False;
4828 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4829 return False;
4831 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4832 uint32 *ptr_sid = NULL;
4834 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4835 return False;
4837 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4838 if (!ptr_sid) {
4839 return False;
4842 for (i = 0; i < r_u->num_sids1; i++) {
4843 ptr_sid[i] = 1;
4844 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4845 return False;
4848 if (UNMARSHALLING(ps)) {
4849 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4852 for (i = 0; i < r_u->num_sids1; i++) {
4853 if (ptr_sid[i] != 0) {
4854 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4855 return False;
4860 if(!prs_align(ps))
4861 return False;
4862 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4863 return False;
4865 return True;
4868 /*******************************************************************
4869 inits a SAMR_Q_LOOKUP_NAMES structure.
4870 ********************************************************************/
4872 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4873 POLICY_HND *pol, uint32 flags,
4874 uint32 num_names, const char **name)
4876 uint32 i;
4878 DEBUG(5, ("init_samr_q_lookup_names\n"));
4880 q_u->pol = *pol;
4882 q_u->num_names1 = num_names;
4883 q_u->flags = flags;
4884 q_u->ptr = 0;
4885 q_u->num_names2 = num_names;
4887 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4888 return NT_STATUS_NO_MEMORY;
4890 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4891 return NT_STATUS_NO_MEMORY;
4893 for (i = 0; i < num_names; i++) {
4894 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4895 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4898 return NT_STATUS_OK;
4901 /*******************************************************************
4902 reads or writes a structure.
4903 ********************************************************************/
4905 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4906 prs_struct *ps, int depth)
4908 uint32 i;
4910 if (q_u == NULL)
4911 return False;
4913 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4914 depth++;
4916 if (UNMARSHALLING(ps))
4917 ZERO_STRUCTP(q_u);
4919 if(!prs_align(ps))
4920 return False;
4922 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4923 return False;
4925 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4926 return False;
4927 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4928 return False;
4929 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4930 return False;
4931 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4932 return False;
4934 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4935 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4936 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4937 if (!q_u->hdr_name || !q_u->uni_name)
4938 return False;
4941 for (i = 0; i < q_u->num_names2; i++) {
4942 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4943 return False;
4946 for (i = 0; i < q_u->num_names2; i++) {
4947 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4948 return False;
4951 return True;
4954 /*******************************************************************
4955 inits a SAMR_R_LOOKUP_NAMES structure.
4956 ********************************************************************/
4958 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4959 uint32 num_rids,
4960 uint32 *rid, enum lsa_SidType *type,
4961 NTSTATUS status)
4963 DEBUG(5, ("init_samr_r_lookup_names\n"));
4965 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4966 uint32 i;
4968 r_u->num_types1 = num_rids;
4969 r_u->ptr_types = 1;
4970 r_u->num_types2 = num_rids;
4972 r_u->num_rids1 = num_rids;
4973 r_u->ptr_rids = 1;
4974 r_u->num_rids2 = num_rids;
4976 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4977 return NT_STATUS_NO_MEMORY;
4978 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4979 return NT_STATUS_NO_MEMORY;
4981 if (!r_u->rids || !r_u->types)
4982 goto empty;
4984 for (i = 0; i < num_rids; i++) {
4985 r_u->rids[i] = rid[i];
4986 r_u->types[i] = type[i];
4988 } else {
4990 empty:
4991 r_u->num_types1 = 0;
4992 r_u->ptr_types = 0;
4993 r_u->num_types2 = 0;
4995 r_u->num_rids1 = 0;
4996 r_u->ptr_rids = 0;
4997 r_u->num_rids2 = 0;
4999 r_u->rids = NULL;
5000 r_u->types = NULL;
5003 r_u->status = status;
5005 return NT_STATUS_OK;
5008 /*******************************************************************
5009 reads or writes a structure.
5010 ********************************************************************/
5012 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
5013 prs_struct *ps, int depth)
5015 uint32 i;
5016 fstring tmp;
5018 if (r_u == NULL)
5019 return False;
5021 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
5022 depth++;
5024 if (UNMARSHALLING(ps))
5025 ZERO_STRUCTP(r_u);
5027 if(!prs_align(ps))
5028 return False;
5030 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
5031 return False;
5032 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
5033 return False;
5035 if (r_u->ptr_rids != 0) {
5036 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
5037 return False;
5039 if (r_u->num_rids2 != r_u->num_rids1) {
5040 /* RPC fault */
5041 return False;
5044 if (UNMARSHALLING(ps))
5045 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
5047 if (!r_u->rids) {
5048 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
5049 return False;
5052 for (i = 0; i < r_u->num_rids2; i++) {
5053 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
5054 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
5055 return False;
5059 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
5060 return False;
5061 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5062 return False;
5064 if (r_u->ptr_types != 0) {
5065 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5066 return False;
5068 if (r_u->num_types2 != r_u->num_types1) {
5069 /* RPC fault */
5070 return False;
5073 if (UNMARSHALLING(ps))
5074 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5076 if (!r_u->types) {
5077 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5078 return False;
5081 for (i = 0; i < r_u->num_types2; i++) {
5082 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5083 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5084 return False;
5088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5089 return False;
5091 return True;
5094 /*******************************************************************
5095 inits a SAMR_Q_DELETE_DOM_USER structure.
5096 ********************************************************************/
5098 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5099 POLICY_HND *hnd)
5101 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5103 q_c->user_pol = *hnd;
5106 /*******************************************************************
5107 reads or writes a structure.
5108 ********************************************************************/
5110 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5111 prs_struct *ps, int depth)
5113 if (q_u == NULL)
5114 return False;
5116 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5117 depth++;
5119 if(!prs_align(ps))
5120 return False;
5122 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5123 return False;
5125 return True;
5128 /*******************************************************************
5129 reads or writes a structure.
5130 ********************************************************************/
5132 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5133 prs_struct *ps, int depth)
5135 if (r_u == NULL)
5136 return False;
5138 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5139 depth++;
5141 if(!prs_align(ps))
5142 return False;
5144 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5145 return False;
5146 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5147 return False;
5149 return True;
5152 /*******************************************************************
5153 reads or writes a structure.
5154 ********************************************************************/
5156 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5157 POLICY_HND *pol,
5158 uint32 access_mask, uint32 rid)
5160 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5162 q_u->domain_pol = *pol;
5163 q_u->access_mask = access_mask;
5164 q_u->user_rid = rid;
5167 /*******************************************************************
5168 reads or writes a structure.
5169 ********************************************************************/
5171 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5172 prs_struct *ps, int depth)
5174 if (q_u == NULL)
5175 return False;
5177 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5178 depth++;
5180 if(!prs_align(ps))
5181 return False;
5183 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5184 return False;
5186 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5187 return False;
5188 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5189 return False;
5191 return True;
5194 /*******************************************************************
5195 reads or writes a structure.
5196 ********************************************************************/
5198 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5199 prs_struct *ps, int depth)
5201 if (r_u == NULL)
5202 return False;
5204 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5205 depth++;
5207 if(!prs_align(ps))
5208 return False;
5210 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5211 return False;
5213 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5214 return False;
5216 return True;
5220 /*******************************************************************
5221 reads or writes a structure.
5222 ********************************************************************/
5224 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5225 POLICY_HND *pol,
5226 const char *name,
5227 uint32 acb_info, uint32 access_mask)
5229 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5231 q_u->domain_pol = *pol;
5233 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5234 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5236 q_u->acb_info = acb_info;
5237 q_u->access_mask = access_mask;
5240 /*******************************************************************
5241 reads or writes a structure.
5242 ********************************************************************/
5244 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5245 prs_struct *ps, int depth)
5247 if (q_u == NULL)
5248 return False;
5250 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5251 depth++;
5253 if(!prs_align(ps))
5254 return False;
5256 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5257 return False;
5259 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5260 return False;
5261 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5262 return False;
5264 if(!prs_align(ps))
5265 return False;
5266 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5267 return False;
5268 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5269 return False;
5271 return True;
5274 /*******************************************************************
5275 reads or writes a structure.
5276 ********************************************************************/
5278 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5279 prs_struct *ps, int depth)
5281 if (r_u == NULL)
5282 return False;
5284 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5285 depth++;
5287 if(!prs_align(ps))
5288 return False;
5290 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5291 return False;
5293 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5294 return False;
5295 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5296 return False;
5297 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5298 return False;
5300 return True;
5303 /*******************************************************************
5304 inits a SAMR_Q_QUERY_USERINFO structure.
5305 ********************************************************************/
5307 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5308 const POLICY_HND *hnd, uint16 switch_value)
5310 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5312 q_u->pol = *hnd;
5313 q_u->switch_value = switch_value;
5316 /*******************************************************************
5317 reads or writes a structure.
5318 ********************************************************************/
5320 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5321 prs_struct *ps, int depth)
5323 if (q_u == NULL)
5324 return False;
5326 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5327 depth++;
5329 if(!prs_align(ps))
5330 return False;
5332 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5333 return False;
5335 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5336 return False;
5338 return True;
5341 /*******************************************************************
5342 reads or writes a LOGON_HRS structure.
5343 ********************************************************************/
5345 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5346 prs_struct *ps, int depth)
5348 if (hrs == NULL)
5349 return False;
5351 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5352 depth++;
5354 if(!prs_align(ps))
5355 return False;
5357 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5358 return False;
5360 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5361 return False;
5363 if(!prs_uint32("len ", ps, depth, &hrs->len))
5364 return False;
5366 if (hrs->len > sizeof(hrs->hours)) {
5367 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5368 hrs->len = sizeof(hrs->hours);
5371 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5372 return False;
5374 return True;
5377 /*******************************************************************
5378 inits a SAM_USER_INFO_18 structure.
5379 ********************************************************************/
5381 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5382 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5384 DEBUG(5, ("init_sam_user_info18\n"));
5386 usr->lm_pwd_active =
5387 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5388 usr->nt_pwd_active =
5389 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5392 /*******************************************************************
5393 reads or writes a structure.
5394 ********************************************************************/
5396 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5397 prs_struct *ps, int depth)
5399 if (u == NULL)
5400 return False;
5402 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5403 depth++;
5405 if(!prs_align(ps))
5406 return False;
5408 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5409 return False;
5410 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5411 return False;
5413 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5414 return False;
5415 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5416 return False;
5418 return True;
5421 /*******************************************************************
5422 inits a SAM_USER_INFO_7 structure.
5423 ********************************************************************/
5425 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5427 DEBUG(5, ("init_sam_user_info7\n"));
5429 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5430 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5434 /*******************************************************************
5435 reads or writes a structure.
5436 ********************************************************************/
5438 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5439 prs_struct *ps, int depth)
5441 if (usr == NULL)
5442 return False;
5444 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5445 depth++;
5447 if(!prs_align(ps))
5448 return False;
5450 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5451 return False;
5453 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5454 return False;
5456 return True;
5459 /*******************************************************************
5460 inits a SAM_USER_INFO_9 structure.
5461 ********************************************************************/
5463 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5465 DEBUG(5, ("init_sam_user_info9\n"));
5467 usr->rid_group = rid_group;
5470 /*******************************************************************
5471 reads or writes a structure.
5472 ********************************************************************/
5474 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5475 prs_struct *ps, int depth)
5477 if (usr == NULL)
5478 return False;
5480 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5481 depth++;
5483 if(!prs_align(ps))
5484 return False;
5486 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5487 return False;
5489 return True;
5492 /*******************************************************************
5493 inits a SAM_USER_INFO_16 structure.
5494 ********************************************************************/
5496 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5498 DEBUG(5, ("init_sam_user_info16\n"));
5500 usr->acb_info = acb_info;
5503 /*******************************************************************
5504 reads or writes a structure.
5505 ********************************************************************/
5507 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5508 prs_struct *ps, int depth)
5510 if (usr == NULL)
5511 return False;
5513 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5514 depth++;
5516 if(!prs_align(ps))
5517 return False;
5519 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5520 return False;
5522 return True;
5525 /*******************************************************************
5526 inits a SAM_USER_INFO_17 structure.
5527 ********************************************************************/
5529 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5530 NTTIME * expiry,
5531 char *mach_acct,
5532 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5534 DEBUG(5, ("init_sam_user_info17\n"));
5536 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5537 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5539 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5541 usr->ptr_1 = 1; /* pointer */
5542 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5543 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5545 usr->ptr_2 = 1; /* pointer */
5546 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5548 usr->ptr_3 = 1; /* pointer */
5549 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5551 usr->rid_user = rid_user;
5552 usr->rid_group = rid_group;
5554 usr->acct_ctrl = acct_ctrl;
5555 usr->unknown_3 = 0x0000;
5557 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5558 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5560 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5561 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5563 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5564 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5567 /*******************************************************************
5568 reads or writes a structure.
5569 ********************************************************************/
5571 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5572 prs_struct *ps, int depth)
5574 if (usr == NULL)
5575 return False;
5577 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5578 depth++;
5580 if(!prs_align(ps))
5581 return False;
5583 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5584 return False;
5586 if(!smb_io_time("time", &usr->expiry, ps, depth))
5587 return False;
5589 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5590 return False;
5592 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5593 return False;
5595 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5596 return False;
5598 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5599 return False;
5600 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5601 return False;
5603 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5604 return False;
5606 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5607 return False;
5608 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5609 return False;
5611 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5612 return False;
5613 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5614 return False;
5616 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5617 return False;
5618 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5619 return False;
5620 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5621 return False;
5622 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5623 return False;
5624 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5625 return False;
5626 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5627 return False;
5629 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5630 return False;
5632 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5633 return False;
5635 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5636 return False;
5638 if(!prs_align(ps))
5639 return False;
5641 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5642 return False;
5644 return True;
5647 /*************************************************************************
5648 init_sam_user_infoa
5649 *************************************************************************/
5651 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5652 uint8 pw_len)
5654 DEBUG(10, ("init_sam_user_info24:\n"));
5655 memcpy(usr->pass, newpass, sizeof(usr->pass));
5656 usr->pw_len = pw_len;
5659 /*******************************************************************
5660 reads or writes a structure.
5661 ********************************************************************/
5663 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5664 prs_struct *ps, int depth)
5666 if (usr == NULL)
5667 return False;
5669 prs_debug(ps, depth, desc, "sam_io_user_info24");
5670 depth++;
5672 if(!prs_align(ps))
5673 return False;
5675 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5676 sizeof(usr->pass)))
5677 return False;
5679 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5680 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5681 return False;
5682 } else if (UNMARSHALLING(ps)) {
5683 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5684 return False;
5687 return True;
5690 /*******************************************************************
5691 reads or writes a structure.
5692 ********************************************************************/
5694 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5695 prs_struct *ps, int depth)
5697 if (usr == NULL)
5698 return False;
5700 prs_debug(ps, depth, desc, "sam_io_user_info26");
5701 depth++;
5703 if(!prs_align(ps))
5704 return False;
5706 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5707 sizeof(usr->pass)))
5708 return False;
5710 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5711 return False;
5713 return True;
5717 /*************************************************************************
5718 init_sam_user_info23
5720 unknown_6 = 0x0000 04ec
5722 *************************************************************************/
5724 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5725 NTTIME * logoff_time, /* all zeros */
5726 NTTIME * kickoff_time, /* all zeros */
5727 NTTIME * pass_last_set_time, /* all zeros */
5728 NTTIME * pass_can_change_time, /* all zeros */
5729 NTTIME * pass_must_change_time, /* all zeros */
5730 UNISTR2 *user_name,
5731 UNISTR2 *full_name,
5732 UNISTR2 *home_dir,
5733 UNISTR2 *dir_drive,
5734 UNISTR2 *log_scr,
5735 UNISTR2 *prof_path,
5736 UNISTR2 *desc,
5737 UNISTR2 *wkstas,
5738 UNISTR2 *unk_str,
5739 UNISTR2 *mung_dial,
5740 uint32 user_rid, /* 0x0000 0000 */
5741 uint32 group_rid,
5742 uint32 acb_info,
5743 uint32 fields_present,
5744 uint16 logon_divs,
5745 LOGON_HRS * hrs,
5746 uint16 bad_password_count,
5747 uint16 logon_count,
5748 char newpass[516])
5750 usr->logon_time = *logon_time; /* all zeros */
5751 usr->logoff_time = *logoff_time; /* all zeros */
5752 usr->kickoff_time = *kickoff_time; /* all zeros */
5753 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5754 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5755 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5757 ZERO_STRUCT(usr->nt_pwd);
5758 ZERO_STRUCT(usr->lm_pwd);
5760 usr->user_rid = user_rid; /* 0x0000 0000 */
5761 usr->group_rid = group_rid;
5762 usr->acb_info = acb_info;
5763 usr->fields_present = fields_present; /* 09f8 27fa */
5765 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5766 usr->ptr_logon_hrs = hrs ? 1 : 0;
5768 if (nt_time_is_zero(pass_must_change_time)) {
5769 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5770 } else {
5771 usr->passmustchange=0;
5774 ZERO_STRUCT(usr->padding1);
5775 ZERO_STRUCT(usr->padding2);
5777 usr->bad_password_count = bad_password_count;
5778 usr->logon_count = logon_count;
5780 memcpy(usr->pass, newpass, sizeof(usr->pass));
5782 copy_unistr2(&usr->uni_user_name, user_name);
5783 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5785 copy_unistr2(&usr->uni_full_name, full_name);
5786 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5788 copy_unistr2(&usr->uni_home_dir, home_dir);
5789 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5791 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5792 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5794 copy_unistr2(&usr->uni_logon_script, log_scr);
5795 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5797 copy_unistr2(&usr->uni_profile_path, prof_path);
5798 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5800 copy_unistr2(&usr->uni_acct_desc, desc);
5801 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5803 copy_unistr2(&usr->uni_workstations, wkstas);
5804 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5806 copy_unistr2(&usr->uni_comment, unk_str);
5807 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5809 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5810 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5812 if (hrs) {
5813 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5814 } else {
5815 ZERO_STRUCT(usr->logon_hrs);
5819 /*************************************************************************
5820 init_sam_user_info23
5822 unknown_6 = 0x0000 04ec
5824 *************************************************************************/
5826 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5827 NTTIME * logoff_time, /* all zeros */
5828 NTTIME * kickoff_time, /* all zeros */
5829 NTTIME * pass_last_set_time, /* all zeros */
5830 NTTIME * pass_can_change_time, /* all zeros */
5831 NTTIME * pass_must_change_time, /* all zeros */
5832 char *user_name, /* NULL */
5833 char *full_name,
5834 char *home_dir, char *dir_drive, char *log_scr,
5835 char *prof_path, const char *desc, char *wkstas,
5836 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5837 uint32 group_rid, uint32 acb_info,
5838 uint32 fields_present, uint16 logon_divs,
5839 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5840 char newpass[516])
5842 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5844 usr->logon_time = *logon_time; /* all zeros */
5845 usr->logoff_time = *logoff_time; /* all zeros */
5846 usr->kickoff_time = *kickoff_time; /* all zeros */
5847 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5848 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5849 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5851 ZERO_STRUCT(usr->nt_pwd);
5852 ZERO_STRUCT(usr->lm_pwd);
5854 usr->user_rid = user_rid; /* 0x0000 0000 */
5855 usr->group_rid = group_rid;
5856 usr->acb_info = acb_info;
5857 usr->fields_present = fields_present; /* 09f8 27fa */
5859 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5860 usr->ptr_logon_hrs = hrs ? 1 : 0;
5862 if (nt_time_is_zero(pass_must_change_time)) {
5863 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5864 } else {
5865 usr->passmustchange=0;
5868 ZERO_STRUCT(usr->padding1);
5869 ZERO_STRUCT(usr->padding2);
5871 usr->bad_password_count = bad_password_count;
5872 usr->logon_count = logon_count;
5874 memcpy(usr->pass, newpass, sizeof(usr->pass));
5876 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5877 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5879 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5880 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5882 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5883 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5885 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5886 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5888 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5889 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5891 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5892 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5894 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5895 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5897 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5898 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5900 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5901 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5903 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5904 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5906 data_blob_free(&blob);
5908 if (hrs) {
5909 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5910 } else {
5911 ZERO_STRUCT(usr->logon_hrs);
5915 /*******************************************************************
5916 reads or writes a structure.
5917 ********************************************************************/
5919 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5920 prs_struct *ps, int depth)
5922 if (usr == NULL)
5923 return False;
5925 prs_debug(ps, depth, desc, "sam_io_user_info23");
5926 depth++;
5928 if(!prs_align(ps))
5929 return False;
5931 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5932 return False;
5933 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5934 return False;
5935 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5936 return False;
5937 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5938 return False;
5939 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5940 return False;
5941 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5942 return False;
5944 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5945 return False;
5946 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5947 return False;
5948 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5949 return False;
5950 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5951 return False;
5952 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5953 return False;
5954 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5955 return False;
5956 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5957 return False;
5958 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5959 return False;
5960 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5961 return False;
5962 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5963 return False;
5965 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5966 return False;
5967 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5968 return False;
5970 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5971 return False;
5972 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5973 return False;
5974 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5975 return False;
5977 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5978 return False;
5979 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5980 return False;
5981 if(!prs_align(ps))
5982 return False;
5983 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5984 return False;
5986 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5987 return False;
5988 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5989 return False;
5991 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5992 return False;
5993 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5994 return False;
5995 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5996 return False;
5999 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6000 return False;
6002 /* here begins pointed-to data */
6004 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6005 return False;
6007 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6008 return False;
6010 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6011 return False;
6013 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6014 return False;
6016 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6017 return False;
6019 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6020 return False;
6022 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6023 return False;
6025 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6026 return False;
6028 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6029 return False;
6031 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6032 return False;
6034 /* ok, this is only guess-work (as usual) */
6035 if (usr->ptr_logon_hrs) {
6036 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6037 return False;
6040 return True;
6043 /*******************************************************************
6044 reads or writes a structure.
6045 NB. This structure is *definately* incorrect. It's my best guess
6046 currently for W2K SP2. The password field is encrypted in a different
6047 way than normal... And there are definately other problems. JRA.
6048 ********************************************************************/
6050 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
6052 if (usr == NULL)
6053 return False;
6055 prs_debug(ps, depth, desc, "sam_io_user_info25");
6056 depth++;
6058 if(!prs_align(ps))
6059 return False;
6061 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6062 return False;
6063 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6064 return False;
6065 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6066 return False;
6067 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6068 return False;
6069 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6070 return False;
6071 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6072 return False;
6074 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6075 return False;
6076 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6077 return False;
6078 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6079 return False;
6080 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6081 return False;
6082 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6083 return False;
6084 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6085 return False;
6086 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6087 return False;
6088 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6089 return False;
6090 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6091 return False;
6092 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6093 return False;
6095 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6096 return False;
6097 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6098 return False;
6100 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6101 return False;
6102 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6103 return False;
6104 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6105 return False;
6106 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6107 return False;
6109 if(!prs_uint32s(False, "unknown_5 ", ps, depth, usr->unknown_5, 5))
6110 return False;
6112 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6113 return False;
6115 /* here begins pointed-to data */
6117 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6118 return False;
6120 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6121 return False;
6123 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6124 return False;
6126 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6127 return False;
6129 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6130 return False;
6132 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6133 return False;
6135 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6136 return False;
6138 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6139 return False;
6141 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6142 return False;
6144 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6145 return False;
6147 #if 0 /* JRA - unknown... */
6148 /* ok, this is only guess-work (as usual) */
6149 if (usr->ptr_logon_hrs) {
6150 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6151 return False;
6153 #endif
6155 return True;
6159 /*************************************************************************
6160 init_sam_user_info21W
6162 unknown_6 = 0x0000 04ec
6164 *************************************************************************/
6166 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6167 NTTIME * logon_time,
6168 NTTIME * logoff_time,
6169 NTTIME * kickoff_time,
6170 NTTIME * pass_last_set_time,
6171 NTTIME * pass_can_change_time,
6172 NTTIME * pass_must_change_time,
6173 UNISTR2 *user_name,
6174 UNISTR2 *full_name,
6175 UNISTR2 *home_dir,
6176 UNISTR2 *dir_drive,
6177 UNISTR2 *log_scr,
6178 UNISTR2 *prof_path,
6179 UNISTR2 *desc,
6180 UNISTR2 *wkstas,
6181 UNISTR2 *unk_str,
6182 UNISTR2 *mung_dial,
6183 uchar lm_pwd[16],
6184 uchar nt_pwd[16],
6185 uint32 user_rid,
6186 uint32 group_rid,
6187 uint32 acb_info,
6188 uint32 fields_present,
6189 uint16 logon_divs,
6190 LOGON_HRS * hrs,
6191 uint16 bad_password_count,
6192 uint16 logon_count)
6194 usr->logon_time = *logon_time;
6195 usr->logoff_time = *logoff_time;
6196 usr->kickoff_time = *kickoff_time;
6197 usr->pass_last_set_time = *pass_last_set_time;
6198 usr->pass_can_change_time = *pass_can_change_time;
6199 usr->pass_must_change_time = *pass_must_change_time;
6201 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6202 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6204 usr->user_rid = user_rid;
6205 usr->group_rid = group_rid;
6206 usr->acb_info = acb_info;
6207 usr->fields_present = fields_present; /* 0x00ff ffff */
6209 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6210 usr->ptr_logon_hrs = hrs ? 1 : 0;
6211 usr->bad_password_count = bad_password_count;
6212 usr->logon_count = logon_count;
6214 if (nt_time_is_zero(pass_must_change_time)) {
6215 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6216 } else {
6217 usr->passmustchange=0;
6220 ZERO_STRUCT(usr->padding1);
6221 ZERO_STRUCT(usr->padding2);
6223 copy_unistr2(&usr->uni_user_name, user_name);
6224 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6226 copy_unistr2(&usr->uni_full_name, full_name);
6227 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6229 copy_unistr2(&usr->uni_home_dir, home_dir);
6230 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6232 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6233 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6235 copy_unistr2(&usr->uni_logon_script, log_scr);
6236 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6238 copy_unistr2(&usr->uni_profile_path, prof_path);
6239 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6241 copy_unistr2(&usr->uni_acct_desc, desc);
6242 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6244 copy_unistr2(&usr->uni_workstations, wkstas);
6245 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6247 copy_unistr2(&usr->uni_comment, unk_str);
6248 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6250 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6251 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6253 if (hrs) {
6254 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6255 } else {
6256 ZERO_STRUCT(usr->logon_hrs);
6260 /*************************************************************************
6261 init_sam_user_info21
6263 unknown_6 = 0x0000 04ec
6265 *************************************************************************/
6267 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6269 NTTIME logon_time, logoff_time, kickoff_time,
6270 pass_last_set_time, pass_can_change_time,
6271 pass_must_change_time;
6273 time_t must_change_time;
6274 const char* user_name = pdb_get_username(pw);
6275 const char* full_name = pdb_get_fullname(pw);
6276 const char* home_dir = pdb_get_homedir(pw);
6277 const char* dir_drive = pdb_get_dir_drive(pw);
6278 const char* logon_script = pdb_get_logon_script(pw);
6279 const char* profile_path = pdb_get_profile_path(pw);
6280 const char* description = pdb_get_acct_desc(pw);
6281 const char* workstations = pdb_get_workstations(pw);
6282 const char* munged_dial = pdb_get_munged_dial(pw);
6283 DATA_BLOB munged_dial_blob;
6285 uint32 user_rid;
6286 const DOM_SID *user_sid;
6288 uint32 group_rid;
6289 const DOM_SID *group_sid;
6291 if (munged_dial) {
6292 munged_dial_blob = base64_decode_data_blob(munged_dial);
6293 } else {
6294 munged_dial_blob = data_blob(NULL, 0);
6297 /* Create NTTIME structs */
6298 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6299 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6300 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6301 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6302 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
6303 must_change_time = pdb_get_pass_must_change_time(pw);
6304 if (must_change_time == get_time_t_max())
6305 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
6306 else
6307 unix_to_nt_time(&pass_must_change_time, must_change_time);
6309 /* structure assignment */
6310 usr->logon_time = logon_time;
6311 usr->logoff_time = logoff_time;
6312 usr->kickoff_time = kickoff_time;
6313 usr->pass_last_set_time = pass_last_set_time;
6314 usr->pass_can_change_time = pass_can_change_time;
6315 usr->pass_must_change_time = pass_must_change_time;
6317 ZERO_STRUCT(usr->nt_pwd);
6318 ZERO_STRUCT(usr->lm_pwd);
6320 user_sid = pdb_get_user_sid(pw);
6322 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6323 fstring user_sid_string;
6324 fstring domain_sid_string;
6325 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6326 "the domain sid %s. Failing operation.\n",
6327 user_name,
6328 sid_to_string(user_sid_string, user_sid),
6329 sid_to_string(domain_sid_string, domain_sid)));
6330 data_blob_free(&munged_dial_blob);
6331 return NT_STATUS_UNSUCCESSFUL;
6334 group_sid = pdb_get_group_sid(pw);
6336 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6337 fstring group_sid_string;
6338 fstring domain_sid_string;
6339 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6340 "which conflicts with the domain sid %s. Failing operation.\n",
6341 user_name,
6342 sid_to_string(group_sid_string, group_sid),
6343 sid_to_string(domain_sid_string, domain_sid)));
6344 data_blob_free(&munged_dial_blob);
6345 return NT_STATUS_UNSUCCESSFUL;
6348 usr->user_rid = user_rid;
6349 usr->group_rid = group_rid;
6350 usr->acb_info = pdb_get_acct_ctrl(pw);
6353 Look at a user on a real NT4 PDC with usrmgr, press
6354 'ok'. Then you will see that fields_present is set to
6355 0x08f827fa. Look at the user immediately after that again,
6356 and you will see that 0x00fffff is returned. This solves
6357 the problem that you get access denied after having looked
6358 at the user.
6359 -- Volker
6361 usr->fields_present = pdb_build_fields_present(pw);
6363 usr->logon_divs = pdb_get_logon_divs(pw);
6364 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6365 usr->bad_password_count = pdb_get_bad_password_count(pw);
6366 usr->logon_count = pdb_get_logon_count(pw);
6368 if (pdb_get_pass_must_change_time(pw) == 0) {
6369 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6370 } else {
6371 usr->passmustchange=0;
6374 ZERO_STRUCT(usr->padding1);
6375 ZERO_STRUCT(usr->padding2);
6377 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6378 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6380 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6381 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6383 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6384 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6386 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6387 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6389 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6390 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6392 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6393 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6395 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6396 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6398 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6399 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6401 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6402 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6404 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6405 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6406 data_blob_free(&munged_dial_blob);
6408 if (pdb_get_hours(pw)) {
6409 usr->logon_hrs.max_len = 1260;
6410 usr->logon_hrs.offset = 0;
6411 usr->logon_hrs.len = pdb_get_hours_len(pw);
6412 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6413 } else {
6414 usr->logon_hrs.max_len = 1260;
6415 usr->logon_hrs.offset = 0;
6416 usr->logon_hrs.len = 0;
6417 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6420 return NT_STATUS_OK;
6423 /*******************************************************************
6424 reads or writes a structure.
6425 ********************************************************************/
6427 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6428 prs_struct *ps, int depth)
6430 if (usr == NULL)
6431 return False;
6433 prs_debug(ps, depth, desc, "sam_io_user_info21");
6434 depth++;
6436 if(!prs_align(ps))
6437 return False;
6439 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6440 return False;
6441 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6442 return False;
6443 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6444 return False;
6445 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6446 return False;
6447 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6448 return False;
6449 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6450 return False;
6452 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6453 return False;
6454 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6455 return False;
6456 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6457 return False;
6458 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6459 return False;
6460 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6461 return False;
6462 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6463 return False;
6464 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6465 return False;
6466 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6467 return False;
6468 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6469 return False;
6470 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6471 return False;
6473 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6474 return False;
6475 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6476 return False;
6478 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6479 return False;
6480 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6481 return False;
6482 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6483 return False;
6485 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6486 return False;
6487 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6488 return False;
6489 if(!prs_align(ps))
6490 return False;
6491 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6492 return False;
6494 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6495 return False;
6496 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6497 return False;
6499 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6500 return False;
6501 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6502 return False;
6503 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6504 return False;
6506 /* here begins pointed-to data */
6508 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6509 return False;
6510 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6511 return False;
6512 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6513 return False;
6514 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6515 return False;
6516 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6517 return False;
6518 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6519 return False;
6520 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6521 return False;
6522 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6523 return False;
6524 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6525 return False;
6526 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6527 return False;
6529 /* ok, this is only guess-work (as usual) */
6530 if (usr->ptr_logon_hrs) {
6531 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6532 return False;
6535 return True;
6538 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6540 const char *munged_dial = pdb_get_munged_dial(pw);
6541 DATA_BLOB blob;
6543 if (munged_dial) {
6544 blob = base64_decode_data_blob(munged_dial);
6545 } else {
6546 blob = data_blob(NULL, 0);
6549 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6550 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6551 data_blob_free(&blob);
6554 /*******************************************************************
6555 reads or writes a structure.
6556 ********************************************************************/
6558 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6559 prs_struct *ps, int depth)
6561 if (usr == NULL)
6562 return False;
6564 prs_debug(ps, depth, desc, "sam_io_user_info20");
6565 depth++;
6567 if(!prs_align(ps))
6568 return False;
6570 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6571 return False;
6573 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6574 return False;
6576 return True;
6579 /*******************************************************************
6580 inits a SAM_USERINFO_CTR structure.
6581 ********************************************************************/
6583 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6584 uint16 switch_value,
6585 SAM_USER_INFO_21 * usr)
6587 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6589 ctr->switch_value = switch_value;
6590 ctr->info.id = NULL;
6592 switch (switch_value) {
6593 case 16:
6594 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6595 if (ctr->info.id16 == NULL)
6596 return NT_STATUS_NO_MEMORY;
6598 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6599 break;
6600 #if 0
6601 /* whoops - got this wrong. i think. or don't understand what's happening. */
6602 case 17:
6604 NTTIME expire;
6605 info = (void *)&id11;
6607 expire.low = 0xffffffff;
6608 expire.high = 0x7fffffff;
6610 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6611 init_sam_user_info11(ctr->info.id17, &expire,
6612 "BROOKFIELDS$", /* name */
6613 0x03ef, /* user rid */
6614 0x201, /* group rid */
6615 0x0080); /* acb info */
6617 break;
6619 #endif
6620 case 18:
6621 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6622 if (ctr->info.id18 == NULL)
6623 return NT_STATUS_NO_MEMORY;
6625 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6626 break;
6627 case 21:
6629 SAM_USER_INFO_21 *cusr;
6630 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6631 ctr->info.id21 = cusr;
6632 if (ctr->info.id21 == NULL)
6633 return NT_STATUS_NO_MEMORY;
6634 memcpy(cusr, usr, sizeof(*usr));
6635 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6636 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6637 break;
6639 default:
6640 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6641 return NT_STATUS_INVALID_INFO_CLASS;
6644 return NT_STATUS_OK;
6647 /*******************************************************************
6648 inits a SAM_USERINFO_CTR structure.
6649 ********************************************************************/
6651 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6652 uint16 switch_value, void *info)
6654 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6656 ctr->switch_value = switch_value;
6657 ctr->info.id = info;
6659 switch (switch_value) {
6660 case 0x18:
6661 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6662 dump_data(100, (char *)sess_key->data, sess_key->length);
6663 dump_data(100, (char *)ctr->info.id24->pass, 516);
6664 break;
6665 case 0x17:
6666 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6667 dump_data(100, (char *)sess_key->data, sess_key->length);
6668 dump_data(100, (char *)ctr->info.id23->pass, 516);
6669 break;
6670 case 0x07:
6671 break;
6672 default:
6673 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6677 /*******************************************************************
6678 reads or writes a structure.
6679 ********************************************************************/
6681 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6682 prs_struct *ps, int depth)
6684 BOOL ret;
6685 SAM_USERINFO_CTR *ctr;
6687 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6688 depth++;
6690 if (UNMARSHALLING(ps)) {
6691 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6692 if (ctr == NULL)
6693 return False;
6694 *ppctr = ctr;
6695 } else {
6696 ctr = *ppctr;
6699 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6701 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6702 return False;
6703 if(!prs_align(ps))
6704 return False;
6706 ret = False;
6708 switch (ctr->switch_value) {
6709 case 7:
6710 if (UNMARSHALLING(ps))
6711 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6712 if (ctr->info.id7 == NULL) {
6713 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6714 return False;
6716 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6717 break;
6718 case 9:
6719 if (UNMARSHALLING(ps))
6720 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6721 if (ctr->info.id9 == NULL) {
6722 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6723 return False;
6725 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6726 break;
6727 case 16:
6728 if (UNMARSHALLING(ps))
6729 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6730 if (ctr->info.id16 == NULL) {
6731 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6732 return False;
6734 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6735 break;
6736 case 17:
6737 if (UNMARSHALLING(ps))
6738 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6740 if (ctr->info.id17 == NULL) {
6741 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6742 return False;
6744 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6745 break;
6746 case 18:
6747 if (UNMARSHALLING(ps))
6748 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6750 if (ctr->info.id18 == NULL) {
6751 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6752 return False;
6754 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6755 break;
6756 case 20:
6757 if (UNMARSHALLING(ps))
6758 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6760 if (ctr->info.id20 == NULL) {
6761 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6762 return False;
6764 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6765 break;
6766 case 21:
6767 if (UNMARSHALLING(ps))
6768 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6770 if (ctr->info.id21 == NULL) {
6771 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6772 return False;
6774 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6775 break;
6776 case 23:
6777 if (UNMARSHALLING(ps))
6778 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6780 if (ctr->info.id23 == NULL) {
6781 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6782 return False;
6784 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6785 break;
6786 case 24:
6787 if (UNMARSHALLING(ps))
6788 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6790 if (ctr->info.id24 == NULL) {
6791 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6792 return False;
6794 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6795 break;
6796 case 25:
6797 if (UNMARSHALLING(ps))
6798 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6800 if (ctr->info.id25 == NULL) {
6801 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6802 return False;
6804 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6805 break;
6806 case 26:
6807 if (UNMARSHALLING(ps))
6808 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6810 if (ctr->info.id26 == NULL) {
6811 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6812 return False;
6814 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6815 break;
6816 default:
6817 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6818 ret = False;
6819 break;
6822 return ret;
6825 /*******************************************************************
6826 inits a SAMR_R_QUERY_USERINFO structure.
6827 ********************************************************************/
6829 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6830 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6832 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6834 r_u->ptr = 0;
6835 r_u->ctr = NULL;
6837 if (NT_STATUS_IS_OK(status)) {
6838 r_u->ptr = 1;
6839 r_u->ctr = ctr;
6842 r_u->status = status; /* return status */
6845 /*******************************************************************
6846 reads or writes a structure.
6847 ********************************************************************/
6849 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6850 prs_struct *ps, int depth)
6852 if (r_u == NULL)
6853 return False;
6855 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6856 depth++;
6858 if(!prs_align(ps))
6859 return False;
6861 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6862 return False;
6864 if (r_u->ptr != 0) {
6865 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6866 return False;
6869 if(!prs_align(ps))
6870 return False;
6871 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6872 return False;
6874 return True;
6877 /*******************************************************************
6878 inits a SAMR_Q_SET_USERINFO structure.
6879 ********************************************************************/
6881 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6882 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6883 uint16 switch_value, void *info)
6885 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6887 q_u->pol = *hnd;
6888 q_u->switch_value = switch_value;
6889 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6892 /*******************************************************************
6893 reads or writes a structure.
6894 ********************************************************************/
6896 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6897 prs_struct *ps, int depth)
6899 if (q_u == NULL)
6900 return False;
6902 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6903 depth++;
6905 if(!prs_align(ps))
6906 return False;
6908 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6910 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6911 return False;
6912 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6913 return False;
6915 return True;
6918 /*******************************************************************
6919 inits a SAMR_R_SET_USERINFO structure.
6920 ********************************************************************/
6922 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6924 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6926 r_u->status = status; /* return status */
6929 /*******************************************************************
6930 reads or writes a structure.
6931 ********************************************************************/
6933 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6934 prs_struct *ps, int depth)
6936 if (r_u == NULL)
6937 return False;
6939 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6940 depth++;
6942 if(!prs_align(ps))
6943 return False;
6945 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6946 return False;
6948 return True;
6951 /*******************************************************************
6952 inits a SAMR_Q_SET_USERINFO2 structure.
6953 ********************************************************************/
6955 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6956 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6957 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6959 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6961 q_u->pol = *hnd;
6962 q_u->switch_value = switch_value;
6963 q_u->ctr = ctr;
6965 q_u->ctr->switch_value = switch_value;
6967 switch (switch_value) {
6968 case 18:
6969 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6970 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6971 dump_data(100, (char *)sess_key->data, sess_key->length);
6972 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6973 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6974 break;
6978 /*******************************************************************
6979 reads or writes a structure.
6980 ********************************************************************/
6982 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6983 prs_struct *ps, int depth)
6985 if (q_u == NULL)
6986 return False;
6988 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6989 depth++;
6991 if(!prs_align(ps))
6992 return False;
6994 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6995 return False;
6997 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6998 return False;
6999 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
7000 return False;
7002 return True;
7005 /*******************************************************************
7006 inits a SAMR_R_SET_USERINFO2 structure.
7007 ********************************************************************/
7009 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
7011 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
7013 r_u->status = status; /* return status */
7016 /*******************************************************************
7017 reads or writes a structure.
7018 ********************************************************************/
7020 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
7021 prs_struct *ps, int depth)
7023 if (r_u == NULL)
7024 return False;
7026 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
7027 depth++;
7029 if(!prs_align(ps))
7030 return False;
7032 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7033 return False;
7035 return True;
7038 /*******************************************************************
7039 inits a SAMR_Q_CONNECT structure.
7040 ********************************************************************/
7042 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
7043 char *srv_name, uint32 access_mask)
7045 DEBUG(5, ("init_samr_q_connect\n"));
7047 /* make PDC server name \\server */
7048 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7049 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7051 /* example values: 0x0000 0002 */
7052 q_u->access_mask = access_mask;
7055 /*******************************************************************
7056 reads or writes a structure.
7057 ********************************************************************/
7059 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
7060 prs_struct *ps, int depth)
7062 if (q_u == NULL)
7063 return False;
7065 prs_debug(ps, depth, desc, "samr_io_q_connect");
7066 depth++;
7068 if(!prs_align(ps))
7069 return False;
7071 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7072 return False;
7073 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7074 return False;
7076 if(!prs_align(ps))
7077 return False;
7078 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7079 return False;
7081 return True;
7084 /*******************************************************************
7085 reads or writes a structure.
7086 ********************************************************************/
7088 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7089 prs_struct *ps, int depth)
7091 if (r_u == NULL)
7092 return False;
7094 prs_debug(ps, depth, desc, "samr_io_r_connect");
7095 depth++;
7097 if(!prs_align(ps))
7098 return False;
7100 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7101 return False;
7103 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7104 return False;
7106 return True;
7109 /*******************************************************************
7110 inits a SAMR_Q_CONNECT4 structure.
7111 ********************************************************************/
7113 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7114 char *srv_name, uint32 access_mask)
7116 DEBUG(5, ("init_samr_q_connect4\n"));
7118 /* make PDC server name \\server */
7119 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7120 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7122 /* Only value we've seen, possibly an address type ? */
7123 q_u->unk_0 = 2;
7125 /* example values: 0x0000 0002 */
7126 q_u->access_mask = access_mask;
7129 /*******************************************************************
7130 reads or writes a structure.
7131 ********************************************************************/
7133 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7134 prs_struct *ps, int depth)
7136 if (q_u == NULL)
7137 return False;
7139 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7140 depth++;
7142 if(!prs_align(ps))
7143 return False;
7145 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7146 return False;
7147 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7148 return False;
7150 if(!prs_align(ps))
7151 return False;
7152 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7153 return False;
7154 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7155 return False;
7157 return True;
7160 /*******************************************************************
7161 reads or writes a structure.
7162 ********************************************************************/
7164 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7165 prs_struct *ps, int depth)
7167 if (r_u == NULL)
7168 return False;
7170 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7171 depth++;
7173 if(!prs_align(ps))
7174 return False;
7176 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7177 return False;
7179 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7180 return False;
7182 return True;
7185 /*******************************************************************
7186 inits a SAMR_Q_CONNECT5 structure.
7187 ********************************************************************/
7189 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7190 char *srv_name, uint32 access_mask)
7192 DEBUG(5, ("init_samr_q_connect5\n"));
7194 /* make PDC server name \\server */
7195 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7196 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7198 /* example values: 0x0000 0002 */
7199 q_u->access_mask = access_mask;
7201 q_u->level = 1;
7202 q_u->info1_unk1 = 3;
7203 q_u->info1_unk2 = 0;
7206 /*******************************************************************
7207 inits a SAMR_R_CONNECT5 structure.
7208 ********************************************************************/
7210 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7212 DEBUG(5, ("init_samr_q_connect5\n"));
7214 r_u->level = 1;
7215 r_u->info1_unk1 = 3;
7216 r_u->info1_unk2 = 0;
7218 r_u->connect_pol = *pol;
7219 r_u->status = status;
7222 /*******************************************************************
7223 reads or writes a structure.
7224 ********************************************************************/
7226 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7227 prs_struct *ps, int depth)
7229 if (q_u == NULL)
7230 return False;
7232 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7233 depth++;
7235 if(!prs_align(ps))
7236 return False;
7238 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7239 return False;
7240 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7241 return False;
7243 if(!prs_align(ps))
7244 return False;
7245 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7246 return False;
7248 if(!prs_uint32("level", ps, depth, &q_u->level))
7249 return False;
7250 if(!prs_uint32("level", ps, depth, &q_u->level))
7251 return False;
7253 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7254 return False;
7255 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7256 return False;
7258 return True;
7261 /*******************************************************************
7262 reads or writes a structure.
7263 ********************************************************************/
7265 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7266 prs_struct *ps, int depth)
7268 if (r_u == NULL)
7269 return False;
7271 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7272 depth++;
7274 if(!prs_align(ps))
7275 return False;
7277 if(!prs_uint32("level", ps, depth, &r_u->level))
7278 return False;
7279 if(!prs_uint32("level", ps, depth, &r_u->level))
7280 return False;
7281 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7282 return False;
7283 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7284 return False;
7286 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7287 return False;
7289 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7290 return False;
7292 return True;
7295 /*******************************************************************
7296 inits a SAMR_Q_CONNECT_ANON structure.
7297 ********************************************************************/
7299 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7301 DEBUG(5, ("init_samr_q_connect_anon\n"));
7303 q_u->ptr = 1;
7304 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7305 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7308 /*******************************************************************
7309 reads or writes a structure.
7310 ********************************************************************/
7312 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7313 prs_struct *ps, int depth)
7315 if (q_u == NULL)
7316 return False;
7318 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7319 depth++;
7321 if(!prs_align(ps))
7322 return False;
7324 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7325 return False;
7326 if (q_u->ptr) {
7327 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7328 return False;
7330 if(!prs_align(ps))
7331 return False;
7332 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7333 return False;
7335 return True;
7338 /*******************************************************************
7339 reads or writes a structure.
7340 ********************************************************************/
7342 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7343 prs_struct *ps, int depth)
7345 if (r_u == NULL)
7346 return False;
7348 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7349 depth++;
7351 if(!prs_align(ps))
7352 return False;
7354 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7355 return False;
7357 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7358 return False;
7360 return True;
7363 /*******************************************************************
7364 inits a SAMR_Q_GET_DOM_PWINFO structure.
7365 ********************************************************************/
7367 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7368 char *srv_name)
7370 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7372 q_u->ptr = 1;
7373 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7374 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7377 /*******************************************************************
7378 reads or writes a structure.
7379 ********************************************************************/
7381 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7382 prs_struct *ps, int depth)
7384 if (q_u == NULL)
7385 return False;
7387 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7388 depth++;
7390 if(!prs_align(ps))
7391 return False;
7393 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7394 return False;
7395 if (q_u->ptr != 0) {
7396 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7397 return False;
7398 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7399 return False;
7402 return True;
7405 /*******************************************************************
7406 reads or writes a structure.
7407 ********************************************************************/
7409 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7410 prs_struct *ps, int depth)
7412 if (r_u == NULL)
7413 return False;
7415 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7416 depth++;
7418 if(!prs_align(ps))
7419 return False;
7421 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7422 return False;
7423 if(!prs_align(ps))
7424 return False;
7425 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7426 return False;
7428 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7429 return False;
7431 return True;
7434 /*******************************************************************
7435 make a SAMR_ENC_PASSWD structure.
7436 ********************************************************************/
7438 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7440 ZERO_STRUCTP(pwd);
7442 if (pass == NULL) {
7443 pwd->ptr = 0;
7444 } else {
7445 pwd->ptr = 1;
7446 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7450 /*******************************************************************
7451 reads or writes a SAMR_ENC_PASSWD structure.
7452 ********************************************************************/
7454 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7455 prs_struct *ps, int depth)
7457 if (pwd == NULL)
7458 return False;
7460 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7461 depth++;
7463 if(!prs_align(ps))
7464 return False;
7466 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7467 return False;
7469 if (pwd->ptr != 0) {
7470 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7471 return False;
7474 return True;
7477 /*******************************************************************
7478 inits a SAMR_ENC_HASH structure.
7479 ********************************************************************/
7481 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7483 ZERO_STRUCTP(hsh);
7485 if (hash == NULL) {
7486 hsh->ptr = 0;
7487 } else {
7488 hsh->ptr = 1;
7489 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7493 /*******************************************************************
7494 reads or writes a SAMR_ENC_HASH structure.
7495 ********************************************************************/
7497 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7498 prs_struct *ps, int depth)
7500 if (hsh == NULL)
7501 return False;
7503 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7504 depth++;
7506 if(!prs_align(ps))
7507 return False;
7509 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7510 return False;
7511 if (hsh->ptr != 0) {
7512 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7513 return False;
7516 return True;
7519 /*******************************************************************
7520 inits a SAMR_Q_CHGPASSWD_USER structure.
7521 ********************************************************************/
7523 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7524 const char *dest_host, const char *user_name,
7525 const uchar nt_newpass[516],
7526 const uchar nt_oldhash[16],
7527 const uchar lm_newpass[516],
7528 const uchar lm_oldhash[16])
7530 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7532 q_u->ptr_0 = 1;
7533 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7534 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7536 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7537 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7539 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7540 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7542 q_u->unknown = 0x01;
7544 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7545 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7548 /*******************************************************************
7549 reads or writes a structure.
7550 ********************************************************************/
7552 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7553 prs_struct *ps, int depth)
7555 if (q_u == NULL)
7556 return False;
7558 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7559 depth++;
7561 if(!prs_align(ps))
7562 return False;
7564 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7565 return False;
7567 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7568 return False;
7569 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7570 return False;
7572 if(!prs_align(ps))
7573 return False;
7574 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7575 return False;
7576 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7577 return False;
7579 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7580 return False;
7581 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7582 return False;
7584 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7585 return False;
7587 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7588 return False;
7589 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7590 return False;
7592 return True;
7595 /*******************************************************************
7596 inits a SAMR_R_CHGPASSWD_USER structure.
7597 ********************************************************************/
7599 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7601 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7603 r_u->status = status;
7606 /*******************************************************************
7607 reads or writes a structure.
7608 ********************************************************************/
7610 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7611 prs_struct *ps, int depth)
7613 if (r_u == NULL)
7614 return False;
7616 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7617 depth++;
7619 if(!prs_align(ps))
7620 return False;
7622 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7623 return False;
7625 return True;
7628 /*******************************************************************
7629 inits a SAMR_Q_CHGPASSWD3 structure.
7630 ********************************************************************/
7632 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7633 const char *dest_host, const char *user_name,
7634 const uchar nt_newpass[516],
7635 const uchar nt_oldhash[16],
7636 const uchar lm_newpass[516],
7637 const uchar lm_oldhash[16])
7639 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7641 q_u->ptr_0 = 1;
7642 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7643 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7645 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7646 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7648 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7649 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7651 q_u->lm_change = 0x01;
7653 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7654 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7656 init_enc_passwd(&q_u->password3, NULL);
7659 /*******************************************************************
7660 reads or writes a structure.
7661 ********************************************************************/
7663 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7664 prs_struct *ps, int depth)
7666 if (q_u == NULL)
7667 return False;
7669 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7670 depth++;
7672 if(!prs_align(ps))
7673 return False;
7675 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7676 return False;
7678 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7679 return False;
7680 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7681 return False;
7683 if(!prs_align(ps))
7684 return False;
7685 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7686 return False;
7687 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7688 return False;
7690 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7691 return False;
7692 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7693 return False;
7695 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7696 return False;
7698 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7699 return False;
7700 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7701 return False;
7703 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7704 return False;
7706 return True;
7709 /*******************************************************************
7710 inits a SAMR_R_CHGPASSWD_USER3 structure.
7711 ********************************************************************/
7713 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7714 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7716 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7718 r_u->status = status;
7719 r_u->info = 0;
7720 r_u->ptr_info = 0;
7721 r_u->reject = 0;
7722 r_u->ptr_reject = 0;
7724 if (info) {
7725 r_u->info = info;
7726 r_u->ptr_info = 1;
7728 if (reject && (reject->reject_reason != Undefined)) {
7729 r_u->reject = reject;
7730 r_u->ptr_reject = 1;
7734 /*******************************************************************
7735 Reads or writes an SAMR_CHANGE_REJECT structure.
7736 ********************************************************************/
7738 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7740 if (reject == NULL)
7741 return False;
7743 prs_debug(ps, depth, desc, "samr_io_change_reject");
7744 depth++;
7746 if(!prs_align(ps))
7747 return False;
7749 if(UNMARSHALLING(ps))
7750 ZERO_STRUCTP(reject);
7752 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7753 return False;
7755 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7756 return False;
7758 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7759 return False;
7761 return True;
7764 /*******************************************************************
7765 reads or writes a structure.
7766 ********************************************************************/
7768 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7769 prs_struct *ps, int depth)
7771 if (r_u == NULL)
7772 return False;
7774 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7775 depth++;
7777 if (!prs_align(ps))
7778 return False;
7780 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7781 return False;
7783 if (r_u->ptr_info && r_u->info != NULL) {
7784 /* SAM_UNK_INFO_1 */
7785 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7786 return False;
7789 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7790 return False;
7792 if (r_u->ptr_reject && r_u->reject != NULL) {
7793 /* SAMR_CHANGE_REJECT */
7794 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7795 return False;
7798 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7799 return False;
7801 return True;
7804 /*******************************************************************
7805 reads or writes a structure.
7806 ********************************************************************/
7808 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7809 POLICY_HND *domain_pol, uint16 switch_value)
7811 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7813 q_u->domain_pol = *domain_pol;
7814 q_u->switch_value = switch_value;
7817 /*******************************************************************
7818 reads or writes a structure.
7819 ********************************************************************/
7821 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7822 prs_struct *ps, int depth)
7824 if (q_u == NULL)
7825 return False;
7827 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7828 depth++;
7830 if(!prs_align(ps))
7831 return False;
7833 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7834 return False;
7836 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7837 return False;
7839 return True;
7842 /*******************************************************************
7843 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7844 ********************************************************************/
7846 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7847 uint16 switch_value, SAM_UNK_CTR * ctr,
7848 NTSTATUS status)
7850 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7852 r_u->ptr_0 = 0;
7853 r_u->switch_value = 0;
7854 r_u->status = status; /* return status */
7856 if (NT_STATUS_IS_OK(status)) {
7857 r_u->switch_value = switch_value;
7858 r_u->ptr_0 = 1;
7859 r_u->ctr = ctr;
7863 /*******************************************************************
7864 reads or writes a structure.
7865 ********************************************************************/
7867 BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7868 prs_struct *ps, int depth)
7870 if (r_u == NULL)
7871 return False;
7873 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7874 depth++;
7876 if(!prs_align(ps))
7877 return False;
7879 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7880 return False;
7882 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7883 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7884 return False;
7885 if(!prs_align(ps))
7886 return False;
7888 switch (r_u->switch_value) {
7889 case 0x0d:
7890 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7891 return False;
7892 break;
7893 case 0x0c:
7894 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7895 return False;
7896 break;
7897 case 0x09:
7898 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7899 return False;
7900 break;
7901 case 0x08:
7902 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7903 return False;
7904 break;
7905 case 0x07:
7906 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7907 return False;
7908 break;
7909 case 0x06:
7910 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7911 return False;
7912 break;
7913 case 0x05:
7914 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7915 return False;
7916 break;
7917 case 0x04:
7918 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7919 return False;
7920 break;
7921 case 0x03:
7922 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7923 return False;
7924 break;
7925 case 0x02:
7926 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7927 return False;
7928 break;
7929 case 0x01:
7930 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7931 return False;
7932 break;
7933 default:
7934 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7935 r_u->switch_value));
7936 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7937 return False;
7941 if(!prs_align(ps))
7942 return False;
7944 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7945 return False;
7947 return True;
7951 /*******************************************************************
7952 reads or writes a structure.
7953 ********************************************************************/
7955 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7956 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7958 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7960 q_u->domain_pol = *domain_pol;
7961 q_u->switch_value0 = switch_value;
7963 q_u->switch_value = switch_value;
7964 q_u->ctr = ctr;
7968 /*******************************************************************
7969 reads or writes a structure.
7970 ********************************************************************/
7972 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7973 prs_struct *ps, int depth)
7975 if (q_u == NULL)
7976 return False;
7978 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7979 depth++;
7981 if(!prs_align(ps))
7982 return False;
7984 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7985 return False;
7987 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7988 return False;
7990 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7991 return False;
7993 if(!prs_align(ps))
7994 return False;
7996 if (UNMARSHALLING(ps)) {
7997 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7998 return False;
8001 switch (q_u->switch_value) {
8003 case 0x0c:
8004 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
8005 return False;
8006 break;
8007 case 0x07:
8008 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
8009 return False;
8010 break;
8011 case 0x06:
8012 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
8013 return False;
8014 break;
8015 case 0x05:
8016 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
8017 return False;
8018 break;
8019 case 0x03:
8020 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
8021 return False;
8022 break;
8023 case 0x02:
8024 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
8025 return False;
8026 break;
8027 case 0x01:
8028 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
8029 return False;
8030 break;
8031 default:
8032 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
8033 q_u->switch_value));
8034 return False;
8037 return True;
8040 /*******************************************************************
8041 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
8042 ********************************************************************/
8044 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
8046 DEBUG(5, ("init_samr_r_set_domain_info\n"));
8048 r_u->status = status; /* return status */
8051 /*******************************************************************
8052 reads or writes a structure.
8053 ********************************************************************/
8055 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
8056 prs_struct *ps, int depth)
8058 if (r_u == NULL)
8059 return False;
8061 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
8062 depth++;
8064 if(!prs_align(ps))
8065 return False;
8067 if(!prs_ntstatus("status", ps, depth, &r_u->status))
8068 return False;
8070 return True;