r18369: I've got a sniff where NT4 sends just a single byte after the 516 byte
[Samba/bb.git] / source / rpc_parse / parse_samr.c
blob58ba3e8689954c8008a4eb4bbcc4598259588240
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_OPEN_GROUP structure.
2177 ********************************************************************/
2179 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2180 POLICY_HND *hnd,
2181 uint32 access_mask, uint32 rid)
2183 DEBUG(5, ("init_samr_q_open_group\n"));
2185 q_c->domain_pol = *hnd;
2186 q_c->access_mask = access_mask;
2187 q_c->rid_group = rid;
2190 /*******************************************************************
2191 reads or writes a structure.
2192 ********************************************************************/
2194 BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2195 prs_struct *ps, int depth)
2197 if (q_u == NULL)
2198 return False;
2200 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2201 depth++;
2203 if(!prs_align(ps))
2204 return False;
2206 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2207 return False;
2209 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2210 return False;
2211 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2212 return False;
2214 return True;
2217 /*******************************************************************
2218 reads or writes a structure.
2219 ********************************************************************/
2221 BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2222 prs_struct *ps, int depth)
2224 if (r_u == NULL)
2225 return False;
2227 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2228 depth++;
2230 if(!prs_align(ps))
2231 return False;
2233 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2234 return False;
2236 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2237 return False;
2239 return True;
2242 /*******************************************************************
2243 inits a GROUP_INFO1 structure.
2244 ********************************************************************/
2246 void init_samr_group_info1(GROUP_INFO1 * gr1,
2247 char *acct_name, char *acct_desc,
2248 uint32 num_members)
2250 DEBUG(5, ("init_samr_group_info1\n"));
2252 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2253 gr1->num_members = num_members;
2255 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2256 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2257 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2258 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2261 /*******************************************************************
2262 reads or writes a structure.
2263 ********************************************************************/
2265 BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2266 prs_struct *ps, int depth)
2268 uint16 dummy = 1;
2270 if (gr1 == NULL)
2271 return False;
2273 prs_debug(ps, depth, desc, "samr_io_group_info1");
2274 depth++;
2276 if(!prs_uint16("level", ps, depth, &dummy))
2277 return False;
2279 if(!prs_align(ps))
2280 return False;
2282 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2283 return False;
2285 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2286 return False;
2287 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2288 return False;
2290 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2291 return False;
2293 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2294 gr1->hdr_acct_name.buffer, ps, depth))
2295 return False;
2297 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2298 gr1->hdr_acct_desc.buffer, ps, depth))
2299 return False;
2301 return True;
2304 /*******************************************************************
2305 inits a GROUP_INFO2 structure.
2306 ********************************************************************/
2308 void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2310 DEBUG(5, ("init_samr_group_info2\n"));
2312 gr2->level = 2;
2313 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2314 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2317 /*******************************************************************
2318 reads or writes a structure.
2319 ********************************************************************/
2321 BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2323 if (gr2 == NULL)
2324 return False;
2326 prs_debug(ps, depth, desc, "samr_io_group_info2");
2327 depth++;
2329 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2330 return False;
2332 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2333 return False;
2334 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2335 gr2->hdr_acct_name.buffer, ps, depth))
2336 return False;
2338 return True;
2341 /*******************************************************************
2342 inits a GROUP_INFO3 structure.
2343 ********************************************************************/
2345 void init_samr_group_info3(GROUP_INFO3 *gr3)
2347 DEBUG(5, ("init_samr_group_info3\n"));
2349 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2352 /*******************************************************************
2353 reads or writes a structure.
2354 ********************************************************************/
2356 BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2358 if (gr3 == NULL)
2359 return False;
2361 prs_debug(ps, depth, desc, "samr_io_group_info3");
2362 depth++;
2364 if(!prs_align(ps))
2365 return False;
2367 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2368 return False;
2370 return True;
2373 /*******************************************************************
2374 inits a GROUP_INFO4 structure.
2375 ********************************************************************/
2377 void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2379 DEBUG(5, ("init_samr_group_info4\n"));
2381 gr4->level = 4;
2382 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2383 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2386 /*******************************************************************
2387 reads or writes a structure.
2388 ********************************************************************/
2390 BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2391 prs_struct *ps, int depth)
2393 if (gr4 == NULL)
2394 return False;
2396 prs_debug(ps, depth, desc, "samr_io_group_info4");
2397 depth++;
2399 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2400 return False;
2401 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2402 return False;
2403 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2404 gr4->hdr_acct_desc.buffer, ps, depth))
2405 return False;
2407 return True;
2410 /*******************************************************************
2411 inits a GROUP_INFO5 structure.
2412 ********************************************************************/
2414 void init_samr_group_info5(GROUP_INFO5 * gr5,
2415 char *acct_name, char *acct_desc,
2416 uint32 num_members)
2418 DEBUG(5, ("init_samr_group_info5\n"));
2420 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2421 gr5->num_members = num_members;
2423 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2424 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2425 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2426 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2429 /*******************************************************************
2430 reads or writes a structure.
2431 ********************************************************************/
2433 BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2434 prs_struct *ps, int depth)
2436 uint16 dummy = 1;
2438 if (gr5 == NULL)
2439 return False;
2441 prs_debug(ps, depth, desc, "samr_io_group_info5");
2442 depth++;
2444 if(!prs_uint16("level", ps, depth, &dummy))
2445 return False;
2447 if(!prs_align(ps))
2448 return False;
2450 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2451 return False;
2453 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2454 return False;
2455 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2456 return False;
2458 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2459 return False;
2461 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2462 gr5->hdr_acct_name.buffer, ps, depth))
2463 return False;
2465 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2466 gr5->hdr_acct_desc.buffer, ps, depth))
2467 return False;
2469 return True;
2473 /*******************************************************************
2474 reads or writes a structure.
2475 ********************************************************************/
2477 static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2478 prs_struct *ps, int depth)
2480 if (UNMARSHALLING(ps))
2481 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2483 if (*ctr == NULL)
2484 return False;
2486 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2487 depth++;
2489 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2490 return False;
2492 switch ((*ctr)->switch_value1) {
2493 case 1:
2494 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2495 return False;
2496 break;
2497 case 2:
2498 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2499 return False;
2500 break;
2501 case 3:
2502 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2503 return False;
2504 break;
2505 case 4:
2506 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2507 return False;
2508 break;
2509 case 5:
2510 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2511 return False;
2512 break;
2513 default:
2514 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2515 break;
2518 return True;
2521 /*******************************************************************
2522 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2523 ********************************************************************/
2525 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2526 POLICY_HND *pol, const char *acct_desc,
2527 uint32 access_mask)
2529 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2531 q_e->pol = *pol;
2533 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2534 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2536 q_e->access_mask = access_mask;
2539 /*******************************************************************
2540 reads or writes a structure.
2541 ********************************************************************/
2543 BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2544 prs_struct *ps, int depth)
2546 if (q_e == NULL)
2547 return False;
2549 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2550 depth++;
2552 if(!prs_align(ps))
2553 return False;
2555 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2556 return False;
2558 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2559 return False;
2560 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2561 q_e->hdr_acct_desc.buffer, ps, depth))
2562 return False;
2564 if(!prs_align(ps))
2565 return False;
2566 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2567 return False;
2569 return True;
2572 /*******************************************************************
2573 reads or writes a structure.
2574 ********************************************************************/
2576 BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2577 prs_struct *ps, int depth)
2579 if (r_u == NULL)
2580 return False;
2582 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2583 depth++;
2585 if(!prs_align(ps))
2586 return False;
2588 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2589 return False;
2591 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2592 return False;
2593 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2594 return False;
2596 return True;
2599 /*******************************************************************
2600 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2601 ********************************************************************/
2603 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2604 POLICY_HND *hnd)
2606 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2608 q_c->group_pol = *hnd;
2611 /*******************************************************************
2612 reads or writes a structure.
2613 ********************************************************************/
2615 BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2616 prs_struct *ps, int depth)
2618 if (q_u == NULL)
2619 return False;
2621 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2622 depth++;
2624 if(!prs_align(ps))
2625 return False;
2627 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2628 return False;
2630 return True;
2633 /*******************************************************************
2634 reads or writes a structure.
2635 ********************************************************************/
2637 BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2638 prs_struct *ps, int depth)
2640 if (r_u == NULL)
2641 return False;
2643 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2644 depth++;
2646 if(!prs_align(ps))
2647 return False;
2649 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2650 return False;
2652 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2653 return False;
2655 return True;
2658 /*******************************************************************
2659 inits a SAMR_Q_DEL_GROUPMEM structure.
2660 ********************************************************************/
2662 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2663 POLICY_HND *pol, uint32 rid)
2665 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2667 q_e->pol = *pol;
2668 q_e->rid = rid;
2671 /*******************************************************************
2672 reads or writes a structure.
2673 ********************************************************************/
2675 BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2676 prs_struct *ps, int depth)
2678 if (q_e == NULL)
2679 return False;
2681 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2682 depth++;
2684 if(!prs_align(ps))
2685 return False;
2687 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2688 return False;
2690 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2691 return False;
2693 return True;
2696 /*******************************************************************
2697 inits a SAMR_R_DEL_GROUPMEM structure.
2698 ********************************************************************/
2700 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2701 NTSTATUS status)
2703 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2705 r_u->status = status;
2708 /*******************************************************************
2709 reads or writes a structure.
2710 ********************************************************************/
2712 BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2713 prs_struct *ps, int depth)
2715 if (r_u == NULL)
2716 return False;
2718 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2719 depth++;
2721 if(!prs_align(ps))
2722 return False;
2724 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2725 return False;
2727 return True;
2730 /*******************************************************************
2731 inits a SAMR_Q_ADD_GROUPMEM structure.
2732 ********************************************************************/
2734 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2735 POLICY_HND *pol, uint32 rid)
2737 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2739 q_e->pol = *pol;
2740 q_e->rid = rid;
2741 q_e->unknown = 0x0005;
2744 /*******************************************************************
2745 reads or writes a structure.
2746 ********************************************************************/
2748 BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2749 prs_struct *ps, int depth)
2751 if (q_e == NULL)
2752 return False;
2754 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2755 depth++;
2757 if(!prs_align(ps))
2758 return False;
2760 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2761 return False;
2763 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2764 return False;
2765 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2766 return False;
2768 return True;
2771 /*******************************************************************
2772 inits a SAMR_R_ADD_GROUPMEM structure.
2773 ********************************************************************/
2775 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2776 NTSTATUS status)
2778 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2780 r_u->status = status;
2783 /*******************************************************************
2784 reads or writes a structure.
2785 ********************************************************************/
2787 BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2788 prs_struct *ps, int depth)
2790 if (r_u == NULL)
2791 return False;
2793 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2794 depth++;
2796 if(!prs_align(ps))
2797 return False;
2799 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2800 return False;
2802 return True;
2805 /*******************************************************************
2806 inits a SAMR_Q_SET_GROUPINFO structure.
2807 ********************************************************************/
2809 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2810 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2812 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2814 q_e->pol = *pol;
2815 q_e->ctr = ctr;
2818 /*******************************************************************
2819 reads or writes a structure.
2820 ********************************************************************/
2822 BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2823 prs_struct *ps, int depth)
2825 if (q_e == NULL)
2826 return False;
2828 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2829 depth++;
2831 if(!prs_align(ps))
2832 return False;
2834 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2835 return False;
2837 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2838 return False;
2840 return True;
2843 /*******************************************************************
2844 inits a SAMR_R_SET_GROUPINFO structure.
2845 ********************************************************************/
2847 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2849 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2851 r_u->status = status;
2854 /*******************************************************************
2855 reads or writes a structure.
2856 ********************************************************************/
2858 BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2859 prs_struct *ps, int depth)
2861 if (r_u == NULL)
2862 return False;
2864 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2865 depth++;
2867 if(!prs_align(ps))
2868 return False;
2870 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2871 return False;
2873 return True;
2876 /*******************************************************************
2877 inits a SAMR_Q_QUERY_GROUPINFO structure.
2878 ********************************************************************/
2880 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2881 POLICY_HND *pol, uint16 switch_level)
2883 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2885 q_e->pol = *pol;
2887 q_e->switch_level = switch_level;
2890 /*******************************************************************
2891 reads or writes a structure.
2892 ********************************************************************/
2894 BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2895 prs_struct *ps, int depth)
2897 if (q_e == NULL)
2898 return False;
2900 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2901 depth++;
2903 if(!prs_align(ps))
2904 return False;
2906 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2907 return False;
2909 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2910 return False;
2912 return True;
2915 /*******************************************************************
2916 inits a SAMR_R_QUERY_GROUPINFO structure.
2917 ********************************************************************/
2919 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
2920 GROUP_INFO_CTR * ctr, NTSTATUS status)
2922 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2924 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
2925 r_u->ctr = ctr;
2926 r_u->status = status;
2929 /*******************************************************************
2930 reads or writes a structure.
2931 ********************************************************************/
2933 BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
2934 prs_struct *ps, int depth)
2936 if (r_u == NULL)
2937 return False;
2939 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
2940 depth++;
2942 if(!prs_align(ps))
2943 return False;
2945 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
2946 return False;
2948 if (r_u->ptr != 0) {
2949 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
2950 return False;
2953 if(!prs_align(ps))
2954 return False;
2955 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2956 return False;
2958 return True;
2961 /*******************************************************************
2962 inits a SAMR_Q_QUERY_GROUPMEM structure.
2963 ********************************************************************/
2965 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
2967 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2969 q_c->group_pol = *hnd;
2972 /*******************************************************************
2973 reads or writes a structure.
2974 ********************************************************************/
2976 BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
2977 prs_struct *ps, int depth)
2979 if (q_u == NULL)
2980 return False;
2982 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
2983 depth++;
2985 if(!prs_align(ps))
2986 return False;
2988 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2989 return False;
2991 return True;
2994 /*******************************************************************
2995 inits a SAMR_R_QUERY_GROUPMEM structure.
2996 ********************************************************************/
2998 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
2999 uint32 num_entries, uint32 *rid,
3000 uint32 *attr, NTSTATUS status)
3002 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3004 if (NT_STATUS_IS_OK(status)) {
3005 r_u->ptr = 1;
3006 r_u->num_entries = num_entries;
3008 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3009 r_u->ptr_rids = rid != NULL ? 1 : 0;
3011 r_u->num_rids = num_entries;
3012 r_u->rid = rid;
3014 r_u->num_attrs = num_entries;
3015 r_u->attr = attr;
3016 } else {
3017 r_u->ptr = 0;
3018 r_u->num_entries = 0;
3021 r_u->status = status;
3024 /*******************************************************************
3025 reads or writes a structure.
3026 ********************************************************************/
3028 BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3029 prs_struct *ps, int depth)
3031 uint32 i;
3033 if (r_u == NULL)
3034 return False;
3036 if (UNMARSHALLING(ps))
3037 ZERO_STRUCTP(r_u);
3039 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3040 depth++;
3042 if(!prs_align(ps))
3043 return False;
3045 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3046 return False;
3047 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3048 return False;
3050 if (r_u->ptr != 0) {
3051 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3052 return False;
3053 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3054 return False;
3056 if (r_u->ptr_rids != 0) {
3057 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3058 return False;
3059 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3060 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3061 if (r_u->rid == NULL)
3062 return False;
3065 for (i = 0; i < r_u->num_rids; i++) {
3066 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3067 return False;
3071 if (r_u->ptr_attrs != 0) {
3072 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3073 return False;
3075 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3076 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3077 if (r_u->attr == NULL)
3078 return False;
3081 for (i = 0; i < r_u->num_attrs; i++) {
3082 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3083 return False;
3088 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3089 return False;
3091 return True;
3094 /*******************************************************************
3095 inits a SAMR_Q_QUERY_USERGROUPS structure.
3096 ********************************************************************/
3098 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3099 POLICY_HND *hnd)
3101 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3103 q_u->pol = *hnd;
3106 /*******************************************************************
3107 reads or writes a structure.
3108 ********************************************************************/
3110 BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3111 prs_struct *ps, int depth)
3113 if (q_u == NULL)
3114 return False;
3116 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3117 depth++;
3119 if(!prs_align(ps))
3120 return False;
3122 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3123 return False;
3125 return True;
3128 /*******************************************************************
3129 inits a SAMR_R_QUERY_USERGROUPS structure.
3130 ********************************************************************/
3132 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3133 uint32 num_gids, DOM_GID * gid,
3134 NTSTATUS status)
3136 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3138 if (NT_STATUS_IS_OK(status)) {
3139 r_u->ptr_0 = 1;
3140 r_u->num_entries = num_gids;
3141 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3142 r_u->num_entries2 = num_gids;
3144 r_u->gid = gid;
3145 } else {
3146 r_u->ptr_0 = 0;
3147 r_u->num_entries = 0;
3148 r_u->ptr_1 = 0;
3149 r_u->gid = NULL;
3152 r_u->status = status;
3155 /*******************************************************************
3156 reads or writes a structure.
3157 ********************************************************************/
3159 BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3160 prs_struct *ps, int depth)
3162 uint32 i;
3163 if (gid == NULL)
3164 return False;
3166 prs_debug(ps, depth, desc, "samr_io_gids");
3167 depth++;
3169 if(!prs_align(ps))
3170 return False;
3172 if(!prs_uint32("num_gids", ps, depth, num_gids))
3173 return False;
3175 if ((*num_gids) != 0) {
3176 if (UNMARSHALLING(ps)) {
3177 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3180 if ((*gid) == NULL) {
3181 return False;
3184 for (i = 0; i < (*num_gids); i++) {
3185 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3186 return False;
3190 return True;
3193 /*******************************************************************
3194 reads or writes a structure.
3195 ********************************************************************/
3197 BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3198 prs_struct *ps, int depth)
3200 if (r_u == NULL)
3201 return False;
3203 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3204 depth++;
3206 if(!prs_align(ps))
3207 return False;
3209 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3210 return False;
3212 if (r_u->ptr_0 != 0) {
3213 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3214 return False;
3215 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3216 return False;
3218 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3219 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3220 return False;
3224 if(!prs_align(ps))
3225 return False;
3226 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3227 return False;
3229 return True;
3232 /*******************************************************************
3233 inits a SAMR_Q_ENUM_DOMAINS structure.
3234 ********************************************************************/
3236 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3237 POLICY_HND *pol,
3238 uint32 start_idx, uint32 size)
3240 DEBUG(5, ("init_samr_q_enum_domains\n"));
3242 q_e->pol = *pol;
3244 q_e->start_idx = start_idx;
3245 q_e->max_size = size;
3248 /*******************************************************************
3249 reads or writes a structure.
3250 ********************************************************************/
3252 BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3253 prs_struct *ps, int depth)
3255 if (q_e == NULL)
3256 return False;
3258 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3259 depth++;
3261 if(!prs_align(ps))
3262 return False;
3264 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3265 return False;
3267 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3268 return False;
3269 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3270 return False;
3272 return True;
3275 /*******************************************************************
3276 inits a SAMR_R_ENUM_DOMAINS structure.
3277 ********************************************************************/
3279 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3280 uint32 next_idx, uint32 num_sam_entries)
3282 DEBUG(5, ("init_samr_r_enum_domains\n"));
3284 r_u->next_idx = next_idx;
3286 if (num_sam_entries != 0) {
3287 r_u->ptr_entries1 = 1;
3288 r_u->ptr_entries2 = 1;
3289 r_u->num_entries2 = num_sam_entries;
3290 r_u->num_entries3 = num_sam_entries;
3292 r_u->num_entries4 = num_sam_entries;
3293 } else {
3294 r_u->ptr_entries1 = 0;
3295 r_u->num_entries2 = num_sam_entries;
3296 r_u->ptr_entries2 = 1;
3300 /*******************************************************************
3301 reads or writes a structure.
3302 ********************************************************************/
3304 BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3305 prs_struct *ps, int depth)
3307 uint32 i;
3309 if (r_u == NULL)
3310 return False;
3312 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3313 depth++;
3315 if(!prs_align(ps))
3316 return False;
3318 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3319 return False;
3320 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3321 return False;
3323 if (r_u->ptr_entries1 != 0) {
3324 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3325 return False;
3326 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3327 return False;
3328 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3329 return False;
3331 if (UNMARSHALLING(ps)) {
3332 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3333 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3336 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3337 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3338 r_u->num_entries4 = 0;
3339 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3340 return False;
3343 for (i = 0; i < r_u->num_entries2; i++) {
3344 fstring tmp;
3345 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3346 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3347 return False;
3350 for (i = 0; i < r_u->num_entries2; i++) {
3351 fstring tmp;
3352 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3353 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3354 r_u->sam[i].hdr_name.buffer, ps,
3355 depth))
3356 return False;
3361 if(!prs_align(ps))
3362 return False;
3363 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3364 return False;
3365 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3366 return False;
3368 return True;
3371 /*******************************************************************
3372 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3373 ********************************************************************/
3375 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3376 POLICY_HND *pol,
3377 uint32 start_idx, uint32 size)
3379 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3381 q_e->pol = *pol;
3383 q_e->start_idx = start_idx;
3384 q_e->max_size = size;
3387 /*******************************************************************
3388 reads or writes a structure.
3389 ********************************************************************/
3391 BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3392 prs_struct *ps, int depth)
3394 if (q_e == NULL)
3395 return False;
3397 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3398 depth++;
3400 if(!prs_align(ps))
3401 return False;
3403 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3404 return False;
3406 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3407 return False;
3408 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3409 return False;
3411 return True;
3414 /*******************************************************************
3415 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3416 ********************************************************************/
3418 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3419 uint32 next_idx, uint32 num_sam_entries)
3421 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3423 r_u->next_idx = next_idx;
3425 if (num_sam_entries != 0) {
3426 r_u->ptr_entries1 = 1;
3427 r_u->ptr_entries2 = 1;
3428 r_u->num_entries2 = num_sam_entries;
3429 r_u->num_entries3 = num_sam_entries;
3431 r_u->num_entries4 = num_sam_entries;
3432 } else {
3433 r_u->ptr_entries1 = 0;
3434 r_u->num_entries2 = num_sam_entries;
3435 r_u->ptr_entries2 = 1;
3439 /*******************************************************************
3440 reads or writes a structure.
3441 ********************************************************************/
3443 BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3444 prs_struct *ps, int depth)
3446 uint32 i;
3448 if (r_u == NULL)
3449 return False;
3451 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3452 depth++;
3454 if(!prs_align(ps))
3455 return False;
3457 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3458 return False;
3459 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3460 return False;
3462 if (r_u->ptr_entries1 != 0) {
3463 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3464 return False;
3465 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3466 return False;
3467 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3468 return False;
3470 if (UNMARSHALLING(ps)) {
3471 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3472 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3475 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3476 DEBUG(0,
3477 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3478 r_u->num_entries4 = 0;
3479 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3480 return False;
3483 for (i = 0; i < r_u->num_entries2; i++) {
3484 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3485 return False;
3488 for (i = 0; i < r_u->num_entries2; i++) {
3489 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3490 r_u->sam[i].hdr_name.buffer, ps, depth))
3491 return False;
3495 if(!prs_align(ps))
3496 return False;
3497 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3498 return False;
3499 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3500 return False;
3502 return True;
3505 /*******************************************************************
3506 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3507 ********************************************************************/
3509 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3510 POLICY_HND *pol, uint32 start_idx,
3511 uint32 size)
3513 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3515 q_e->pol = *pol;
3517 q_e->start_idx = start_idx;
3518 q_e->max_size = size;
3522 /*******************************************************************
3523 reads or writes a structure.
3524 ********************************************************************/
3526 BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3527 prs_struct *ps, int depth)
3529 if (q_e == NULL)
3530 return False;
3532 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3533 depth++;
3535 if(!prs_align(ps))
3536 return False;
3538 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3539 return False;
3541 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3542 return False;
3543 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3544 return False;
3546 return True;
3549 /*******************************************************************
3550 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3551 ********************************************************************/
3553 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3555 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3557 r_u->next_idx = next_idx;
3559 if (num_sam_entries != 0) {
3560 r_u->ptr_entries1 = 1;
3561 r_u->ptr_entries2 = 1;
3562 r_u->num_entries2 = num_sam_entries;
3563 r_u->num_entries3 = num_sam_entries;
3565 r_u->num_entries4 = num_sam_entries;
3566 } else {
3567 r_u->ptr_entries1 = 0;
3568 r_u->num_entries2 = num_sam_entries;
3569 r_u->ptr_entries2 = 1;
3573 /*******************************************************************
3574 reads or writes a structure.
3575 ********************************************************************/
3577 BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3578 prs_struct *ps, int depth)
3580 uint32 i;
3582 if (r_u == NULL)
3583 return False;
3585 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3586 depth++;
3588 if(!prs_align(ps))
3589 return False;
3591 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3592 return False;
3593 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3594 return False;
3596 if (r_u->ptr_entries1 != 0) {
3597 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3598 return False;
3599 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3600 return False;
3601 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3602 return False;
3604 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3605 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3606 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3609 if (r_u->num_entries2 != 0 &&
3610 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3611 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3612 r_u->num_entries4 = 0;
3613 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3614 return False;
3617 for (i = 0; i < r_u->num_entries2; i++) {
3618 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3619 return False;
3622 for (i = 0; i < r_u->num_entries2; i++) {
3623 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3624 r_u->sam[i].hdr_name.buffer, ps,
3625 depth))
3626 return False;
3630 if(!prs_align(ps))
3631 return False;
3632 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3633 return False;
3634 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3635 return False;
3637 return True;
3640 /*******************************************************************
3641 inits a ALIAS_INFO1 structure.
3642 ********************************************************************/
3644 void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3646 DEBUG(5, ("init_samr_alias_info1\n"));
3648 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3649 al1->num_member = num_member;
3650 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3653 /*******************************************************************
3654 reads or writes a structure.
3655 ********************************************************************/
3657 BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3658 prs_struct *ps, int depth)
3660 if (al1 == NULL)
3661 return False;
3663 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3664 depth++;
3666 if(!prs_align(ps))
3667 return False;
3669 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3670 return False;
3671 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3672 return False;
3673 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3674 return False;
3676 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3677 return False;
3678 if ( !prs_align(ps) )
3679 return False;
3680 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3681 return False;
3682 if ( !prs_align(ps) )
3683 return False;
3685 return True;
3688 /*******************************************************************
3689 inits a ALIAS_INFO3 structure.
3690 ********************************************************************/
3692 void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3694 DEBUG(5, ("init_samr_alias_info3\n"));
3696 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3699 /*******************************************************************
3700 reads or writes a structure.
3701 ********************************************************************/
3703 BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3704 prs_struct *ps, int depth)
3706 if (al3 == NULL)
3707 return False;
3709 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3710 depth++;
3712 if(!prs_align(ps))
3713 return False;
3715 if (!prs_unistr4("description", ps, depth, &al3->description))
3716 return False;
3718 return True;
3721 /*******************************************************************
3722 reads or writes a structure.
3723 ********************************************************************/
3725 BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3726 prs_struct *ps, int depth)
3728 if (al2 == NULL)
3729 return False;
3731 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3732 depth++;
3734 if(!prs_align(ps))
3735 return False;
3737 if (!prs_unistr4("name", ps, depth, &al2->name))
3738 return False;
3740 return True;
3743 /*******************************************************************
3744 reads or writes a structure.
3745 ********************************************************************/
3747 BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3749 if ( !ctr )
3750 return False;
3752 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3753 depth++;
3755 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3756 return False;
3758 if(!prs_align(ps))
3759 return False;
3760 switch (ctr->level) {
3761 case 1:
3762 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3763 return False;
3764 break;
3765 case 2:
3766 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3767 return False;
3768 break;
3769 case 3:
3770 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3771 return False;
3772 break;
3773 default:
3774 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3775 break;
3778 return True;
3781 /*******************************************************************
3782 inits a SAMR_Q_QUERY_ALIASINFO structure.
3783 ********************************************************************/
3785 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3786 POLICY_HND *pol, uint32 switch_level)
3788 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3790 q_e->pol = *pol;
3791 q_e->level = switch_level;
3794 /*******************************************************************
3795 reads or writes a structure.
3796 ********************************************************************/
3798 BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3799 prs_struct *ps, int depth)
3801 if ( !in )
3802 return False;
3804 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3805 depth++;
3807 if(!prs_align(ps))
3808 return False;
3810 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3811 return False;
3813 if ( !prs_uint16("level", ps, depth, &in->level) )
3814 return False;
3816 return True;
3819 /*******************************************************************
3820 inits a SAMR_R_QUERY_ALIASINFO structure.
3821 ********************************************************************/
3823 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3824 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3826 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3828 out->ctr = ctr;
3829 out->status = status;
3832 /*******************************************************************
3833 reads or writes a structure.
3834 ********************************************************************/
3836 BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3837 prs_struct *ps, int depth)
3839 if ( !out )
3840 return False;
3842 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3843 depth++;
3845 if(!prs_align(ps))
3846 return False;
3848 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3849 return False;
3850 if(!prs_align(ps))
3851 return False;
3853 if(!prs_ntstatus("status", ps, depth, &out->status))
3854 return False;
3856 return True;
3859 /*******************************************************************
3860 inits a SAMR_Q_SET_ALIASINFO structure.
3861 ********************************************************************/
3863 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3864 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3866 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3868 q_u->alias_pol = *hnd;
3869 q_u->ctr = *ctr;
3872 /*******************************************************************
3873 reads or writes a structure.
3874 ********************************************************************/
3876 BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3877 prs_struct *ps, int depth)
3879 if (q_u == NULL)
3880 return False;
3882 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3883 depth++;
3885 if(!prs_align(ps))
3886 return False;
3888 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3889 return False;
3890 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3891 return False;
3893 return True;
3896 /*******************************************************************
3897 reads or writes a structure.
3898 ********************************************************************/
3900 BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3901 prs_struct *ps, int depth)
3903 if (r_u == NULL)
3904 return False;
3906 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3907 depth++;
3909 if(!prs_align(ps))
3910 return False;
3911 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3912 return False;
3914 return True;
3917 /*******************************************************************
3918 inits a SAMR_Q_QUERY_USERALIASES structure.
3919 ********************************************************************/
3921 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
3922 POLICY_HND *hnd,
3923 uint32 num_sids,
3924 uint32 *ptr_sid, DOM_SID2 * sid)
3926 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3928 q_u->pol = *hnd;
3930 q_u->num_sids1 = num_sids;
3931 q_u->ptr = 1;
3932 q_u->num_sids2 = num_sids;
3934 q_u->ptr_sid = ptr_sid;
3935 q_u->sid = sid;
3938 /*******************************************************************
3939 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3940 ********************************************************************/
3942 BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
3943 prs_struct *ps, int depth)
3945 fstring tmp;
3946 uint32 i;
3948 if (q_u == NULL)
3949 return False;
3951 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
3952 depth++;
3954 if(!prs_align(ps))
3955 return False;
3957 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3958 return False;
3960 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
3961 return False;
3962 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
3963 return False;
3965 if (q_u->ptr==0)
3966 return True;
3968 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
3969 return False;
3971 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
3972 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
3973 if (q_u->ptr_sid == NULL)
3974 return False;
3976 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
3977 if (q_u->sid == NULL)
3978 return False;
3981 for (i = 0; i < q_u->num_sids2; i++) {
3982 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
3983 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
3984 return False;
3987 for (i = 0; i < q_u->num_sids2; i++) {
3988 if (q_u->ptr_sid[i] != 0) {
3989 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
3990 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
3991 return False;
3995 return True;
3998 /*******************************************************************
3999 inits a SAMR_R_QUERY_USERALIASES structure.
4000 ********************************************************************/
4002 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4003 uint32 num_rids, uint32 *rid,
4004 NTSTATUS status)
4006 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4008 if (NT_STATUS_IS_OK(status)) {
4009 r_u->num_entries = num_rids;
4010 r_u->ptr = 1;
4011 r_u->num_entries2 = num_rids;
4013 r_u->rid = rid;
4014 } else {
4015 r_u->num_entries = 0;
4016 r_u->ptr = 0;
4017 r_u->num_entries2 = 0;
4020 r_u->status = status;
4023 /*******************************************************************
4024 reads or writes a structure.
4025 ********************************************************************/
4027 BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4028 prs_struct *ps, int depth)
4030 fstring tmp;
4031 uint32 i;
4032 if (rid == NULL)
4033 return False;
4035 prs_debug(ps, depth, desc, "samr_io_rids");
4036 depth++;
4038 if(!prs_align(ps))
4039 return False;
4041 if(!prs_uint32("num_rids", ps, depth, num_rids))
4042 return False;
4044 if ((*num_rids) != 0) {
4045 if (UNMARSHALLING(ps)) {
4046 /* reading */
4047 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4049 if ((*rid) == NULL)
4050 return False;
4052 for (i = 0; i < (*num_rids); i++) {
4053 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4054 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4055 return False;
4059 return True;
4062 /*******************************************************************
4063 reads or writes a structure.
4064 ********************************************************************/
4066 BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4067 prs_struct *ps, int depth)
4069 if (r_u == NULL)
4070 return False;
4072 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4073 depth++;
4075 if(!prs_align(ps))
4076 return False;
4078 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4079 return False;
4080 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4081 return False;
4083 if (r_u->ptr != 0) {
4084 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4085 return False;
4088 if(!prs_align(ps))
4089 return False;
4090 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4091 return False;
4093 return True;
4096 /*******************************************************************
4097 inits a SAMR_Q_OPEN_ALIAS structure.
4098 ********************************************************************/
4100 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4101 uint32 access_mask, uint32 rid)
4103 DEBUG(5, ("init_samr_q_open_alias\n"));
4105 q_u->dom_pol = *pol;
4106 q_u->access_mask = access_mask;
4107 q_u->rid_alias = rid;
4110 /*******************************************************************
4111 reads or writes a structure.
4112 ********************************************************************/
4114 BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4115 prs_struct *ps, int depth)
4117 if (q_u == NULL)
4118 return False;
4120 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4121 depth++;
4123 if(!prs_align(ps))
4124 return False;
4126 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4127 return False;
4129 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4130 return False;
4131 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4132 return False;
4134 return True;
4137 /*******************************************************************
4138 reads or writes a structure.
4139 ********************************************************************/
4141 BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4142 prs_struct *ps, int depth)
4144 if (r_u == NULL)
4145 return False;
4147 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4148 depth++;
4150 if(!prs_align(ps))
4151 return False;
4153 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4154 return False;
4156 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4157 return False;
4159 return True;
4162 /*******************************************************************
4163 inits a SAMR_Q_LOOKUP_RIDS structure.
4164 ********************************************************************/
4166 void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4167 POLICY_HND *pol, uint32 flags,
4168 uint32 num_rids, uint32 *rid)
4170 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4172 q_u->pol = *pol;
4174 q_u->num_rids1 = num_rids;
4175 q_u->flags = flags;
4176 q_u->ptr = 0;
4177 q_u->num_rids2 = num_rids;
4178 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4179 if (q_u->rid == NULL) {
4180 q_u->num_rids1 = 0;
4181 q_u->num_rids2 = 0;
4182 } else {
4183 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4187 /*******************************************************************
4188 reads or writes a structure.
4189 ********************************************************************/
4191 BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4192 prs_struct *ps, int depth)
4194 uint32 i;
4195 fstring tmp;
4197 if (q_u == NULL)
4198 return False;
4200 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4201 depth++;
4203 if (UNMARSHALLING(ps))
4204 ZERO_STRUCTP(q_u);
4206 if(!prs_align(ps))
4207 return False;
4209 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4210 return False;
4212 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4213 return False;
4214 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4215 return False;
4216 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4217 return False;
4218 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4219 return False;
4221 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4222 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4223 if (q_u->rid == NULL)
4224 return False;
4227 for (i = 0; i < q_u->num_rids2; i++) {
4228 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4229 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4230 return False;
4233 return True;
4236 /*******************************************************************
4237 inits a SAMR_R_LOOKUP_RIDS structure.
4238 ********************************************************************/
4240 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4241 uint32 num_names, UNIHDR * hdr_name,
4242 UNISTR2 *uni_name, uint32 *type)
4244 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4246 r_u->hdr_name = NULL;
4247 r_u->uni_name = NULL;
4248 r_u->type = NULL;
4250 if (num_names != 0) {
4251 r_u->num_names1 = num_names;
4252 r_u->ptr_names = 1;
4253 r_u->num_names2 = num_names;
4255 r_u->num_types1 = num_names;
4256 r_u->ptr_types = 1;
4257 r_u->num_types2 = num_names;
4259 r_u->hdr_name = hdr_name;
4260 r_u->uni_name = uni_name;
4261 r_u->type = type;
4262 } else {
4263 r_u->num_names1 = num_names;
4264 r_u->ptr_names = 0;
4265 r_u->num_names2 = num_names;
4267 r_u->num_types1 = num_names;
4268 r_u->ptr_types = 0;
4269 r_u->num_types2 = num_names;
4273 /*******************************************************************
4274 reads or writes a structure.
4275 ********************************************************************/
4277 BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4278 prs_struct *ps, int depth)
4280 uint32 i;
4281 fstring tmp;
4282 if (r_u == NULL)
4283 return False;
4285 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4286 depth++;
4288 if(!prs_align(ps))
4289 return False;
4291 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4292 return False;
4293 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4294 return False;
4296 if (r_u->ptr_names != 0) {
4298 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4299 return False;
4302 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4303 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4304 if (r_u->hdr_name == NULL)
4305 return False;
4307 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4308 if (r_u->uni_name == NULL)
4309 return False;
4312 for (i = 0; i < r_u->num_names2; i++) {
4313 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4314 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4315 return False;
4317 for (i = 0; i < r_u->num_names2; i++) {
4318 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4319 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4320 return False;
4325 if(!prs_align(ps))
4326 return False;
4327 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4328 return False;
4329 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4330 return False;
4332 if (r_u->ptr_types != 0) {
4334 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4335 return False;
4337 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4338 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4339 if (r_u->type == NULL)
4340 return False;
4343 for (i = 0; i < r_u->num_types2; i++) {
4344 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4345 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4346 return False;
4350 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4351 return False;
4353 return True;
4356 /*******************************************************************
4357 inits a SAMR_Q_OPEN_ALIAS structure.
4358 ********************************************************************/
4360 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4362 DEBUG(5, ("init_samr_q_delete_alias\n"));
4364 q_u->alias_pol = *hnd;
4367 /*******************************************************************
4368 reads or writes a structure.
4369 ********************************************************************/
4371 BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4372 prs_struct *ps, int depth)
4374 if (q_u == NULL)
4375 return False;
4377 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4378 depth++;
4380 if(!prs_align(ps))
4381 return False;
4383 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4384 return False;
4386 return True;
4389 /*******************************************************************
4390 reads or writes a structure.
4391 ********************************************************************/
4393 BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4394 prs_struct *ps, int depth)
4396 if (r_u == NULL)
4397 return False;
4399 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4400 depth++;
4402 if(!prs_align(ps))
4403 return False;
4405 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4406 return False;
4407 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4408 return False;
4410 return True;
4413 /*******************************************************************
4414 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4415 ********************************************************************/
4417 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4418 POLICY_HND *hnd, const char *acct_desc)
4420 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4422 q_u->dom_pol = *hnd;
4424 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4425 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4427 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4430 /*******************************************************************
4431 reads or writes a structure.
4432 ********************************************************************/
4434 BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4435 prs_struct *ps, int depth)
4437 if (q_u == NULL)
4438 return False;
4440 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4441 depth++;
4443 if(!prs_align(ps))
4444 return False;
4446 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4447 return False;
4449 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4450 return False;
4451 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4452 q_u->hdr_acct_desc.buffer, ps, depth))
4453 return False;
4455 if(!prs_align(ps))
4456 return False;
4457 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4458 return False;
4460 return True;
4463 /*******************************************************************
4464 reads or writes a structure.
4465 ********************************************************************/
4467 BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4468 prs_struct *ps, int depth)
4470 if (r_u == NULL)
4471 return False;
4473 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4474 depth++;
4476 if(!prs_align(ps))
4477 return False;
4479 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4480 return False;
4482 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4483 return False;
4485 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4486 return False;
4488 return True;
4491 /*******************************************************************
4492 inits a SAMR_Q_ADD_ALIASMEM structure.
4493 ********************************************************************/
4495 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4496 DOM_SID *sid)
4498 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4500 q_u->alias_pol = *hnd;
4501 init_dom_sid2(&q_u->sid, sid);
4504 /*******************************************************************
4505 reads or writes a structure.
4506 ********************************************************************/
4508 BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4509 prs_struct *ps, int depth)
4511 if (q_u == NULL)
4512 return False;
4514 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4515 depth++;
4517 if(!prs_align(ps))
4518 return False;
4520 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4521 return False;
4522 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4523 return False;
4525 return True;
4528 /*******************************************************************
4529 reads or writes a structure.
4530 ********************************************************************/
4532 BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4533 prs_struct *ps, int depth)
4535 if (r_u == NULL)
4536 return False;
4538 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4539 depth++;
4541 if(!prs_align(ps))
4542 return False;
4544 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4545 return False;
4547 return True;
4550 /*******************************************************************
4551 inits a SAMR_Q_DEL_ALIASMEM structure.
4552 ********************************************************************/
4554 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4555 DOM_SID *sid)
4557 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4559 q_u->alias_pol = *hnd;
4560 init_dom_sid2(&q_u->sid, sid);
4563 /*******************************************************************
4564 reads or writes a structure.
4565 ********************************************************************/
4567 BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4568 prs_struct *ps, int depth)
4570 if (q_u == NULL)
4571 return False;
4573 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4574 depth++;
4576 if(!prs_align(ps))
4577 return False;
4579 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4580 return False;
4581 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4582 return False;
4584 return True;
4587 /*******************************************************************
4588 reads or writes a structure.
4589 ********************************************************************/
4591 BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4592 prs_struct *ps, int depth)
4594 if (r_u == NULL)
4595 return False;
4597 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4598 depth++;
4600 if(!prs_align(ps))
4601 return False;
4603 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4604 return False;
4606 return True;
4609 /*******************************************************************
4610 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4611 ********************************************************************/
4613 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4614 POLICY_HND *hnd)
4616 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4618 q_c->alias_pol = *hnd;
4621 /*******************************************************************
4622 reads or writes a structure.
4623 ********************************************************************/
4625 BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4626 prs_struct *ps, int depth)
4628 if (q_u == NULL)
4629 return False;
4631 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4632 depth++;
4634 if(!prs_align(ps))
4635 return False;
4637 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4638 return False;
4640 return True;
4643 /*******************************************************************
4644 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4645 ********************************************************************/
4647 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4648 NTSTATUS status)
4650 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4652 r_u->status = status;
4655 /*******************************************************************
4656 reads or writes a structure.
4657 ********************************************************************/
4659 BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4660 prs_struct *ps, int depth)
4662 if (r_u == NULL)
4663 return False;
4665 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4666 depth++;
4668 if(!prs_align(ps))
4669 return False;
4671 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4672 return False;
4674 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4675 return False;
4677 return True;
4680 /*******************************************************************
4681 inits a SAMR_Q_QUERY_ALIASMEM structure.
4682 ********************************************************************/
4684 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4685 POLICY_HND *hnd)
4687 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4689 q_c->alias_pol = *hnd;
4692 /*******************************************************************
4693 reads or writes a structure.
4694 ********************************************************************/
4696 BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4697 prs_struct *ps, int depth)
4699 if (q_u == NULL)
4700 return False;
4702 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4703 depth++;
4705 if(!prs_align(ps))
4706 return False;
4708 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4709 return False;
4711 return True;
4714 /*******************************************************************
4715 inits a SAMR_R_QUERY_ALIASMEM structure.
4716 ********************************************************************/
4718 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4719 uint32 num_sids, DOM_SID2 * sid,
4720 NTSTATUS status)
4722 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4724 if (NT_STATUS_IS_OK(status)) {
4725 r_u->num_sids = num_sids;
4726 r_u->ptr = (num_sids != 0) ? 1 : 0;
4727 r_u->num_sids1 = num_sids;
4729 r_u->sid = sid;
4730 } else {
4731 r_u->ptr = 0;
4732 r_u->num_sids = 0;
4735 r_u->status = status;
4738 /*******************************************************************
4739 reads or writes a structure.
4740 ********************************************************************/
4742 BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4743 prs_struct *ps, int depth)
4745 uint32 i;
4747 if (r_u == NULL)
4748 return False;
4750 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4751 depth++;
4753 if(!prs_align(ps))
4754 return False;
4756 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4757 return False;
4758 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4759 return False;
4761 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4762 uint32 *ptr_sid = NULL;
4764 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4765 return False;
4767 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4768 if (!ptr_sid) {
4769 return False;
4772 for (i = 0; i < r_u->num_sids1; i++) {
4773 ptr_sid[i] = 1;
4774 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4775 return False;
4778 if (UNMARSHALLING(ps)) {
4779 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4782 for (i = 0; i < r_u->num_sids1; i++) {
4783 if (ptr_sid[i] != 0) {
4784 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4785 return False;
4790 if(!prs_align(ps))
4791 return False;
4792 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4793 return False;
4795 return True;
4798 /*******************************************************************
4799 inits a SAMR_Q_LOOKUP_NAMES structure.
4800 ********************************************************************/
4802 NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4803 POLICY_HND *pol, uint32 flags,
4804 uint32 num_names, const char **name)
4806 uint32 i;
4808 DEBUG(5, ("init_samr_q_lookup_names\n"));
4810 q_u->pol = *pol;
4812 q_u->num_names1 = num_names;
4813 q_u->flags = flags;
4814 q_u->ptr = 0;
4815 q_u->num_names2 = num_names;
4817 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4818 return NT_STATUS_NO_MEMORY;
4820 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4821 return NT_STATUS_NO_MEMORY;
4823 for (i = 0; i < num_names; i++) {
4824 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4825 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4828 return NT_STATUS_OK;
4831 /*******************************************************************
4832 reads or writes a structure.
4833 ********************************************************************/
4835 BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4836 prs_struct *ps, int depth)
4838 uint32 i;
4840 if (q_u == NULL)
4841 return False;
4843 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4844 depth++;
4846 if (UNMARSHALLING(ps))
4847 ZERO_STRUCTP(q_u);
4849 if(!prs_align(ps))
4850 return False;
4852 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4853 return False;
4855 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4856 return False;
4857 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4858 return False;
4859 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4860 return False;
4861 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4862 return False;
4864 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4865 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4866 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4867 if (!q_u->hdr_name || !q_u->uni_name)
4868 return False;
4871 for (i = 0; i < q_u->num_names2; i++) {
4872 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4873 return False;
4876 for (i = 0; i < q_u->num_names2; i++) {
4877 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4878 return False;
4881 return True;
4884 /*******************************************************************
4885 inits a SAMR_R_LOOKUP_NAMES structure.
4886 ********************************************************************/
4888 NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4889 uint32 num_rids,
4890 uint32 *rid, enum lsa_SidType *type,
4891 NTSTATUS status)
4893 DEBUG(5, ("init_samr_r_lookup_names\n"));
4895 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4896 uint32 i;
4898 r_u->num_types1 = num_rids;
4899 r_u->ptr_types = 1;
4900 r_u->num_types2 = num_rids;
4902 r_u->num_rids1 = num_rids;
4903 r_u->ptr_rids = 1;
4904 r_u->num_rids2 = num_rids;
4906 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4907 return NT_STATUS_NO_MEMORY;
4908 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
4909 return NT_STATUS_NO_MEMORY;
4911 if (!r_u->rids || !r_u->types)
4912 goto empty;
4914 for (i = 0; i < num_rids; i++) {
4915 r_u->rids[i] = rid[i];
4916 r_u->types[i] = type[i];
4918 } else {
4920 empty:
4921 r_u->num_types1 = 0;
4922 r_u->ptr_types = 0;
4923 r_u->num_types2 = 0;
4925 r_u->num_rids1 = 0;
4926 r_u->ptr_rids = 0;
4927 r_u->num_rids2 = 0;
4929 r_u->rids = NULL;
4930 r_u->types = NULL;
4933 r_u->status = status;
4935 return NT_STATUS_OK;
4938 /*******************************************************************
4939 reads or writes a structure.
4940 ********************************************************************/
4942 BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
4943 prs_struct *ps, int depth)
4945 uint32 i;
4946 fstring tmp;
4948 if (r_u == NULL)
4949 return False;
4951 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
4952 depth++;
4954 if (UNMARSHALLING(ps))
4955 ZERO_STRUCTP(r_u);
4957 if(!prs_align(ps))
4958 return False;
4960 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
4961 return False;
4962 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
4963 return False;
4965 if (r_u->ptr_rids != 0) {
4966 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
4967 return False;
4969 if (r_u->num_rids2 != r_u->num_rids1) {
4970 /* RPC fault */
4971 return False;
4974 if (UNMARSHALLING(ps))
4975 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
4977 if (!r_u->rids) {
4978 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4979 return False;
4982 for (i = 0; i < r_u->num_rids2; i++) {
4983 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4984 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
4985 return False;
4989 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4990 return False;
4991 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4992 return False;
4994 if (r_u->ptr_types != 0) {
4995 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4996 return False;
4998 if (r_u->num_types2 != r_u->num_types1) {
4999 /* RPC fault */
5000 return False;
5003 if (UNMARSHALLING(ps))
5004 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5006 if (!r_u->types) {
5007 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5008 return False;
5011 for (i = 0; i < r_u->num_types2; i++) {
5012 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5013 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5014 return False;
5018 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5019 return False;
5021 return True;
5024 /*******************************************************************
5025 inits a SAMR_Q_DELETE_DOM_USER structure.
5026 ********************************************************************/
5028 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5029 POLICY_HND *hnd)
5031 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5033 q_c->user_pol = *hnd;
5036 /*******************************************************************
5037 reads or writes a structure.
5038 ********************************************************************/
5040 BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5041 prs_struct *ps, int depth)
5043 if (q_u == NULL)
5044 return False;
5046 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5047 depth++;
5049 if(!prs_align(ps))
5050 return False;
5052 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5053 return False;
5055 return True;
5058 /*******************************************************************
5059 reads or writes a structure.
5060 ********************************************************************/
5062 BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5063 prs_struct *ps, int depth)
5065 if (r_u == NULL)
5066 return False;
5068 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5069 depth++;
5071 if(!prs_align(ps))
5072 return False;
5074 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5075 return False;
5076 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5077 return False;
5079 return True;
5082 /*******************************************************************
5083 reads or writes a structure.
5084 ********************************************************************/
5086 void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5087 POLICY_HND *pol,
5088 uint32 access_mask, uint32 rid)
5090 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5092 q_u->domain_pol = *pol;
5093 q_u->access_mask = access_mask;
5094 q_u->user_rid = rid;
5097 /*******************************************************************
5098 reads or writes a structure.
5099 ********************************************************************/
5101 BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5102 prs_struct *ps, int depth)
5104 if (q_u == NULL)
5105 return False;
5107 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5108 depth++;
5110 if(!prs_align(ps))
5111 return False;
5113 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5114 return False;
5116 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5117 return False;
5118 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5119 return False;
5121 return True;
5124 /*******************************************************************
5125 reads or writes a structure.
5126 ********************************************************************/
5128 BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5129 prs_struct *ps, int depth)
5131 if (r_u == NULL)
5132 return False;
5134 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5135 depth++;
5137 if(!prs_align(ps))
5138 return False;
5140 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5141 return False;
5143 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5144 return False;
5146 return True;
5150 /*******************************************************************
5151 reads or writes a structure.
5152 ********************************************************************/
5154 void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5155 POLICY_HND *pol,
5156 const char *name,
5157 uint32 acb_info, uint32 access_mask)
5159 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5161 q_u->domain_pol = *pol;
5163 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5164 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5166 q_u->acb_info = acb_info;
5167 q_u->access_mask = access_mask;
5170 /*******************************************************************
5171 reads or writes a structure.
5172 ********************************************************************/
5174 BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5175 prs_struct *ps, int depth)
5177 if (q_u == NULL)
5178 return False;
5180 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5181 depth++;
5183 if(!prs_align(ps))
5184 return False;
5186 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5187 return False;
5189 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5190 return False;
5191 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5192 return False;
5194 if(!prs_align(ps))
5195 return False;
5196 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5197 return False;
5198 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5199 return False;
5201 return True;
5204 /*******************************************************************
5205 reads or writes a structure.
5206 ********************************************************************/
5208 BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5209 prs_struct *ps, int depth)
5211 if (r_u == NULL)
5212 return False;
5214 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5215 depth++;
5217 if(!prs_align(ps))
5218 return False;
5220 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5221 return False;
5223 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5224 return False;
5225 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5226 return False;
5227 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5228 return False;
5230 return True;
5233 /*******************************************************************
5234 inits a SAMR_Q_QUERY_USERINFO structure.
5235 ********************************************************************/
5237 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5238 const POLICY_HND *hnd, uint16 switch_value)
5240 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5242 q_u->pol = *hnd;
5243 q_u->switch_value = switch_value;
5246 /*******************************************************************
5247 reads or writes a structure.
5248 ********************************************************************/
5250 BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5251 prs_struct *ps, int depth)
5253 if (q_u == NULL)
5254 return False;
5256 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5257 depth++;
5259 if(!prs_align(ps))
5260 return False;
5262 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5263 return False;
5265 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5266 return False;
5268 return True;
5271 /*******************************************************************
5272 reads or writes a LOGON_HRS structure.
5273 ********************************************************************/
5275 static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5276 prs_struct *ps, int depth)
5278 if (hrs == NULL)
5279 return False;
5281 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5282 depth++;
5284 if(!prs_align(ps))
5285 return False;
5287 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5288 return False;
5290 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5291 return False;
5293 if(!prs_uint32("len ", ps, depth, &hrs->len))
5294 return False;
5296 if (hrs->len > sizeof(hrs->hours)) {
5297 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5298 hrs->len = sizeof(hrs->hours);
5301 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5302 return False;
5304 return True;
5307 /*******************************************************************
5308 inits a SAM_USER_INFO_18 structure.
5309 ********************************************************************/
5311 void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5312 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5314 DEBUG(5, ("init_sam_user_info18\n"));
5316 usr->lm_pwd_active =
5317 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5318 usr->nt_pwd_active =
5319 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5322 /*******************************************************************
5323 reads or writes a structure.
5324 ********************************************************************/
5326 static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5327 prs_struct *ps, int depth)
5329 if (u == NULL)
5330 return False;
5332 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5333 depth++;
5335 if(!prs_align(ps))
5336 return False;
5338 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5339 return False;
5340 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5341 return False;
5343 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5344 return False;
5345 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5346 return False;
5348 return True;
5351 /*******************************************************************
5352 inits a SAM_USER_INFO_7 structure.
5353 ********************************************************************/
5355 void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5357 DEBUG(5, ("init_sam_user_info7\n"));
5359 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5360 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5364 /*******************************************************************
5365 reads or writes a structure.
5366 ********************************************************************/
5368 static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5369 prs_struct *ps, int depth)
5371 if (usr == NULL)
5372 return False;
5374 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5375 depth++;
5377 if(!prs_align(ps))
5378 return False;
5380 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5381 return False;
5383 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5384 return False;
5386 return True;
5389 /*******************************************************************
5390 inits a SAM_USER_INFO_9 structure.
5391 ********************************************************************/
5393 void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5395 DEBUG(5, ("init_sam_user_info9\n"));
5397 usr->rid_group = rid_group;
5400 /*******************************************************************
5401 reads or writes a structure.
5402 ********************************************************************/
5404 static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5405 prs_struct *ps, int depth)
5407 if (usr == NULL)
5408 return False;
5410 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5411 depth++;
5413 if(!prs_align(ps))
5414 return False;
5416 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5417 return False;
5419 return True;
5422 /*******************************************************************
5423 inits a SAM_USER_INFO_16 structure.
5424 ********************************************************************/
5426 void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5428 DEBUG(5, ("init_sam_user_info16\n"));
5430 usr->acb_info = acb_info;
5433 /*******************************************************************
5434 reads or writes a structure.
5435 ********************************************************************/
5437 static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5438 prs_struct *ps, int depth)
5440 if (usr == NULL)
5441 return False;
5443 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5444 depth++;
5446 if(!prs_align(ps))
5447 return False;
5449 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5450 return False;
5452 return True;
5455 /*******************************************************************
5456 inits a SAM_USER_INFO_17 structure.
5457 ********************************************************************/
5459 void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5460 NTTIME * expiry,
5461 char *mach_acct,
5462 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5464 DEBUG(5, ("init_sam_user_info17\n"));
5466 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5467 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5469 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5471 usr->ptr_1 = 1; /* pointer */
5472 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5473 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5475 usr->ptr_2 = 1; /* pointer */
5476 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5478 usr->ptr_3 = 1; /* pointer */
5479 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5481 usr->rid_user = rid_user;
5482 usr->rid_group = rid_group;
5484 usr->acct_ctrl = acct_ctrl;
5485 usr->unknown_3 = 0x0000;
5487 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5488 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5490 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5491 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5493 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5494 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5497 /*******************************************************************
5498 reads or writes a structure.
5499 ********************************************************************/
5501 static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5502 prs_struct *ps, int depth)
5504 if (usr == NULL)
5505 return False;
5507 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5508 depth++;
5510 if(!prs_align(ps))
5511 return False;
5513 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5514 return False;
5516 if(!smb_io_time("time", &usr->expiry, ps, depth))
5517 return False;
5519 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5520 return False;
5522 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5523 return False;
5525 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5526 return False;
5528 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5529 return False;
5530 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5531 return False;
5533 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5534 return False;
5536 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5537 return False;
5538 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5539 return False;
5541 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5542 return False;
5543 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5544 return False;
5546 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5547 return False;
5548 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5549 return False;
5550 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5551 return False;
5552 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5553 return False;
5554 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5555 return False;
5556 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5557 return False;
5559 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5560 return False;
5562 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5563 return False;
5565 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5566 return False;
5568 if(!prs_align(ps))
5569 return False;
5571 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5572 return False;
5574 return True;
5577 /*************************************************************************
5578 init_sam_user_infoa
5579 *************************************************************************/
5581 void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5582 uint8 pw_len)
5584 DEBUG(10, ("init_sam_user_info24:\n"));
5585 memcpy(usr->pass, newpass, sizeof(usr->pass));
5586 usr->pw_len = pw_len;
5589 /*******************************************************************
5590 reads or writes a structure.
5591 ********************************************************************/
5593 static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5594 prs_struct *ps, int depth)
5596 if (usr == NULL)
5597 return False;
5599 prs_debug(ps, depth, desc, "sam_io_user_info24");
5600 depth++;
5602 if(!prs_align(ps))
5603 return False;
5605 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5606 sizeof(usr->pass)))
5607 return False;
5609 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5610 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5611 return False;
5612 } else if (UNMARSHALLING(ps)) {
5613 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5614 return False;
5617 return True;
5620 /*******************************************************************
5621 reads or writes a structure.
5622 ********************************************************************/
5624 static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5625 prs_struct *ps, int depth)
5627 if (usr == NULL)
5628 return False;
5630 prs_debug(ps, depth, desc, "sam_io_user_info26");
5631 depth++;
5633 if(!prs_align(ps))
5634 return False;
5636 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5637 sizeof(usr->pass)))
5638 return False;
5640 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5641 return False;
5643 return True;
5647 /*************************************************************************
5648 init_sam_user_info23
5650 unknown_6 = 0x0000 04ec
5652 *************************************************************************/
5654 void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5655 NTTIME * logoff_time, /* all zeros */
5656 NTTIME * kickoff_time, /* all zeros */
5657 NTTIME * pass_last_set_time, /* all zeros */
5658 NTTIME * pass_can_change_time, /* all zeros */
5659 NTTIME * pass_must_change_time, /* all zeros */
5660 UNISTR2 *user_name,
5661 UNISTR2 *full_name,
5662 UNISTR2 *home_dir,
5663 UNISTR2 *dir_drive,
5664 UNISTR2 *log_scr,
5665 UNISTR2 *prof_path,
5666 UNISTR2 *desc,
5667 UNISTR2 *wkstas,
5668 UNISTR2 *unk_str,
5669 UNISTR2 *mung_dial,
5670 uint32 user_rid, /* 0x0000 0000 */
5671 uint32 group_rid,
5672 uint32 acb_info,
5673 uint32 fields_present,
5674 uint16 logon_divs,
5675 LOGON_HRS * hrs,
5676 uint16 bad_password_count,
5677 uint16 logon_count,
5678 char newpass[516])
5680 usr->logon_time = *logon_time; /* all zeros */
5681 usr->logoff_time = *logoff_time; /* all zeros */
5682 usr->kickoff_time = *kickoff_time; /* all zeros */
5683 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5684 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5685 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5687 ZERO_STRUCT(usr->nt_pwd);
5688 ZERO_STRUCT(usr->lm_pwd);
5690 usr->user_rid = user_rid; /* 0x0000 0000 */
5691 usr->group_rid = group_rid;
5692 usr->acb_info = acb_info;
5693 usr->fields_present = fields_present; /* 09f8 27fa */
5695 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5696 usr->ptr_logon_hrs = hrs ? 1 : 0;
5698 if (nt_time_is_zero(pass_must_change_time)) {
5699 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5700 } else {
5701 usr->passmustchange=0;
5704 ZERO_STRUCT(usr->padding1);
5705 ZERO_STRUCT(usr->padding2);
5707 usr->bad_password_count = bad_password_count;
5708 usr->logon_count = logon_count;
5710 memcpy(usr->pass, newpass, sizeof(usr->pass));
5712 copy_unistr2(&usr->uni_user_name, user_name);
5713 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5715 copy_unistr2(&usr->uni_full_name, full_name);
5716 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5718 copy_unistr2(&usr->uni_home_dir, home_dir);
5719 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5721 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5722 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5724 copy_unistr2(&usr->uni_logon_script, log_scr);
5725 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5727 copy_unistr2(&usr->uni_profile_path, prof_path);
5728 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5730 copy_unistr2(&usr->uni_acct_desc, desc);
5731 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5733 copy_unistr2(&usr->uni_workstations, wkstas);
5734 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5736 copy_unistr2(&usr->uni_comment, unk_str);
5737 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5739 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5740 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5742 if (hrs) {
5743 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5744 } else {
5745 ZERO_STRUCT(usr->logon_hrs);
5749 /*************************************************************************
5750 init_sam_user_info23
5752 unknown_6 = 0x0000 04ec
5754 *************************************************************************/
5756 void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5757 NTTIME * logoff_time, /* all zeros */
5758 NTTIME * kickoff_time, /* all zeros */
5759 NTTIME * pass_last_set_time, /* all zeros */
5760 NTTIME * pass_can_change_time, /* all zeros */
5761 NTTIME * pass_must_change_time, /* all zeros */
5762 char *user_name, /* NULL */
5763 char *full_name,
5764 char *home_dir, char *dir_drive, char *log_scr,
5765 char *prof_path, const char *desc, char *wkstas,
5766 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5767 uint32 group_rid, uint32 acb_info,
5768 uint32 fields_present, uint16 logon_divs,
5769 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5770 char newpass[516])
5772 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5774 usr->logon_time = *logon_time; /* all zeros */
5775 usr->logoff_time = *logoff_time; /* all zeros */
5776 usr->kickoff_time = *kickoff_time; /* all zeros */
5777 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5778 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5779 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5781 ZERO_STRUCT(usr->nt_pwd);
5782 ZERO_STRUCT(usr->lm_pwd);
5784 usr->user_rid = user_rid; /* 0x0000 0000 */
5785 usr->group_rid = group_rid;
5786 usr->acb_info = acb_info;
5787 usr->fields_present = fields_present; /* 09f8 27fa */
5789 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5790 usr->ptr_logon_hrs = hrs ? 1 : 0;
5792 if (nt_time_is_zero(pass_must_change_time)) {
5793 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5794 } else {
5795 usr->passmustchange=0;
5798 ZERO_STRUCT(usr->padding1);
5799 ZERO_STRUCT(usr->padding2);
5801 usr->bad_password_count = bad_password_count;
5802 usr->logon_count = logon_count;
5804 memcpy(usr->pass, newpass, sizeof(usr->pass));
5806 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5807 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5809 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5810 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5812 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5813 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5815 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5816 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5818 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5819 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5821 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5822 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5824 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5825 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5827 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5828 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5830 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5831 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5833 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5834 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5836 data_blob_free(&blob);
5838 if (hrs) {
5839 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5840 } else {
5841 ZERO_STRUCT(usr->logon_hrs);
5845 /*******************************************************************
5846 reads or writes a structure.
5847 ********************************************************************/
5849 static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5850 prs_struct *ps, int depth)
5852 if (usr == NULL)
5853 return False;
5855 prs_debug(ps, depth, desc, "sam_io_user_info23");
5856 depth++;
5858 if(!prs_align(ps))
5859 return False;
5861 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5862 return False;
5863 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5864 return False;
5865 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5866 return False;
5867 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5868 return False;
5869 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5870 return False;
5871 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
5872 return False;
5874 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
5875 return False;
5876 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
5877 return False;
5878 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
5879 return False;
5880 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
5881 return False;
5882 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
5883 return False;
5884 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
5885 return False;
5886 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
5887 return False;
5888 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
5889 return False;
5890 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
5891 return False;
5892 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
5893 return False;
5895 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
5896 return False;
5897 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
5898 return False;
5900 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
5901 return False;
5902 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
5903 return False;
5904 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
5905 return False;
5907 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
5908 return False;
5909 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
5910 return False;
5911 if(!prs_align(ps))
5912 return False;
5913 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
5914 return False;
5916 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
5917 return False;
5918 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
5919 return False;
5921 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
5922 return False;
5923 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
5924 return False;
5925 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
5926 return False;
5929 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
5930 return False;
5932 /* here begins pointed-to data */
5934 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
5935 return False;
5937 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
5938 return False;
5940 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
5941 return False;
5943 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
5944 return False;
5946 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
5947 return False;
5949 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
5950 return False;
5952 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
5953 return False;
5955 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
5956 return False;
5958 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
5959 return False;
5961 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
5962 return False;
5964 /* ok, this is only guess-work (as usual) */
5965 if (usr->ptr_logon_hrs) {
5966 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
5967 return False;
5970 return True;
5973 /*******************************************************************
5974 reads or writes a structure.
5975 NB. This structure is *definately* incorrect. It's my best guess
5976 currently for W2K SP2. The password field is encrypted in a different
5977 way than normal... And there are definately other problems. JRA.
5978 ********************************************************************/
5980 static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
5982 if (usr == NULL)
5983 return False;
5985 prs_debug(ps, depth, desc, "sam_io_user_info25");
5986 depth++;
5988 if(!prs_align(ps))
5989 return False;
5991 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5992 return False;
5993 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5994 return False;
5995 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5996 return False;
5997 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5998 return False;
5999 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6000 return False;
6001 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6002 return False;
6004 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6005 return False;
6006 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6007 return False;
6008 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6009 return False;
6010 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6011 return False;
6012 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6013 return False;
6014 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6015 return False;
6016 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6017 return False;
6018 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6019 return False;
6020 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6021 return False;
6022 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6023 return False;
6025 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6026 return False;
6027 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6028 return False;
6030 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6031 return False;
6032 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6033 return False;
6034 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6035 return False;
6036 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6037 return False;
6039 if(!prs_uint32s(False, "unknown_5 ", ps, depth, usr->unknown_5, 5))
6040 return False;
6042 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6043 return False;
6045 /* here begins pointed-to data */
6047 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6048 return False;
6050 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6051 return False;
6053 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6054 return False;
6056 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6057 return False;
6059 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6060 return False;
6062 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6063 return False;
6065 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6066 return False;
6068 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6069 return False;
6071 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6072 return False;
6074 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6075 return False;
6077 #if 0 /* JRA - unknown... */
6078 /* ok, this is only guess-work (as usual) */
6079 if (usr->ptr_logon_hrs) {
6080 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6081 return False;
6083 #endif
6085 return True;
6089 /*************************************************************************
6090 init_sam_user_info21W
6092 unknown_6 = 0x0000 04ec
6094 *************************************************************************/
6096 void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6097 NTTIME * logon_time,
6098 NTTIME * logoff_time,
6099 NTTIME * kickoff_time,
6100 NTTIME * pass_last_set_time,
6101 NTTIME * pass_can_change_time,
6102 NTTIME * pass_must_change_time,
6103 UNISTR2 *user_name,
6104 UNISTR2 *full_name,
6105 UNISTR2 *home_dir,
6106 UNISTR2 *dir_drive,
6107 UNISTR2 *log_scr,
6108 UNISTR2 *prof_path,
6109 UNISTR2 *desc,
6110 UNISTR2 *wkstas,
6111 UNISTR2 *unk_str,
6112 UNISTR2 *mung_dial,
6113 uchar lm_pwd[16],
6114 uchar nt_pwd[16],
6115 uint32 user_rid,
6116 uint32 group_rid,
6117 uint32 acb_info,
6118 uint32 fields_present,
6119 uint16 logon_divs,
6120 LOGON_HRS * hrs,
6121 uint16 bad_password_count,
6122 uint16 logon_count)
6124 usr->logon_time = *logon_time;
6125 usr->logoff_time = *logoff_time;
6126 usr->kickoff_time = *kickoff_time;
6127 usr->pass_last_set_time = *pass_last_set_time;
6128 usr->pass_can_change_time = *pass_can_change_time;
6129 usr->pass_must_change_time = *pass_must_change_time;
6131 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6132 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6134 usr->user_rid = user_rid;
6135 usr->group_rid = group_rid;
6136 usr->acb_info = acb_info;
6137 usr->fields_present = fields_present; /* 0x00ff ffff */
6139 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6140 usr->ptr_logon_hrs = hrs ? 1 : 0;
6141 usr->bad_password_count = bad_password_count;
6142 usr->logon_count = logon_count;
6144 if (nt_time_is_zero(pass_must_change_time)) {
6145 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6146 } else {
6147 usr->passmustchange=0;
6150 ZERO_STRUCT(usr->padding1);
6151 ZERO_STRUCT(usr->padding2);
6153 copy_unistr2(&usr->uni_user_name, user_name);
6154 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6156 copy_unistr2(&usr->uni_full_name, full_name);
6157 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6159 copy_unistr2(&usr->uni_home_dir, home_dir);
6160 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6162 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6163 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6165 copy_unistr2(&usr->uni_logon_script, log_scr);
6166 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6168 copy_unistr2(&usr->uni_profile_path, prof_path);
6169 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6171 copy_unistr2(&usr->uni_acct_desc, desc);
6172 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6174 copy_unistr2(&usr->uni_workstations, wkstas);
6175 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6177 copy_unistr2(&usr->uni_comment, unk_str);
6178 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6180 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6181 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6183 if (hrs) {
6184 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6185 } else {
6186 ZERO_STRUCT(usr->logon_hrs);
6190 /*************************************************************************
6191 init_sam_user_info21
6193 unknown_6 = 0x0000 04ec
6195 *************************************************************************/
6197 NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6199 NTTIME logon_time, logoff_time, kickoff_time,
6200 pass_last_set_time, pass_can_change_time,
6201 pass_must_change_time;
6203 const char* user_name = pdb_get_username(pw);
6204 const char* full_name = pdb_get_fullname(pw);
6205 const char* home_dir = pdb_get_homedir(pw);
6206 const char* dir_drive = pdb_get_dir_drive(pw);
6207 const char* logon_script = pdb_get_logon_script(pw);
6208 const char* profile_path = pdb_get_profile_path(pw);
6209 const char* description = pdb_get_acct_desc(pw);
6210 const char* workstations = pdb_get_workstations(pw);
6211 const char* munged_dial = pdb_get_munged_dial(pw);
6212 DATA_BLOB munged_dial_blob;
6214 uint32 user_rid;
6215 const DOM_SID *user_sid;
6217 uint32 group_rid;
6218 const DOM_SID *group_sid;
6220 if (munged_dial) {
6221 munged_dial_blob = base64_decode_data_blob(munged_dial);
6222 } else {
6223 munged_dial_blob = data_blob(NULL, 0);
6226 /* Create NTTIME structs */
6227 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6228 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6229 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6230 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6231 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw));
6232 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw));
6234 /* structure assignment */
6235 usr->logon_time = logon_time;
6236 usr->logoff_time = logoff_time;
6237 usr->kickoff_time = kickoff_time;
6238 usr->pass_last_set_time = pass_last_set_time;
6239 usr->pass_can_change_time = pass_can_change_time;
6240 usr->pass_must_change_time = pass_must_change_time;
6242 ZERO_STRUCT(usr->nt_pwd);
6243 ZERO_STRUCT(usr->lm_pwd);
6245 user_sid = pdb_get_user_sid(pw);
6247 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6248 fstring user_sid_string;
6249 fstring domain_sid_string;
6250 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6251 "the domain sid %s. Failing operation.\n",
6252 user_name,
6253 sid_to_string(user_sid_string, user_sid),
6254 sid_to_string(domain_sid_string, domain_sid)));
6255 data_blob_free(&munged_dial_blob);
6256 return NT_STATUS_UNSUCCESSFUL;
6259 group_sid = pdb_get_group_sid(pw);
6261 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6262 fstring group_sid_string;
6263 fstring domain_sid_string;
6264 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6265 "which conflicts with the domain sid %s. Failing operation.\n",
6266 user_name,
6267 sid_to_string(group_sid_string, group_sid),
6268 sid_to_string(domain_sid_string, domain_sid)));
6269 data_blob_free(&munged_dial_blob);
6270 return NT_STATUS_UNSUCCESSFUL;
6273 usr->user_rid = user_rid;
6274 usr->group_rid = group_rid;
6275 usr->acb_info = pdb_get_acct_ctrl(pw);
6278 Look at a user on a real NT4 PDC with usrmgr, press
6279 'ok'. Then you will see that fields_present is set to
6280 0x08f827fa. Look at the user immediately after that again,
6281 and you will see that 0x00fffff is returned. This solves
6282 the problem that you get access denied after having looked
6283 at the user.
6284 -- Volker
6286 usr->fields_present = pdb_build_fields_present(pw);
6288 usr->logon_divs = pdb_get_logon_divs(pw);
6289 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6290 usr->bad_password_count = pdb_get_bad_password_count(pw);
6291 usr->logon_count = pdb_get_logon_count(pw);
6293 if (pdb_get_pass_must_change_time(pw) == 0) {
6294 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6295 } else {
6296 usr->passmustchange=0;
6299 ZERO_STRUCT(usr->padding1);
6300 ZERO_STRUCT(usr->padding2);
6302 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6303 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6305 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6306 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6308 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6309 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6311 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6312 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6314 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6315 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6317 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6318 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6320 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6321 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6323 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6324 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6326 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6327 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6329 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6330 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6331 data_blob_free(&munged_dial_blob);
6333 if (pdb_get_hours(pw)) {
6334 usr->logon_hrs.max_len = 1260;
6335 usr->logon_hrs.offset = 0;
6336 usr->logon_hrs.len = pdb_get_hours_len(pw);
6337 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6338 } else {
6339 usr->logon_hrs.max_len = 1260;
6340 usr->logon_hrs.offset = 0;
6341 usr->logon_hrs.len = 0;
6342 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6345 return NT_STATUS_OK;
6348 /*******************************************************************
6349 reads or writes a structure.
6350 ********************************************************************/
6352 static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6353 prs_struct *ps, int depth)
6355 if (usr == NULL)
6356 return False;
6358 prs_debug(ps, depth, desc, "sam_io_user_info21");
6359 depth++;
6361 if(!prs_align(ps))
6362 return False;
6364 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6365 return False;
6366 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6367 return False;
6368 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6369 return False;
6370 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6371 return False;
6372 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6373 return False;
6374 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6375 return False;
6377 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6378 return False;
6379 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6380 return False;
6381 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6382 return False;
6383 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6384 return False;
6385 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6386 return False;
6387 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6388 return False;
6389 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6390 return False;
6391 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6392 return False;
6393 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6394 return False;
6395 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6396 return False;
6398 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6399 return False;
6400 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6401 return False;
6403 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6404 return False;
6405 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6406 return False;
6407 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6408 return False;
6410 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6411 return False;
6412 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6413 return False;
6414 if(!prs_align(ps))
6415 return False;
6416 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6417 return False;
6419 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6420 return False;
6421 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6422 return False;
6424 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6425 return False;
6426 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6427 return False;
6428 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6429 return False;
6431 /* here begins pointed-to data */
6433 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6434 return False;
6435 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6436 return False;
6437 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6438 return False;
6439 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6440 return False;
6441 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6442 return False;
6443 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6444 return False;
6445 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6446 return False;
6447 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6448 return False;
6449 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6450 return False;
6451 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6452 return False;
6454 /* ok, this is only guess-work (as usual) */
6455 if (usr->ptr_logon_hrs) {
6456 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6457 return False;
6460 return True;
6463 void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6465 const char *munged_dial = pdb_get_munged_dial(pw);
6466 DATA_BLOB blob;
6468 if (munged_dial) {
6469 blob = base64_decode_data_blob(munged_dial);
6470 } else {
6471 blob = data_blob(NULL, 0);
6474 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6475 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6476 data_blob_free(&blob);
6479 /*******************************************************************
6480 reads or writes a structure.
6481 ********************************************************************/
6483 static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6484 prs_struct *ps, int depth)
6486 if (usr == NULL)
6487 return False;
6489 prs_debug(ps, depth, desc, "sam_io_user_info20");
6490 depth++;
6492 if(!prs_align(ps))
6493 return False;
6495 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6496 return False;
6498 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6499 return False;
6501 return True;
6504 /*******************************************************************
6505 inits a SAM_USERINFO_CTR structure.
6506 ********************************************************************/
6508 NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6509 uint16 switch_value,
6510 SAM_USER_INFO_21 * usr)
6512 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6514 ctr->switch_value = switch_value;
6515 ctr->info.id = NULL;
6517 switch (switch_value) {
6518 case 16:
6519 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6520 if (ctr->info.id16 == NULL)
6521 return NT_STATUS_NO_MEMORY;
6523 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6524 break;
6525 #if 0
6526 /* whoops - got this wrong. i think. or don't understand what's happening. */
6527 case 17:
6529 NTTIME expire;
6530 info = (void *)&id11;
6532 expire.low = 0xffffffff;
6533 expire.high = 0x7fffffff;
6535 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6536 init_sam_user_info11(ctr->info.id17, &expire,
6537 "BROOKFIELDS$", /* name */
6538 0x03ef, /* user rid */
6539 0x201, /* group rid */
6540 0x0080); /* acb info */
6542 break;
6544 #endif
6545 case 18:
6546 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6547 if (ctr->info.id18 == NULL)
6548 return NT_STATUS_NO_MEMORY;
6550 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6551 break;
6552 case 21:
6554 SAM_USER_INFO_21 *cusr;
6555 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6556 ctr->info.id21 = cusr;
6557 if (ctr->info.id21 == NULL)
6558 return NT_STATUS_NO_MEMORY;
6559 memcpy(cusr, usr, sizeof(*usr));
6560 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6561 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6562 break;
6564 default:
6565 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6566 return NT_STATUS_INVALID_INFO_CLASS;
6569 return NT_STATUS_OK;
6572 /*******************************************************************
6573 inits a SAM_USERINFO_CTR structure.
6574 ********************************************************************/
6576 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6577 uint16 switch_value, void *info)
6579 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6581 ctr->switch_value = switch_value;
6582 ctr->info.id = info;
6584 switch (switch_value) {
6585 case 0x18:
6586 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6587 dump_data(100, (char *)sess_key->data, sess_key->length);
6588 dump_data(100, (char *)ctr->info.id24->pass, 516);
6589 break;
6590 case 0x17:
6591 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6592 dump_data(100, (char *)sess_key->data, sess_key->length);
6593 dump_data(100, (char *)ctr->info.id23->pass, 516);
6594 break;
6595 case 0x07:
6596 break;
6597 default:
6598 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6602 /*******************************************************************
6603 reads or writes a structure.
6604 ********************************************************************/
6606 static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6607 prs_struct *ps, int depth)
6609 BOOL ret;
6610 SAM_USERINFO_CTR *ctr;
6612 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6613 depth++;
6615 if (UNMARSHALLING(ps)) {
6616 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6617 if (ctr == NULL)
6618 return False;
6619 *ppctr = ctr;
6620 } else {
6621 ctr = *ppctr;
6624 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6626 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6627 return False;
6628 if(!prs_align(ps))
6629 return False;
6631 ret = False;
6633 switch (ctr->switch_value) {
6634 case 7:
6635 if (UNMARSHALLING(ps))
6636 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6637 if (ctr->info.id7 == NULL) {
6638 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6639 return False;
6641 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6642 break;
6643 case 9:
6644 if (UNMARSHALLING(ps))
6645 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6646 if (ctr->info.id9 == NULL) {
6647 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6648 return False;
6650 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6651 break;
6652 case 16:
6653 if (UNMARSHALLING(ps))
6654 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6655 if (ctr->info.id16 == NULL) {
6656 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6657 return False;
6659 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6660 break;
6661 case 17:
6662 if (UNMARSHALLING(ps))
6663 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6665 if (ctr->info.id17 == NULL) {
6666 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6667 return False;
6669 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6670 break;
6671 case 18:
6672 if (UNMARSHALLING(ps))
6673 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6675 if (ctr->info.id18 == NULL) {
6676 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6677 return False;
6679 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6680 break;
6681 case 20:
6682 if (UNMARSHALLING(ps))
6683 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6685 if (ctr->info.id20 == NULL) {
6686 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6687 return False;
6689 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6690 break;
6691 case 21:
6692 if (UNMARSHALLING(ps))
6693 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6695 if (ctr->info.id21 == NULL) {
6696 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6697 return False;
6699 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6700 break;
6701 case 23:
6702 if (UNMARSHALLING(ps))
6703 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6705 if (ctr->info.id23 == NULL) {
6706 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6707 return False;
6709 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6710 break;
6711 case 24:
6712 if (UNMARSHALLING(ps))
6713 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6715 if (ctr->info.id24 == NULL) {
6716 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6717 return False;
6719 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6720 break;
6721 case 25:
6722 if (UNMARSHALLING(ps))
6723 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6725 if (ctr->info.id25 == NULL) {
6726 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6727 return False;
6729 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6730 break;
6731 case 26:
6732 if (UNMARSHALLING(ps))
6733 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6735 if (ctr->info.id26 == NULL) {
6736 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6737 return False;
6739 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6740 break;
6741 default:
6742 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6743 ret = False;
6744 break;
6747 return ret;
6750 /*******************************************************************
6751 inits a SAMR_R_QUERY_USERINFO structure.
6752 ********************************************************************/
6754 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6755 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6757 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6759 r_u->ptr = 0;
6760 r_u->ctr = NULL;
6762 if (NT_STATUS_IS_OK(status)) {
6763 r_u->ptr = 1;
6764 r_u->ctr = ctr;
6767 r_u->status = status; /* return status */
6770 /*******************************************************************
6771 reads or writes a structure.
6772 ********************************************************************/
6774 BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6775 prs_struct *ps, int depth)
6777 if (r_u == NULL)
6778 return False;
6780 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6781 depth++;
6783 if(!prs_align(ps))
6784 return False;
6786 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6787 return False;
6789 if (r_u->ptr != 0) {
6790 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6791 return False;
6794 if(!prs_align(ps))
6795 return False;
6796 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6797 return False;
6799 return True;
6802 /*******************************************************************
6803 inits a SAMR_Q_SET_USERINFO structure.
6804 ********************************************************************/
6806 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6807 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6808 uint16 switch_value, void *info)
6810 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6812 q_u->pol = *hnd;
6813 q_u->switch_value = switch_value;
6814 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6817 /*******************************************************************
6818 reads or writes a structure.
6819 ********************************************************************/
6821 BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6822 prs_struct *ps, int depth)
6824 if (q_u == NULL)
6825 return False;
6827 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6828 depth++;
6830 if(!prs_align(ps))
6831 return False;
6833 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6835 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6836 return False;
6837 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6838 return False;
6840 return True;
6843 /*******************************************************************
6844 inits a SAMR_R_SET_USERINFO structure.
6845 ********************************************************************/
6847 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6849 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6851 r_u->status = status; /* return status */
6854 /*******************************************************************
6855 reads or writes a structure.
6856 ********************************************************************/
6858 BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
6859 prs_struct *ps, int depth)
6861 if (r_u == NULL)
6862 return False;
6864 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
6865 depth++;
6867 if(!prs_align(ps))
6868 return False;
6870 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6871 return False;
6873 return True;
6876 /*******************************************************************
6877 inits a SAMR_Q_SET_USERINFO2 structure.
6878 ********************************************************************/
6880 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
6881 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6882 uint16 switch_value, SAM_USERINFO_CTR * ctr)
6884 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6886 q_u->pol = *hnd;
6887 q_u->switch_value = switch_value;
6888 q_u->ctr = ctr;
6890 q_u->ctr->switch_value = switch_value;
6892 switch (switch_value) {
6893 case 18:
6894 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
6895 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
6896 dump_data(100, (char *)sess_key->data, sess_key->length);
6897 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
6898 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
6899 break;
6903 /*******************************************************************
6904 reads or writes a structure.
6905 ********************************************************************/
6907 BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
6908 prs_struct *ps, int depth)
6910 if (q_u == NULL)
6911 return False;
6913 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
6914 depth++;
6916 if(!prs_align(ps))
6917 return False;
6919 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
6920 return False;
6922 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6923 return False;
6924 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6925 return False;
6927 return True;
6930 /*******************************************************************
6931 inits a SAMR_R_SET_USERINFO2 structure.
6932 ********************************************************************/
6934 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
6936 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6938 r_u->status = status; /* return status */
6941 /*******************************************************************
6942 reads or writes a structure.
6943 ********************************************************************/
6945 BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
6946 prs_struct *ps, int depth)
6948 if (r_u == NULL)
6949 return False;
6951 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
6952 depth++;
6954 if(!prs_align(ps))
6955 return False;
6957 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6958 return False;
6960 return True;
6963 /*******************************************************************
6964 inits a SAMR_Q_CONNECT structure.
6965 ********************************************************************/
6967 void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
6968 char *srv_name, uint32 access_mask)
6970 DEBUG(5, ("init_samr_q_connect\n"));
6972 /* make PDC server name \\server */
6973 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
6974 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
6976 /* example values: 0x0000 0002 */
6977 q_u->access_mask = access_mask;
6980 /*******************************************************************
6981 reads or writes a structure.
6982 ********************************************************************/
6984 BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
6985 prs_struct *ps, int depth)
6987 if (q_u == NULL)
6988 return False;
6990 prs_debug(ps, depth, desc, "samr_io_q_connect");
6991 depth++;
6993 if(!prs_align(ps))
6994 return False;
6996 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
6997 return False;
6998 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
6999 return False;
7001 if(!prs_align(ps))
7002 return False;
7003 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7004 return False;
7006 return True;
7009 /*******************************************************************
7010 reads or writes a structure.
7011 ********************************************************************/
7013 BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7014 prs_struct *ps, int depth)
7016 if (r_u == NULL)
7017 return False;
7019 prs_debug(ps, depth, desc, "samr_io_r_connect");
7020 depth++;
7022 if(!prs_align(ps))
7023 return False;
7025 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7026 return False;
7028 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7029 return False;
7031 return True;
7034 /*******************************************************************
7035 inits a SAMR_Q_CONNECT4 structure.
7036 ********************************************************************/
7038 void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7039 char *srv_name, uint32 access_mask)
7041 DEBUG(5, ("init_samr_q_connect4\n"));
7043 /* make PDC server name \\server */
7044 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7045 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7047 /* Only value we've seen, possibly an address type ? */
7048 q_u->unk_0 = 2;
7050 /* example values: 0x0000 0002 */
7051 q_u->access_mask = access_mask;
7054 /*******************************************************************
7055 reads or writes a structure.
7056 ********************************************************************/
7058 BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7059 prs_struct *ps, int depth)
7061 if (q_u == NULL)
7062 return False;
7064 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7065 depth++;
7067 if(!prs_align(ps))
7068 return False;
7070 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7071 return False;
7072 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7073 return False;
7075 if(!prs_align(ps))
7076 return False;
7077 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7078 return False;
7079 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7080 return False;
7082 return True;
7085 /*******************************************************************
7086 reads or writes a structure.
7087 ********************************************************************/
7089 BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7090 prs_struct *ps, int depth)
7092 if (r_u == NULL)
7093 return False;
7095 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7096 depth++;
7098 if(!prs_align(ps))
7099 return False;
7101 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7102 return False;
7104 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7105 return False;
7107 return True;
7110 /*******************************************************************
7111 inits a SAMR_Q_CONNECT5 structure.
7112 ********************************************************************/
7114 void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7115 char *srv_name, uint32 access_mask)
7117 DEBUG(5, ("init_samr_q_connect5\n"));
7119 /* make PDC server name \\server */
7120 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7121 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7123 /* example values: 0x0000 0002 */
7124 q_u->access_mask = access_mask;
7126 q_u->level = 1;
7127 q_u->info1_unk1 = 3;
7128 q_u->info1_unk2 = 0;
7131 /*******************************************************************
7132 inits a SAMR_R_CONNECT5 structure.
7133 ********************************************************************/
7135 void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7137 DEBUG(5, ("init_samr_q_connect5\n"));
7139 r_u->level = 1;
7140 r_u->info1_unk1 = 3;
7141 r_u->info1_unk2 = 0;
7143 r_u->connect_pol = *pol;
7144 r_u->status = status;
7147 /*******************************************************************
7148 reads or writes a structure.
7149 ********************************************************************/
7151 BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7152 prs_struct *ps, int depth)
7154 if (q_u == NULL)
7155 return False;
7157 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7158 depth++;
7160 if(!prs_align(ps))
7161 return False;
7163 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7164 return False;
7165 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7166 return False;
7168 if(!prs_align(ps))
7169 return False;
7170 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7171 return False;
7173 if(!prs_uint32("level", ps, depth, &q_u->level))
7174 return False;
7175 if(!prs_uint32("level", ps, depth, &q_u->level))
7176 return False;
7178 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7179 return False;
7180 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7181 return False;
7183 return True;
7186 /*******************************************************************
7187 reads or writes a structure.
7188 ********************************************************************/
7190 BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7191 prs_struct *ps, int depth)
7193 if (r_u == NULL)
7194 return False;
7196 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7197 depth++;
7199 if(!prs_align(ps))
7200 return False;
7202 if(!prs_uint32("level", ps, depth, &r_u->level))
7203 return False;
7204 if(!prs_uint32("level", ps, depth, &r_u->level))
7205 return False;
7206 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7207 return False;
7208 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7209 return False;
7211 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7212 return False;
7214 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7215 return False;
7217 return True;
7220 /*******************************************************************
7221 inits a SAMR_Q_CONNECT_ANON structure.
7222 ********************************************************************/
7224 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7226 DEBUG(5, ("init_samr_q_connect_anon\n"));
7228 q_u->ptr = 1;
7229 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7230 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7233 /*******************************************************************
7234 reads or writes a structure.
7235 ********************************************************************/
7237 BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7238 prs_struct *ps, int depth)
7240 if (q_u == NULL)
7241 return False;
7243 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7244 depth++;
7246 if(!prs_align(ps))
7247 return False;
7249 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7250 return False;
7251 if (q_u->ptr) {
7252 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7253 return False;
7255 if(!prs_align(ps))
7256 return False;
7257 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7258 return False;
7260 return True;
7263 /*******************************************************************
7264 reads or writes a structure.
7265 ********************************************************************/
7267 BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7268 prs_struct *ps, int depth)
7270 if (r_u == NULL)
7271 return False;
7273 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7274 depth++;
7276 if(!prs_align(ps))
7277 return False;
7279 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7280 return False;
7282 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7283 return False;
7285 return True;
7288 /*******************************************************************
7289 inits a SAMR_Q_GET_DOM_PWINFO structure.
7290 ********************************************************************/
7292 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7293 char *srv_name)
7295 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7297 q_u->ptr = 1;
7298 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7299 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7302 /*******************************************************************
7303 reads or writes a structure.
7304 ********************************************************************/
7306 BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7307 prs_struct *ps, int depth)
7309 if (q_u == NULL)
7310 return False;
7312 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7313 depth++;
7315 if(!prs_align(ps))
7316 return False;
7318 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7319 return False;
7320 if (q_u->ptr != 0) {
7321 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7322 return False;
7323 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7324 return False;
7327 return True;
7330 /*******************************************************************
7331 reads or writes a structure.
7332 ********************************************************************/
7334 BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7335 prs_struct *ps, int depth)
7337 if (r_u == NULL)
7338 return False;
7340 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7341 depth++;
7343 if(!prs_align(ps))
7344 return False;
7346 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7347 return False;
7348 if(!prs_align(ps))
7349 return False;
7350 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7351 return False;
7353 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7354 return False;
7356 return True;
7359 /*******************************************************************
7360 make a SAMR_ENC_PASSWD structure.
7361 ********************************************************************/
7363 void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7365 ZERO_STRUCTP(pwd);
7367 if (pass == NULL) {
7368 pwd->ptr = 0;
7369 } else {
7370 pwd->ptr = 1;
7371 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7375 /*******************************************************************
7376 reads or writes a SAMR_ENC_PASSWD structure.
7377 ********************************************************************/
7379 BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7380 prs_struct *ps, int depth)
7382 if (pwd == NULL)
7383 return False;
7385 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7386 depth++;
7388 if(!prs_align(ps))
7389 return False;
7391 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7392 return False;
7394 if (pwd->ptr != 0) {
7395 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7396 return False;
7399 return True;
7402 /*******************************************************************
7403 inits a SAMR_ENC_HASH structure.
7404 ********************************************************************/
7406 void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7408 ZERO_STRUCTP(hsh);
7410 if (hash == NULL) {
7411 hsh->ptr = 0;
7412 } else {
7413 hsh->ptr = 1;
7414 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7418 /*******************************************************************
7419 reads or writes a SAMR_ENC_HASH structure.
7420 ********************************************************************/
7422 BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7423 prs_struct *ps, int depth)
7425 if (hsh == NULL)
7426 return False;
7428 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7429 depth++;
7431 if(!prs_align(ps))
7432 return False;
7434 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7435 return False;
7436 if (hsh->ptr != 0) {
7437 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7438 return False;
7441 return True;
7444 /*******************************************************************
7445 inits a SAMR_Q_CHGPASSWD_USER structure.
7446 ********************************************************************/
7448 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7449 const char *dest_host, const char *user_name,
7450 const uchar nt_newpass[516],
7451 const uchar nt_oldhash[16],
7452 const uchar lm_newpass[516],
7453 const uchar lm_oldhash[16])
7455 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7457 q_u->ptr_0 = 1;
7458 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7459 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7461 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7462 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7464 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7465 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7467 q_u->unknown = 0x01;
7469 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7470 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7473 /*******************************************************************
7474 reads or writes a structure.
7475 ********************************************************************/
7477 BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7478 prs_struct *ps, int depth)
7480 if (q_u == NULL)
7481 return False;
7483 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7484 depth++;
7486 if(!prs_align(ps))
7487 return False;
7489 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7490 return False;
7492 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7493 return False;
7494 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7495 return False;
7497 if(!prs_align(ps))
7498 return False;
7499 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7500 return False;
7501 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7502 return False;
7504 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7505 return False;
7506 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7507 return False;
7509 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7510 return False;
7512 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7513 return False;
7514 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7515 return False;
7517 return True;
7520 /*******************************************************************
7521 inits a SAMR_R_CHGPASSWD_USER structure.
7522 ********************************************************************/
7524 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7526 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7528 r_u->status = status;
7531 /*******************************************************************
7532 reads or writes a structure.
7533 ********************************************************************/
7535 BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7536 prs_struct *ps, int depth)
7538 if (r_u == NULL)
7539 return False;
7541 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7542 depth++;
7544 if(!prs_align(ps))
7545 return False;
7547 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7548 return False;
7550 return True;
7553 /*******************************************************************
7554 inits a SAMR_Q_CHGPASSWD3 structure.
7555 ********************************************************************/
7557 void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7558 const char *dest_host, const char *user_name,
7559 const uchar nt_newpass[516],
7560 const uchar nt_oldhash[16],
7561 const uchar lm_newpass[516],
7562 const uchar lm_oldhash[16])
7564 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7566 q_u->ptr_0 = 1;
7567 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7568 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7570 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7571 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7573 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7574 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7576 q_u->lm_change = 0x01;
7578 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7579 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7581 init_enc_passwd(&q_u->password3, NULL);
7584 /*******************************************************************
7585 reads or writes a structure.
7586 ********************************************************************/
7588 BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7589 prs_struct *ps, int depth)
7591 if (q_u == NULL)
7592 return False;
7594 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7595 depth++;
7597 if(!prs_align(ps))
7598 return False;
7600 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7601 return False;
7603 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7604 return False;
7605 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7606 return False;
7608 if(!prs_align(ps))
7609 return False;
7610 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7611 return False;
7612 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7613 return False;
7615 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7616 return False;
7617 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7618 return False;
7620 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7621 return False;
7623 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7624 return False;
7625 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7626 return False;
7628 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7629 return False;
7631 return True;
7634 /*******************************************************************
7635 inits a SAMR_R_CHGPASSWD_USER3 structure.
7636 ********************************************************************/
7638 void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7639 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7641 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7643 r_u->status = status;
7644 r_u->info = 0;
7645 r_u->ptr_info = 0;
7646 r_u->reject = 0;
7647 r_u->ptr_reject = 0;
7649 if (info) {
7650 r_u->info = info;
7651 r_u->ptr_info = 1;
7653 if (reject && (reject->reject_reason != Undefined)) {
7654 r_u->reject = reject;
7655 r_u->ptr_reject = 1;
7659 /*******************************************************************
7660 Reads or writes an SAMR_CHANGE_REJECT structure.
7661 ********************************************************************/
7663 BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7665 if (reject == NULL)
7666 return False;
7668 prs_debug(ps, depth, desc, "samr_io_change_reject");
7669 depth++;
7671 if(!prs_align(ps))
7672 return False;
7674 if(UNMARSHALLING(ps))
7675 ZERO_STRUCTP(reject);
7677 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7678 return False;
7680 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7681 return False;
7683 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7684 return False;
7686 return True;
7689 /*******************************************************************
7690 reads or writes a structure.
7691 ********************************************************************/
7693 BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7694 prs_struct *ps, int depth)
7696 if (r_u == NULL)
7697 return False;
7699 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7700 depth++;
7702 if (!prs_align(ps))
7703 return False;
7705 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7706 return False;
7708 if (r_u->ptr_info && r_u->info != NULL) {
7709 /* SAM_UNK_INFO_1 */
7710 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7711 return False;
7714 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7715 return False;
7717 if (r_u->ptr_reject && r_u->reject != NULL) {
7718 /* SAMR_CHANGE_REJECT */
7719 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7720 return False;
7723 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7724 return False;
7726 return True;
7729 /*******************************************************************
7730 reads or writes a structure.
7731 ********************************************************************/
7733 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7734 POLICY_HND *domain_pol, uint16 switch_value)
7736 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7738 q_u->domain_pol = *domain_pol;
7739 q_u->switch_value = switch_value;
7742 /*******************************************************************
7743 reads or writes a structure.
7744 ********************************************************************/
7746 BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7747 prs_struct *ps, int depth)
7749 if (q_u == NULL)
7750 return False;
7752 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7753 depth++;
7755 if(!prs_align(ps))
7756 return False;
7758 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7759 return False;
7761 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7762 return False;
7764 return True;
7767 /*******************************************************************
7768 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7769 ********************************************************************/
7771 void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7772 uint16 switch_value, SAM_UNK_CTR * ctr,
7773 NTSTATUS status)
7775 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7777 r_u->ptr_0 = 0;
7778 r_u->switch_value = 0;
7779 r_u->status = status; /* return status */
7781 if (NT_STATUS_IS_OK(status)) {
7782 r_u->switch_value = switch_value;
7783 r_u->ptr_0 = 1;
7784 r_u->ctr = ctr;
7788 /*******************************************************************
7789 reads or writes a structure.
7790 ********************************************************************/
7792 BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7793 prs_struct *ps, int depth)
7795 if (r_u == NULL)
7796 return False;
7798 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7799 depth++;
7801 if(!prs_align(ps))
7802 return False;
7804 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7805 return False;
7807 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7808 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7809 return False;
7810 if(!prs_align(ps))
7811 return False;
7813 switch (r_u->switch_value) {
7814 case 0x0d:
7815 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7816 return False;
7817 break;
7818 case 0x0c:
7819 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7820 return False;
7821 break;
7822 case 0x09:
7823 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7824 return False;
7825 break;
7826 case 0x08:
7827 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7828 return False;
7829 break;
7830 case 0x07:
7831 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7832 return False;
7833 break;
7834 case 0x06:
7835 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7836 return False;
7837 break;
7838 case 0x05:
7839 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7840 return False;
7841 break;
7842 case 0x04:
7843 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
7844 return False;
7845 break;
7846 case 0x03:
7847 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
7848 return False;
7849 break;
7850 case 0x02:
7851 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
7852 return False;
7853 break;
7854 case 0x01:
7855 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
7856 return False;
7857 break;
7858 default:
7859 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
7860 r_u->switch_value));
7861 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
7862 return False;
7866 if(!prs_align(ps))
7867 return False;
7869 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7870 return False;
7872 return True;
7876 /*******************************************************************
7877 reads or writes a structure.
7878 ********************************************************************/
7880 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
7881 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
7883 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7885 q_u->domain_pol = *domain_pol;
7886 q_u->switch_value0 = switch_value;
7888 q_u->switch_value = switch_value;
7889 q_u->ctr = ctr;
7893 /*******************************************************************
7894 reads or writes a structure.
7895 ********************************************************************/
7897 BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
7898 prs_struct *ps, int depth)
7900 if (q_u == NULL)
7901 return False;
7903 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
7904 depth++;
7906 if(!prs_align(ps))
7907 return False;
7909 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7910 return False;
7912 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
7913 return False;
7915 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7916 return False;
7918 if(!prs_align(ps))
7919 return False;
7921 if (UNMARSHALLING(ps)) {
7922 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
7923 return False;
7926 switch (q_u->switch_value) {
7928 case 0x0c:
7929 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
7930 return False;
7931 break;
7932 case 0x07:
7933 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
7934 return False;
7935 break;
7936 case 0x06:
7937 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
7938 return False;
7939 break;
7940 case 0x05:
7941 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
7942 return False;
7943 break;
7944 case 0x03:
7945 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
7946 return False;
7947 break;
7948 case 0x02:
7949 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
7950 return False;
7951 break;
7952 case 0x01:
7953 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
7954 return False;
7955 break;
7956 default:
7957 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7958 q_u->switch_value));
7959 return False;
7962 return True;
7965 /*******************************************************************
7966 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7967 ********************************************************************/
7969 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
7971 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7973 r_u->status = status; /* return status */
7976 /*******************************************************************
7977 reads or writes a structure.
7978 ********************************************************************/
7980 BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
7981 prs_struct *ps, int depth)
7983 if (r_u == NULL)
7984 return False;
7986 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
7987 depth++;
7989 if(!prs_align(ps))
7990 return False;
7992 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7993 return False;
7995 return True;