source: branches/samba-3.0/source/rpc_parse/parse_samr.c

Last change on this file was 134, checked in by Paul Smedley, 17 years ago

Update source to 3.0.29

File size: 223.8 KB
Line 
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.
11 *
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.
16 *
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.
21 *
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.
25 */
26
27#include "includes.h"
28
29#undef DBGC_CLASS
30#define DBGC_CLASS DBGC_RPC_PARSE
31
32/*******************************************************************
33inits a SAMR_Q_CLOSE_HND structure.
34********************************************************************/
35
36void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd)
37{
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
39
40 q_c->pol = *hnd;
41}
42
43/*******************************************************************
44reads or writes a structure.
45********************************************************************/
46
47BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u,
48 prs_struct *ps, int depth)
49{
50 if (q_u == NULL)
51 return False;
52
53 prs_debug(ps, depth, desc, "samr_io_q_close_hnd");
54 depth++;
55
56 if(!prs_align(ps))
57 return False;
58
59 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);
60}
61
62/*******************************************************************
63reads or writes a structure.
64********************************************************************/
65
66BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u,
67 prs_struct *ps, int depth)
68{
69 if (r_u == NULL)
70 return False;
71
72 prs_debug(ps, depth, desc, "samr_io_r_close_hnd");
73 depth++;
74
75 if(!prs_align(ps))
76 return False;
77
78 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
79 return False;
80
81 if(!prs_ntstatus("status", ps, depth, &r_u->status))
82 return False;
83
84 return True;
85}
86
87/*******************************************************************
88inits a SAMR_Q_LOOKUP_DOMAIN structure.
89********************************************************************/
90
91void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
92 POLICY_HND *pol, char *dom_name)
93{
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
95
96 q_u->connect_pol = *pol;
97
98 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
99 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
100}
101
102/*******************************************************************
103reads or writes a structure.
104********************************************************************/
105BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u,
106 prs_struct *ps, int depth)
107{
108 if (q_u == NULL)
109 return False;
110
111 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain");
112 depth++;
113
114 if(!prs_align(ps))
115 return False;
116
117 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth))
118 return False;
119
120 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth))
121 return False;
122
123 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth))
124 return False;
125
126 return True;
127}
128
129/*******************************************************************
130inits a SAMR_R_LOOKUP_DOMAIN structure.
131********************************************************************/
132
133void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u,
134 DOM_SID *dom_sid, NTSTATUS status)
135{
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
137
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);
143 }
144}
145
146/*******************************************************************
147reads or writes a structure.
148********************************************************************/
149
150BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u,
151 prs_struct *ps, int depth)
152{
153 if (r_u == NULL)
154 return False;
155
156 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain");
157 depth++;
158
159 if(!prs_align(ps))
160 return False;
161
162 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid))
163 return False;
164
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;
170 }
171
172 if(!prs_ntstatus("status", ps, depth, &r_u->status))
173 return False;
174
175 return True;
176}
177
178/*******************************************************************
179reads or writes a structure.
180********************************************************************/
181
182void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid)
183{
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
185
186 q_u->dom_pol = *dom_pol;
187 init_dom_sid2(&q_u->sid, sid);
188}
189
190/*******************************************************************
191reads or writes a structure.
192********************************************************************/
193
194BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u,
195 prs_struct *ps, int depth)
196{
197 if (q_u == NULL)
198 return False;
199
200 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain");
201 depth++;
202
203 if(!prs_align(ps))
204 return False;
205
206 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
207 return False;
208
209 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth))
210 return False;
211
212 if(!prs_align(ps))
213 return False;
214
215 return True;
216}
217
218/*******************************************************************
219reads or writes a structure.
220********************************************************************/
221
222BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u,
223 prs_struct *ps, int depth)
224{
225 if (r_u == NULL)
226 return False;
227
228 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain");
229 depth++;
230
231 if(!prs_align(ps))
232 return False;
233
234 if(!prs_ntstatus("status", ps, depth, &r_u->status))
235 return False;
236
237 return True;
238}
239
240/*******************************************************************
241reads or writes a structure.
242********************************************************************/
243
244void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u,
245 POLICY_HND *pol, uint32 flags,
246 const DOM_SID *sid)
247{
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
249
250 q_u->pol = *pol;
251 q_u->flags = flags;
252 init_dom_sid2(&q_u->dom_sid, sid);
253}
254
255/*******************************************************************
256reads or writes a structure.
257********************************************************************/
258
259BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u,
260 prs_struct *ps, int depth)
261{
262 if (q_u == NULL)
263 return False;
264
265 prs_debug(ps, depth, desc, "samr_io_q_open_domain");
266 depth++;
267
268 if(!prs_align(ps))
269 return False;
270
271 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
272 return False;
273
274 if(!prs_uint32("flags", ps, depth, &q_u->flags))
275 return False;
276
277 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth))
278 return False;
279
280 return True;
281}
282
283/*******************************************************************
284reads or writes a structure.
285********************************************************************/
286
287BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u,
288 prs_struct *ps, int depth)
289{
290 if (r_u == NULL)
291 return False;
292
293 prs_debug(ps, depth, desc, "samr_io_r_open_domain");
294 depth++;
295
296 if(!prs_align(ps))
297 return False;
298
299 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth))
300 return False;
301
302 if(!prs_ntstatus("status", ps, depth, &r_u->status))
303 return False;
304
305 return True;
306}
307
308/*******************************************************************
309reads or writes a structure.
310********************************************************************/
311
312void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u,
313 POLICY_HND *user_pol)
314{
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
316
317 q_u->user_pol = *user_pol;
318}
319
320/*******************************************************************
321reads or writes a structure.
322********************************************************************/
323
324BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u,
325 prs_struct *ps, int depth)
326{
327 if (q_u == NULL)
328 return False;
329
330 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo");
331 depth++;
332
333 if(!prs_align(ps))
334 return False;
335
336 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);
337}
338
339/*******************************************************************
340 Init.
341********************************************************************/
342
343void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status)
344{
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
346
347 r_u->min_pwd_length = 0x0000;
348
349 /*
350 * used to be
351 * r_u->unknown_1 = 0x0015;
352 * but for trusts.
353 */
354 r_u->unknown_1 = 0x01D1;
355 r_u->unknown_1 = 0x0015;
356
357 r_u->password_properties = 0x00000000;
358
359 r_u->status = status;
360}
361
362/*******************************************************************
363reads or writes a structure.
364********************************************************************/
365
366BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u,
367 prs_struct *ps, int depth)
368{
369 if (r_u == NULL)
370 return False;
371
372 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo");
373 depth++;
374
375 if(!prs_align(ps))
376 return False;
377
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;
384
385 if(!prs_ntstatus("status ", ps, depth, &r_u->status))
386 return False;
387
388 return True;
389}
390
391
392/*******************************************************************
393reads or writes a structure.
394********************************************************************/
395
396BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u,
397 prs_struct *ps, int depth)
398{
399 if (q_u == NULL)
400 return False;
401
402 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj");
403 depth++;
404
405 if(!prs_align(ps))
406 return False;
407
408 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
409 return False;
410
411 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
412 return False;
413
414 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth))
415 return False;
416
417 return True;
418}
419
420
421/*******************************************************************
422reads or writes a structure.
423********************************************************************/
424
425void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u,
426 POLICY_HND *user_pol, uint32 sec_info)
427{
428 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
429
430 q_u->user_pol = *user_pol;
431 q_u->sec_info = sec_info;
432}
433
434
435/*******************************************************************
436reads or writes a structure.
437********************************************************************/
438
439BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u,
440 prs_struct *ps, int depth)
441{
442 if (q_u == NULL)
443 return False;
444
445 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj");
446 depth++;
447
448 if(!prs_align(ps))
449 return False;
450
451 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
452 return False;
453
454 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
455 return False;
456
457 return True;
458}
459
460/*******************************************************************
461reads or writes a structure.
462********************************************************************/
463
464void init_samr_q_query_domain_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u,
465 POLICY_HND *domain_pol, uint16 switch_value)
466{
467 DEBUG(5, ("samr_init_samr_q_query_domain_info\n"));
468
469 q_u->domain_pol = *domain_pol;
470 q_u->switch_value = switch_value;
471}
472
473/*******************************************************************
474reads or writes a structure.
475********************************************************************/
476
477BOOL samr_io_q_query_domain_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u,
478 prs_struct *ps, int depth)
479{
480 if (q_u == NULL)
481 return False;
482
483 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info");
484 depth++;
485
486 if(!prs_align(ps))
487 return False;
488
489 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
490 return False;
491
492 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
493 return False;
494
495 return True;
496}
497
498/*******************************************************************
499inits a structure.
500********************************************************************/
501
502void 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)
504{
505 u_1->min_length_password = min_pass_len;
506 u_1->password_history = pass_hist;
507
508 if (lp_check_password_script() && *lp_check_password_script()) {
509 password_properties |= DOMAIN_PASSWORD_COMPLEX;
510 }
511 u_1->password_properties = password_properties;
512
513 /* password never expire */
514 u_1->expire = nt_expire;
515
516 /* can change the password now */
517 u_1->min_passwordage = nt_min_age;
518
519}
520
521/*******************************************************************
522reads or writes a structure.
523********************************************************************/
524
525static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1,
526 prs_struct *ps, int depth)
527{
528 if (u_1 == NULL)
529 return False;
530
531 prs_debug(ps, depth, desc, "sam_io_unk_info1");
532 depth++;
533
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;
544
545 return True;
546}
547
548/*******************************************************************
549inits a structure.
550********************************************************************/
551
552void 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)
555{
556 u_2->logout = nt_logout;
557
558 u_2->seq_num = seq_num;
559
560
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;
567
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);
574}
575
576/*******************************************************************
577reads or writes a structure.
578********************************************************************/
579
580static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2,
581 prs_struct *ps, int depth)
582{
583 if (u_2 == NULL)
584 return False;
585
586 prs_debug(ps, depth, desc, "sam_io_unk_info2");
587 depth++;
588
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;
597
598 /* put all the data in here, at the moment, including what the above
599 pointer is referring to
600 */
601
602 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num))
603 return False;
604
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;
617
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;
624
625 return True;
626}
627
628/*******************************************************************
629inits a structure.
630********************************************************************/
631
632void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout)
633{
634 u_3->logout = nt_logout;
635}
636
637/*******************************************************************
638reads or writes a structure.
639********************************************************************/
640
641static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3,
642 prs_struct *ps, int depth)
643{
644 if (u_3 == NULL)
645 return False;
646
647 prs_debug(ps, depth, desc, "sam_io_unk_info3");
648 depth++;
649
650 if(!smb_io_time("logout", &u_3->logout, ps, depth))
651 return False;
652
653 return True;
654}
655
656/*******************************************************************
657inits a structure.
658********************************************************************/
659
660void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment)
661{
662 init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE);
663 init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment);
664}
665
666/*******************************************************************
667reads or writes a structure.
668********************************************************************/
669
670static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4,
671 prs_struct *ps, int depth)
672{
673 if (u_4 == NULL)
674 return False;
675
676 prs_debug(ps, depth, desc, "sam_io_unk_info4");
677 depth++;
678
679 if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth))
680 return False;
681
682 if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth))
683 return False;
684
685 return True;
686}
687
688/*******************************************************************
689inits a structure.
690********************************************************************/
691
692void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *domain)
693{
694 init_unistr2(&u_5->uni_domain, domain, UNI_FLAGS_NONE);
695 init_uni_hdr(&u_5->hdr_domain, &u_5->uni_domain);
696}
697
698/*******************************************************************
699reads or writes a structure.
700********************************************************************/
701
702static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
703 prs_struct *ps, int depth)
704{
705 if (u_5 == NULL)
706 return False;
707
708 prs_debug(ps, depth, desc, "sam_io_unk_info5");
709 depth++;
710
711 if(!smb_io_unihdr("hdr_domain", &u_5->hdr_domain, ps, depth))
712 return False;
713
714 if(!smb_io_unistr2("uni_domain", &u_5->uni_domain, u_5->hdr_domain.buffer, ps, depth))
715 return False;
716
717 return True;
718}
719
720/*******************************************************************
721inits a structure.
722********************************************************************/
723
724void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server)
725{
726 init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE);
727 init_uni_hdr(&u_6->hdr_server, &u_6->uni_server);
728}
729
730/*******************************************************************
731reads or writes a structure.
732********************************************************************/
733
734static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6,
735 prs_struct *ps, int depth)
736{
737 if (u_6 == NULL)
738 return False;
739
740 prs_debug(ps, depth, desc, "sam_io_unk_info6");
741 depth++;
742
743 if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth))
744 return False;
745
746 if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth))
747 return False;
748
749 return True;
750}
751
752/*******************************************************************
753inits a structure.
754********************************************************************/
755
756void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role)
757{
758 u_7->server_role = server_role;
759}
760
761/*******************************************************************
762reads or writes a structure.
763********************************************************************/
764
765static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7,
766 prs_struct *ps, int depth)
767{
768 if (u_7 == NULL)
769 return False;
770
771 prs_debug(ps, depth, desc, "sam_io_unk_info7");
772 depth++;
773
774 if(!prs_uint16("server_role", ps, depth, &u_7->server_role))
775 return False;
776
777 return True;
778}
779
780/*******************************************************************
781inits a structure.
782********************************************************************/
783
784void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num)
785{
786 unix_to_nt_time(&u_8->domain_create_time, 0);
787 u_8->seq_num = seq_num;
788}
789
790/*******************************************************************
791reads or writes a structure.
792********************************************************************/
793
794static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8,
795 prs_struct *ps, int depth)
796{
797 if (u_8 == NULL)
798 return False;
799
800 prs_debug(ps, depth, desc, "sam_io_unk_info8");
801 depth++;
802
803 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num))
804 return False;
805
806 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth))
807 return False;
808
809 return True;
810}
811
812/*******************************************************************
813inits a structure.
814********************************************************************/
815
816void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown)
817{
818 u_9->unknown = unknown;
819}
820
821/*******************************************************************
822reads or writes a structure.
823********************************************************************/
824
825static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9,
826 prs_struct *ps, int depth)
827{
828 if (u_9 == NULL)
829 return False;
830
831 prs_debug(ps, depth, desc, "sam_io_unk_info9");
832 depth++;
833
834 if (!prs_uint32("unknown", ps, depth, &u_9->unknown))
835 return False;
836
837 return True;
838}
839
840/*******************************************************************
841inits a structure.
842********************************************************************/
843
844void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout)
845{
846 u_12->duration = nt_lock_duration;
847 u_12->reset_count = nt_reset_time;
848
849 u_12->bad_attempt_lockout = lockout;
850}
851
852/*******************************************************************
853reads or writes a structure.
854********************************************************************/
855
856static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
857 prs_struct *ps, int depth)
858{
859 if (u_12 == NULL)
860 return False;
861
862 prs_debug(ps, depth, desc, "sam_io_unk_info12");
863 depth++;
864
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;
871
872 return True;
873}
874
875/*******************************************************************
876inits a structure.
877********************************************************************/
878
879void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num)
880{
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;
885}
886
887/*******************************************************************
888reads or writes a structure.
889********************************************************************/
890
891static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13,
892 prs_struct *ps, int depth)
893{
894 if (u_13 == NULL)
895 return False;
896
897 prs_debug(ps, depth, desc, "sam_io_unk_info13");
898 depth++;
899
900 if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num))
901 return False;
902
903 if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth))
904 return False;
905
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;
910
911 return True;
912}
913
914/*******************************************************************
915inits a SAMR_R_QUERY_DOMAIN_INFO structure.
916********************************************************************/
917
918void init_samr_r_query_domain_info(SAMR_R_QUERY_DOMAIN_INFO * r_u,
919 uint16 switch_value, SAM_UNK_CTR * ctr,
920 NTSTATUS status)
921{
922 DEBUG(5, ("init_samr_r_query_domain_info\n"));
923
924 r_u->ptr_0 = 0;
925 r_u->switch_value = 0;
926 r_u->status = status; /* return status */
927
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;
932 }
933}
934
935/*******************************************************************
936reads or writes a structure.
937********************************************************************/
938
939BOOL samr_io_r_query_domain_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u,
940 prs_struct *ps, int depth)
941{
942 if (r_u == NULL)
943 return False;
944
945 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info");
946 depth++;
947
948 if(!prs_align(ps))
949 return False;
950
951 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
952 return False;
953
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;
959
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;
1010 }
1011 }
1012
1013 if(!prs_align(ps))
1014 return False;
1015
1016 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1017 return False;
1018
1019 return True;
1020}
1021
1022/*******************************************************************
1023reads or writes a structure.
1024********************************************************************/
1025
1026void init_samr_q_set_sec_obj(SAMR_Q_SET_SEC_OBJ * q_u,
1027 POLICY_HND *pol, uint32 sec_info, SEC_DESC_BUF *buf)
1028{
1029 DEBUG(5, ("samr_init_samr_q_set_sec_obj\n"));
1030
1031 q_u->pol = *pol;
1032 q_u->sec_info = sec_info;
1033 q_u->buf = buf;
1034}
1035
1036
1037/*******************************************************************
1038reads or writes a SAMR_R_SET_SEC_OBJ structure.
1039********************************************************************/
1040
1041BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u,
1042 prs_struct *ps, int depth)
1043{
1044 if (r_u == NULL)
1045 return False;
1046
1047 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj");
1048 depth++;
1049
1050 if(!prs_align(ps))
1051 return False;
1052
1053 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1054 return False;
1055
1056 return True;
1057}
1058
1059/*******************************************************************
1060reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
1061********************************************************************/
1062
1063BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u,
1064 prs_struct *ps, int depth)
1065{
1066 if (r_u == NULL)
1067 return False;
1068
1069 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj");
1070 depth++;
1071
1072 if(!prs_align(ps))
1073 return False;
1074
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;
1080 }
1081
1082 if(!prs_ntstatus("status", ps, depth, &r_u->status))
1083 return False;
1084
1085 return True;
1086}
1087
1088/*******************************************************************
1089reads or writes a SAM_STR1 structure.
1090********************************************************************/
1091
1092static 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)
1095{
1096 if (sam == NULL)
1097 return False;
1098
1099 prs_debug(ps, depth, desc, "sam_io_sam_str1");
1100 depth++;
1101
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;
1106
1107 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth))
1108 return False;
1109
1110 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth))
1111 return False;
1112
1113 return True;
1114}
1115
1116/*******************************************************************
1117inits a SAM_ENTRY1 structure.
1118********************************************************************/
1119
1120static 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)
1124{
1125 DEBUG(5, ("init_sam_entry1\n"));
1126
1127 ZERO_STRUCTP(sam);
1128
1129 sam->user_idx = user_idx;
1130 sam->rid_user = rid_user;
1131 sam->acb_info = acb_info;
1132
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);
1136}
1137
1138/*******************************************************************
1139reads or writes a SAM_ENTRY1 structure.
1140********************************************************************/
1141
1142static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam,
1143 prs_struct *ps, int depth)
1144{
1145 if (sam == NULL)
1146 return False;
1147
1148 prs_debug(ps, depth, desc, "sam_io_sam_entry1");
1149 depth++;
1150
1151 if(!prs_align(ps))
1152 return False;
1153
1154 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1155 return False;
1156
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;
1161
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;
1168
1169 return True;
1170}
1171
1172/*******************************************************************
1173reads or writes a SAM_STR2 structure.
1174********************************************************************/
1175
1176static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
1177 uint32 desc_buf, prs_struct *ps, int depth)
1178{
1179 if (sam == NULL)
1180 return False;
1181
1182 prs_debug(ps, depth, desc, "sam_io_sam_str2");
1183 depth++;
1184
1185 if(!prs_align(ps))
1186 return False;
1187
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;
1192
1193 return True;
1194}
1195
1196/*******************************************************************
1197inits a SAM_ENTRY2 structure.
1198********************************************************************/
1199static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
1200 UNISTR2 *sam_name, UNISTR2 *sam_desc,
1201 uint32 rid_user, uint32 acb_info)
1202{
1203 DEBUG(5, ("init_sam_entry2\n"));
1204
1205 sam->user_idx = user_idx;
1206 sam->rid_user = rid_user;
1207 sam->acb_info = acb_info;
1208
1209 init_uni_hdr(&sam->hdr_srv_name, sam_name);
1210 init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
1211}
1212
1213/*******************************************************************
1214reads or writes a SAM_ENTRY2 structure.
1215********************************************************************/
1216
1217static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam,
1218 prs_struct *ps, int depth)
1219{
1220 if (sam == NULL)
1221 return False;
1222
1223 prs_debug(ps, depth, desc, "sam_io_sam_entry2");
1224 depth++;
1225
1226 if(!prs_align(ps))
1227 return False;
1228
1229 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx))
1230 return False;
1231
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;
1236
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;
1241
1242 return True;
1243}
1244
1245/*******************************************************************
1246reads or writes a SAM_STR3 structure.
1247********************************************************************/
1248
1249static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf,
1250 uint32 desc_buf, prs_struct *ps, int depth)
1251{
1252 if (sam == NULL)
1253 return False;
1254
1255 prs_debug(ps, depth, desc, "sam_io_sam_str3");
1256 depth++;
1257
1258 if(!prs_align(ps))
1259 return False;
1260
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;
1265
1266 return True;
1267}
1268
1269/*******************************************************************
1270inits a SAM_ENTRY3 structure.
1271********************************************************************/
1272
1273static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
1274 UNISTR2 *grp_name, UNISTR2 *grp_desc,
1275 uint32 rid_grp)
1276{
1277 DEBUG(5, ("init_sam_entry3\n"));
1278
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 */
1282
1283 init_uni_hdr(&sam->hdr_grp_name, grp_name);
1284 init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
1285}
1286
1287/*******************************************************************
1288reads or writes a SAM_ENTRY3 structure.
1289********************************************************************/
1290
1291static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam,
1292 prs_struct *ps, int depth)
1293{
1294 if (sam == NULL)
1295 return False;
1296
1297 prs_debug(ps, depth, desc, "sam_io_sam_entry3");
1298 depth++;
1299
1300 if(!prs_align(ps))
1301 return False;
1302
1303 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx))
1304 return False;
1305
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;
1310
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;
1315
1316 return True;
1317}
1318
1319/*******************************************************************
1320inits a SAM_ENTRY4 structure.
1321********************************************************************/
1322
1323static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx,
1324 uint32 len_acct_name)
1325{
1326 DEBUG(5, ("init_sam_entry4\n"));
1327
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);
1330}
1331
1332/*******************************************************************
1333reads or writes a SAM_ENTRY4 structure.
1334********************************************************************/
1335
1336static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam,
1337 prs_struct *ps, int depth)
1338{
1339 if (sam == NULL)
1340 return False;
1341
1342 prs_debug(ps, depth, desc, "sam_io_sam_entry4");
1343 depth++;
1344
1345 if(!prs_align(ps))
1346 return False;
1347
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;
1352
1353 return True;
1354}
1355
1356/*******************************************************************
1357inits a SAM_ENTRY5 structure.
1358********************************************************************/
1359
1360static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx,
1361 uint32 len_grp_name)
1362{
1363 DEBUG(5, ("init_sam_entry5\n"));
1364
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);
1368}
1369
1370/*******************************************************************
1371reads or writes a SAM_ENTRY5 structure.
1372********************************************************************/
1373
1374static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
1375 prs_struct *ps, int depth)
1376{
1377 if (sam == NULL)
1378 return False;
1379
1380 prs_debug(ps, depth, desc, "sam_io_sam_entry5");
1381 depth++;
1382
1383 if(!prs_align(ps))
1384 return False;
1385
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;
1390
1391 return True;
1392}
1393
1394/*******************************************************************
1395inits a SAM_ENTRY structure.
1396********************************************************************/
1397
1398void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
1399{
1400 DEBUG(10, ("init_sam_entry: %d\n", rid));
1401
1402 sam->rid = rid;
1403 init_uni_hdr(&sam->hdr_name, uni2);
1404}
1405
1406/*******************************************************************
1407reads or writes a SAM_ENTRY structure.
1408********************************************************************/
1409
1410static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam,
1411 prs_struct *ps, int depth)
1412{
1413 if (sam == NULL)
1414 return False;
1415
1416 prs_debug(ps, depth, desc, "sam_io_sam_entry");
1417 depth++;
1418
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;
1425
1426 return True;
1427}
1428
1429/*******************************************************************
1430inits a SAMR_Q_ENUM_DOM_USERS structure.
1431********************************************************************/
1432
1433void 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)
1436{
1437 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1438
1439 q_e->pol = *pol;
1440
1441 q_e->start_idx = start_idx; /* zero indicates lots */
1442 q_e->acb_mask = acb_mask;
1443 q_e->max_size = size;
1444}
1445
1446/*******************************************************************
1447reads or writes a structure.
1448********************************************************************/
1449
1450BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e,
1451 prs_struct *ps, int depth)
1452{
1453 if (q_e == NULL)
1454 return False;
1455
1456 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users");
1457 depth++;
1458
1459 if(!prs_align(ps))
1460 return False;
1461
1462 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth))
1463 return False;
1464
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;
1469
1470 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
1471 return False;
1472
1473 return True;
1474}
1475
1476
1477/*******************************************************************
1478inits a SAMR_R_ENUM_DOM_USERS structure.
1479********************************************************************/
1480
1481void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u,
1482 uint32 next_idx, uint32 num_sam_entries)
1483{
1484 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1485
1486 r_u->next_idx = next_idx;
1487
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;
1493
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;
1499 }
1500}
1501
1502/*******************************************************************
1503reads or writes a structure.
1504********************************************************************/
1505
1506BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u,
1507 prs_struct *ps, int depth)
1508{
1509 uint32 i;
1510
1511 if (r_u == NULL)
1512 return False;
1513
1514 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users");
1515 depth++;
1516
1517 if(!prs_align(ps))
1518 return False;
1519
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;
1524
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;
1532
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);
1536 }
1537
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;
1543 }
1544
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;
1548 }
1549
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;
1553 }
1554
1555 }
1556
1557 if(!prs_align(ps))
1558 return False;
1559
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;
1564
1565 return True;
1566}
1567
1568/*******************************************************************
1569inits a SAMR_Q_QUERY_DISPINFO structure.
1570********************************************************************/
1571
1572void 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)
1575{
1576 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1577
1578 q_e->domain_pol = *pol;
1579
1580 q_e->switch_level = switch_level;
1581
1582 q_e->start_idx = start_idx;
1583 q_e->max_entries = max_entries;
1584 q_e->max_size = max_size;
1585}
1586
1587/*******************************************************************
1588reads or writes a structure.
1589********************************************************************/
1590
1591BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,
1592 prs_struct *ps, int depth)
1593{
1594 if (q_e == NULL)
1595 return False;
1596
1597 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");
1598 depth++;
1599
1600 if(!prs_align(ps))
1601 return False;
1602
1603 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
1604 return False;
1605
1606 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
1607 return False;
1608 if(!prs_align(ps))
1609 return False;
1610
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;
1617
1618 return True;
1619}
1620
1621/*******************************************************************
1622inits a SAM_DISPINFO_1 structure.
1623********************************************************************/
1624
1625NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,
1626 uint32 num_entries, uint32 start_idx,
1627 struct samr_displayentry *entries)
1628{
1629 uint32 i;
1630
1631 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));
1632
1633 if (num_entries==0)
1634 return NT_STATUS_OK;
1635
1636 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);
1637 if (*sam == NULL)
1638 return NT_STATUS_NO_MEMORY;
1639
1640 (*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);
1641 if ((*sam)->sam == NULL)
1642 return NT_STATUS_NO_MEMORY;
1643
1644 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);
1645 if ((*sam)->str == NULL)
1646 return NT_STATUS_NO_MEMORY;
1647
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);
1655
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);
1661 }
1662
1663 return NT_STATUS_OK;
1664}
1665
1666/*******************************************************************
1667reads or writes a structure.
1668********************************************************************/
1669
1670static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,
1671 uint32 num_entries,
1672 prs_struct *ps, int depth)
1673{
1674 uint32 i;
1675
1676 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");
1677 depth++;
1678
1679 if(!prs_align(ps))
1680 return False;
1681
1682 if (UNMARSHALLING(ps) && num_entries > 0) {
1683
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;
1687 }
1688
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;
1692 }
1693 }
1694
1695 for (i = 0; i < num_entries; i++) {
1696 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))
1697 return False;
1698 }
1699
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;
1706 }
1707
1708 return True;
1709}
1710
1711/*******************************************************************
1712inits a SAM_DISPINFO_2 structure.
1713********************************************************************/
1714
1715NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,
1716 uint32 num_entries, uint32 start_idx,
1717 struct samr_displayentry *entries)
1718{
1719 uint32 i;
1720
1721 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));
1722
1723 if (num_entries==0)
1724 return NT_STATUS_OK;
1725
1726 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);
1727 if (*sam == NULL)
1728 return NT_STATUS_NO_MEMORY;
1729
1730 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);
1731 if ((*sam)->sam == NULL)
1732 return NT_STATUS_NO_MEMORY;
1733
1734 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);
1735 if ((*sam)->str == NULL)
1736 return NT_STATUS_NO_MEMORY;
1737
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);
1743
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);
1748 }
1749
1750 return NT_STATUS_OK;
1751}
1752
1753/*******************************************************************
1754reads or writes a structure.
1755********************************************************************/
1756
1757static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,
1758 uint32 num_entries,
1759 prs_struct *ps, int depth)
1760{
1761 uint32 i;
1762
1763 if (sam == NULL)
1764 return False;
1765
1766 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");
1767 depth++;
1768
1769 if(!prs_align(ps))
1770 return False;
1771
1772 if (UNMARSHALLING(ps) && num_entries > 0) {
1773
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;
1777 }
1778
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;
1782 }
1783 }
1784
1785 for (i = 0; i < num_entries; i++) {
1786 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))
1787 return False;
1788 }
1789
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;
1795 }
1796
1797 return True;
1798}
1799
1800/*******************************************************************
1801inits a SAM_DISPINFO_3 structure.
1802********************************************************************/
1803
1804NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,
1805 uint32 num_entries, uint32 start_idx,
1806 struct samr_displayentry *entries)
1807{
1808 uint32 i;
1809
1810 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));
1811
1812 if (num_entries==0)
1813 return NT_STATUS_OK;
1814
1815 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);
1816 if (*sam == NULL)
1817 return NT_STATUS_NO_MEMORY;
1818
1819 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))
1820 return NT_STATUS_NO_MEMORY;
1821
1822 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))
1823 return NT_STATUS_NO_MEMORY;
1824
1825 for (i = 0; i < num_entries; i++) {
1826 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
1827
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);
1832
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);
1837 }
1838
1839 return NT_STATUS_OK;
1840}
1841
1842/*******************************************************************
1843reads or writes a structure.
1844********************************************************************/
1845
1846static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,
1847 uint32 num_entries,
1848 prs_struct *ps, int depth)
1849{
1850 uint32 i;
1851
1852 if (sam == NULL)
1853 return False;
1854
1855 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");
1856 depth++;
1857
1858 if(!prs_align(ps))
1859 return False;
1860
1861 if (UNMARSHALLING(ps) && num_entries > 0) {
1862
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;
1866 }
1867
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;
1871 }
1872 }
1873
1874 for (i = 0; i < num_entries; i++) {
1875 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))
1876 return False;
1877 }
1878
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;
1884 }
1885
1886 return True;
1887}
1888
1889/*******************************************************************
1890inits a SAM_DISPINFO_4 structure.
1891********************************************************************/
1892
1893NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,
1894 uint32 num_entries, uint32 start_idx,
1895 struct samr_displayentry *entries)
1896{
1897 uint32 i;
1898
1899 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));
1900
1901 if (num_entries==0)
1902 return NT_STATUS_OK;
1903
1904 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);
1905 if (*sam == NULL)
1906 return NT_STATUS_NO_MEMORY;
1907
1908 (*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);
1909 if ((*sam)->sam == NULL)
1910 return NT_STATUS_NO_MEMORY;
1911
1912 (*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);
1913 if ((*sam)->str == NULL)
1914 return NT_STATUS_NO_MEMORY;
1915
1916 for (i = 0; i < num_entries; i++) {
1917 size_t len_sam_name = strlen(entries[i].account_name);
1918
1919 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));
1920
1921 init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,
1922 len_sam_name);
1923
1924 init_string2(&(*sam)->str[i].acct_name,
1925 entries[i].account_name, len_sam_name+1,
1926 len_sam_name);
1927 }
1928
1929 return NT_STATUS_OK;
1930}
1931
1932/*******************************************************************
1933reads or writes a structure.
1934********************************************************************/
1935
1936static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,
1937 uint32 num_entries,
1938 prs_struct *ps, int depth)
1939{
1940 uint32 i;
1941
1942 if (sam == NULL)
1943 return False;
1944
1945 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");
1946 depth++;
1947
1948 if(!prs_align(ps))
1949 return False;
1950
1951 if (UNMARSHALLING(ps) && num_entries > 0) {
1952
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;
1956 }
1957
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;
1961 }
1962 }
1963
1964 for (i = 0; i < num_entries; i++) {
1965 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))
1966 return False;
1967 }
1968
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;
1973 }
1974
1975 return True;
1976}
1977
1978/*******************************************************************
1979inits a SAM_DISPINFO_5 structure.
1980********************************************************************/
1981
1982NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,
1983 uint32 num_entries, uint32 start_idx,
1984 struct samr_displayentry *entries)
1985{
1986 uint32 len_sam_name;
1987 uint32 i;
1988
1989 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));
1990
1991 if (num_entries==0)
1992 return NT_STATUS_OK;
1993
1994 *sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);
1995 if (*sam == NULL)
1996 return NT_STATUS_NO_MEMORY;
1997
1998 if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))
1999 return NT_STATUS_NO_MEMORY;
2000
2001 if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))
2002 return NT_STATUS_NO_MEMORY;
2003
2004 for (i = 0; i < num_entries; i++) {
2005 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));
2006
2007 len_sam_name = strlen(entries[i].account_name);
2008
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);
2012 }
2013
2014 return NT_STATUS_OK;
2015}
2016
2017/*******************************************************************
2018reads or writes a structure.
2019********************************************************************/
2020
2021static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,
2022 uint32 num_entries,
2023 prs_struct *ps, int depth)
2024{
2025 uint32 i;
2026
2027 if (sam == NULL)
2028 return False;
2029
2030 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");
2031 depth++;
2032
2033 if(!prs_align(ps))
2034 return False;
2035
2036 if (UNMARSHALLING(ps) && num_entries > 0) {
2037
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;
2041 }
2042
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;
2046 }
2047 }
2048
2049 for (i = 0; i < num_entries; i++) {
2050 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))
2051 return False;
2052 }
2053
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;
2058 }
2059
2060 return True;
2061}
2062
2063/*******************************************************************
2064inits a SAMR_R_QUERY_DISPINFO structure.
2065********************************************************************/
2066
2067void 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)
2071{
2072 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level));
2073
2074 r_u->total_size = total_size;
2075
2076 r_u->data_size = data_size;
2077
2078 r_u->switch_level = switch_level;
2079 r_u->num_entries = num_entries;
2080
2081 if (num_entries==0)
2082 r_u->ptr_entries = 0;
2083 else
2084 r_u->ptr_entries = 1;
2085
2086 r_u->num_entries2 = num_entries;
2087 r_u->ctr = ctr;
2088
2089 r_u->status = status;
2090}
2091
2092/*******************************************************************
2093reads or writes a structure.
2094********************************************************************/
2095
2096BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
2097 prs_struct *ps, int depth)
2098{
2099 if (r_u == NULL)
2100 return False;
2101
2102 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo");
2103 depth++;
2104
2105 if(!prs_align(ps))
2106 return False;
2107
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;
2116
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;
2121
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;
2127
2128 return True;
2129 }
2130
2131 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
2132 return False;
2133
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;
2165 }
2166
2167 if(!prs_align(ps))
2168 return False;
2169 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2170 return False;
2171
2172 return True;
2173}
2174
2175/*******************************************************************
2176inits a SAMR_Q_GET_DISPENUM_INDEX structure.
2177********************************************************************/
2178
2179void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
2180 uint16 switch_level, const char *name)
2181{
2182 DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
2183
2184 q_e->domain_pol = *pol;
2185
2186 q_e->switch_level = switch_level;
2187
2188 init_lsa_string(&q_e->name, name);
2189}
2190
2191/*******************************************************************
2192reads or writes a structure.
2193********************************************************************/
2194
2195BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
2196 prs_struct *ps, int depth)
2197{
2198 if (q_e == NULL)
2199 return False;
2200
2201 prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
2202 depth++;
2203
2204 if(!prs_align(ps))
2205 return False;
2206
2207 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
2208 return False;
2209
2210 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2211 return False;
2212
2213 if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
2214 return False;
2215
2216 return True;
2217}
2218
2219/*******************************************************************
2220reads or writes a structure.
2221********************************************************************/
2222
2223BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
2224 prs_struct *ps, int depth)
2225{
2226 if (r_u == NULL)
2227 return False;
2228
2229 prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
2230 depth++;
2231
2232 if(!prs_align(ps))
2233 return False;
2234
2235 if(!prs_uint32("idx", ps, depth, &r_u->idx))
2236 return False;
2237
2238 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2239 return False;
2240
2241 return True;
2242}
2243
2244
2245/*******************************************************************
2246inits a SAMR_Q_OPEN_GROUP structure.
2247********************************************************************/
2248
2249void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c,
2250 POLICY_HND *hnd,
2251 uint32 access_mask, uint32 rid)
2252{
2253 DEBUG(5, ("init_samr_q_open_group\n"));
2254
2255 q_c->domain_pol = *hnd;
2256 q_c->access_mask = access_mask;
2257 q_c->rid_group = rid;
2258}
2259
2260/*******************************************************************
2261inits a SAMR_R_GET_DISPENUM_INDEX structure.
2262********************************************************************/
2263
2264void init_samr_r_get_dispenum_index(SAMR_R_GET_DISPENUM_INDEX * q_e, uint32 idx)
2265{
2266 DEBUG(5, ("init_samr_r_get_dispenum_index\n"));
2267
2268 q_e->idx = idx;
2269}
2270
2271/*******************************************************************
2272reads or writes a structure.
2273********************************************************************/
2274
2275BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u,
2276 prs_struct *ps, int depth)
2277{
2278 if (q_u == NULL)
2279 return False;
2280
2281 prs_debug(ps, depth, desc, "samr_io_q_open_group");
2282 depth++;
2283
2284 if(!prs_align(ps))
2285 return False;
2286
2287 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
2288 return False;
2289
2290 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
2291 return False;
2292 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group))
2293 return False;
2294
2295 return True;
2296}
2297
2298/*******************************************************************
2299reads or writes a structure.
2300********************************************************************/
2301
2302BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u,
2303 prs_struct *ps, int depth)
2304{
2305 if (r_u == NULL)
2306 return False;
2307
2308 prs_debug(ps, depth, desc, "samr_io_r_open_group");
2309 depth++;
2310
2311 if(!prs_align(ps))
2312 return False;
2313
2314 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2315 return False;
2316
2317 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2318 return False;
2319
2320 return True;
2321}
2322
2323/*******************************************************************
2324inits a GROUP_INFO1 structure.
2325********************************************************************/
2326
2327void init_samr_group_info1(GROUP_INFO1 * gr1,
2328 char *acct_name, char *acct_desc,
2329 uint32 num_members)
2330{
2331 DEBUG(5, ("init_samr_group_info1\n"));
2332
2333 gr1->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2334 gr1->num_members = num_members;
2335
2336 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2337 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
2338 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2339 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
2340}
2341
2342/*******************************************************************
2343reads or writes a structure.
2344********************************************************************/
2345
2346BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1,
2347 prs_struct *ps, int depth)
2348{
2349 uint16 dummy = 1;
2350
2351 if (gr1 == NULL)
2352 return False;
2353
2354 prs_debug(ps, depth, desc, "samr_io_group_info1");
2355 depth++;
2356
2357 if(!prs_uint16("level", ps, depth, &dummy))
2358 return False;
2359
2360 if(!prs_align(ps))
2361 return False;
2362
2363 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth))
2364 return False;
2365
2366 if(!prs_uint32("group_attr", ps, depth, &gr1->group_attr))
2367 return False;
2368 if(!prs_uint32("num_members", ps, depth, &gr1->num_members))
2369 return False;
2370
2371 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth))
2372 return False;
2373
2374 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name,
2375 gr1->hdr_acct_name.buffer, ps, depth))
2376 return False;
2377
2378 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc,
2379 gr1->hdr_acct_desc.buffer, ps, depth))
2380 return False;
2381
2382 return True;
2383}
2384
2385/*******************************************************************
2386inits a GROUP_INFO2 structure.
2387********************************************************************/
2388
2389void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name)
2390{
2391 DEBUG(5, ("init_samr_group_info2\n"));
2392
2393 gr2->level = 2;
2394 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2395 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name);
2396}
2397
2398/*******************************************************************
2399reads or writes a structure.
2400********************************************************************/
2401
2402BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth)
2403{
2404 if (gr2 == NULL)
2405 return False;
2406
2407 prs_debug(ps, depth, desc, "samr_io_group_info2");
2408 depth++;
2409
2410 if(!prs_uint16("hdr_level", ps, depth, &gr2->level))
2411 return False;
2412
2413 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth))
2414 return False;
2415 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name,
2416 gr2->hdr_acct_name.buffer, ps, depth))
2417 return False;
2418
2419 return True;
2420}
2421
2422/*******************************************************************
2423inits a GROUP_INFO3 structure.
2424********************************************************************/
2425
2426void init_samr_group_info3(GROUP_INFO3 *gr3)
2427{
2428 DEBUG(5, ("init_samr_group_info3\n"));
2429
2430 gr3->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2431}
2432
2433/*******************************************************************
2434reads or writes a structure.
2435********************************************************************/
2436
2437BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth)
2438{
2439 if (gr3 == NULL)
2440 return False;
2441
2442 prs_debug(ps, depth, desc, "samr_io_group_info3");
2443 depth++;
2444
2445 if(!prs_align(ps))
2446 return False;
2447
2448 if(!prs_uint32("group_attr", ps, depth, &gr3->group_attr))
2449 return False;
2450
2451 return True;
2452}
2453
2454/*******************************************************************
2455inits a GROUP_INFO4 structure.
2456********************************************************************/
2457
2458void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc)
2459{
2460 DEBUG(5, ("init_samr_group_info4\n"));
2461
2462 gr4->level = 4;
2463 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2464 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
2465}
2466
2467/*******************************************************************
2468reads or writes a structure.
2469********************************************************************/
2470
2471BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4,
2472 prs_struct *ps, int depth)
2473{
2474 if (gr4 == NULL)
2475 return False;
2476
2477 prs_debug(ps, depth, desc, "samr_io_group_info4");
2478 depth++;
2479
2480 if(!prs_uint16("hdr_level", ps, depth, &gr4->level))
2481 return False;
2482 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth))
2483 return False;
2484 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc,
2485 gr4->hdr_acct_desc.buffer, ps, depth))
2486 return False;
2487
2488 return True;
2489}
2490
2491/*******************************************************************
2492inits a GROUP_INFO5 structure.
2493********************************************************************/
2494
2495void init_samr_group_info5(GROUP_INFO5 * gr5,
2496 char *acct_name, char *acct_desc,
2497 uint32 num_members)
2498{
2499 DEBUG(5, ("init_samr_group_info5\n"));
2500
2501 gr5->group_attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT); /* why not | SE_GROUP_ENABLED ? */
2502 gr5->num_members = num_members;
2503
2504 init_unistr2(&gr5->uni_acct_name, acct_name, UNI_FLAGS_NONE);
2505 init_uni_hdr(&gr5->hdr_acct_name, &gr5->uni_acct_name);
2506 init_unistr2(&gr5->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2507 init_uni_hdr(&gr5->hdr_acct_desc, &gr5->uni_acct_desc);
2508}
2509
2510/*******************************************************************
2511reads or writes a structure.
2512********************************************************************/
2513
2514BOOL samr_io_group_info5(const char *desc, GROUP_INFO5 * gr5,
2515 prs_struct *ps, int depth)
2516{
2517 uint16 dummy = 1;
2518
2519 if (gr5 == NULL)
2520 return False;
2521
2522 prs_debug(ps, depth, desc, "samr_io_group_info5");
2523 depth++;
2524
2525 if(!prs_uint16("level", ps, depth, &dummy))
2526 return False;
2527
2528 if(!prs_align(ps))
2529 return False;
2530
2531 if(!smb_io_unihdr("hdr_acct_name", &gr5->hdr_acct_name, ps, depth))
2532 return False;
2533
2534 if(!prs_uint32("group_attr", ps, depth, &gr5->group_attr))
2535 return False;
2536 if(!prs_uint32("num_members", ps, depth, &gr5->num_members))
2537 return False;
2538
2539 if(!smb_io_unihdr("hdr_acct_desc", &gr5->hdr_acct_desc, ps, depth))
2540 return False;
2541
2542 if(!smb_io_unistr2("uni_acct_name", &gr5->uni_acct_name,
2543 gr5->hdr_acct_name.buffer, ps, depth))
2544 return False;
2545
2546 if(!smb_io_unistr2("uni_acct_desc", &gr5->uni_acct_desc,
2547 gr5->hdr_acct_desc.buffer, ps, depth))
2548 return False;
2549
2550 return True;
2551}
2552
2553
2554/*******************************************************************
2555reads or writes a structure.
2556********************************************************************/
2557
2558static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr,
2559 prs_struct *ps, int depth)
2560{
2561 if (UNMARSHALLING(ps))
2562 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1);
2563
2564 if (*ctr == NULL)
2565 return False;
2566
2567 prs_debug(ps, depth, desc, "samr_group_info_ctr");
2568 depth++;
2569
2570 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
2571 return False;
2572
2573 switch ((*ctr)->switch_value1) {
2574 case 1:
2575 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth))
2576 return False;
2577 break;
2578 case 2:
2579 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth))
2580 return False;
2581 break;
2582 case 3:
2583 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth))
2584 return False;
2585 break;
2586 case 4:
2587 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth))
2588 return False;
2589 break;
2590 case 5:
2591 if(!samr_io_group_info5("group_info5", &(*ctr)->group.info5, ps, depth))
2592 return False;
2593 break;
2594 default:
2595 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2596 break;
2597 }
2598
2599 return True;
2600}
2601
2602/*******************************************************************
2603inits a SAMR_Q_CREATE_DOM_GROUP structure.
2604********************************************************************/
2605
2606void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
2607 POLICY_HND *pol, const char *acct_desc,
2608 uint32 access_mask)
2609{
2610 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2611
2612 q_e->pol = *pol;
2613
2614 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
2615 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
2616
2617 q_e->access_mask = access_mask;
2618}
2619
2620/*******************************************************************
2621reads or writes a structure.
2622********************************************************************/
2623
2624BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e,
2625 prs_struct *ps, int depth)
2626{
2627 if (q_e == NULL)
2628 return False;
2629
2630 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group");
2631 depth++;
2632
2633 if(!prs_align(ps))
2634 return False;
2635
2636 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2637 return False;
2638
2639 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth))
2640 return False;
2641 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc,
2642 q_e->hdr_acct_desc.buffer, ps, depth))
2643 return False;
2644
2645 if(!prs_align(ps))
2646 return False;
2647 if(!prs_uint32("access", ps, depth, &q_e->access_mask))
2648 return False;
2649
2650 return True;
2651}
2652
2653/*******************************************************************
2654reads or writes a structure.
2655********************************************************************/
2656
2657BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u,
2658 prs_struct *ps, int depth)
2659{
2660 if (r_u == NULL)
2661 return False;
2662
2663 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group");
2664 depth++;
2665
2666 if(!prs_align(ps))
2667 return False;
2668
2669 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2670 return False;
2671
2672 if(!prs_uint32("rid ", ps, depth, &r_u->rid))
2673 return False;
2674 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2675 return False;
2676
2677 return True;
2678}
2679
2680/*******************************************************************
2681inits a SAMR_Q_DELETE_DOM_GROUP structure.
2682********************************************************************/
2683
2684void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c,
2685 POLICY_HND *hnd)
2686{
2687 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2688
2689 q_c->group_pol = *hnd;
2690}
2691
2692/*******************************************************************
2693reads or writes a structure.
2694********************************************************************/
2695
2696BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u,
2697 prs_struct *ps, int depth)
2698{
2699 if (q_u == NULL)
2700 return False;
2701
2702 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group");
2703 depth++;
2704
2705 if(!prs_align(ps))
2706 return False;
2707
2708 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
2709 return False;
2710
2711 return True;
2712}
2713
2714/*******************************************************************
2715reads or writes a structure.
2716********************************************************************/
2717
2718BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u,
2719 prs_struct *ps, int depth)
2720{
2721 if (r_u == NULL)
2722 return False;
2723
2724 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group");
2725 depth++;
2726
2727 if(!prs_align(ps))
2728 return False;
2729
2730 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
2731 return False;
2732
2733 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2734 return False;
2735
2736 return True;
2737}
2738
2739/*******************************************************************
2740inits a SAMR_Q_DEL_GROUPMEM structure.
2741********************************************************************/
2742
2743void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e,
2744 POLICY_HND *pol, uint32 rid)
2745{
2746 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2747
2748 q_e->pol = *pol;
2749 q_e->rid = rid;
2750}
2751
2752/*******************************************************************
2753reads or writes a structure.
2754********************************************************************/
2755
2756BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e,
2757 prs_struct *ps, int depth)
2758{
2759 if (q_e == NULL)
2760 return False;
2761
2762 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem");
2763 depth++;
2764
2765 if(!prs_align(ps))
2766 return False;
2767
2768 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2769 return False;
2770
2771 if(!prs_uint32("rid", ps, depth, &q_e->rid))
2772 return False;
2773
2774 return True;
2775}
2776
2777/*******************************************************************
2778inits a SAMR_R_DEL_GROUPMEM structure.
2779********************************************************************/
2780
2781void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol,
2782 NTSTATUS status)
2783{
2784 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2785
2786 r_u->status = status;
2787}
2788
2789/*******************************************************************
2790reads or writes a structure.
2791********************************************************************/
2792
2793BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u,
2794 prs_struct *ps, int depth)
2795{
2796 if (r_u == NULL)
2797 return False;
2798
2799 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem");
2800 depth++;
2801
2802 if(!prs_align(ps))
2803 return False;
2804
2805 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2806 return False;
2807
2808 return True;
2809}
2810
2811/*******************************************************************
2812inits a SAMR_Q_ADD_GROUPMEM structure.
2813********************************************************************/
2814
2815void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e,
2816 POLICY_HND *pol, uint32 rid)
2817{
2818 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2819
2820 q_e->pol = *pol;
2821 q_e->rid = rid;
2822 q_e->unknown = 0x0005;
2823}
2824
2825/*******************************************************************
2826reads or writes a structure.
2827********************************************************************/
2828
2829BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e,
2830 prs_struct *ps, int depth)
2831{
2832 if (q_e == NULL)
2833 return False;
2834
2835 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem");
2836 depth++;
2837
2838 if(!prs_align(ps))
2839 return False;
2840
2841 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2842 return False;
2843
2844 if(!prs_uint32("rid ", ps, depth, &q_e->rid))
2845 return False;
2846 if(!prs_uint32("unknown", ps, depth, &q_e->unknown))
2847 return False;
2848
2849 return True;
2850}
2851
2852/*******************************************************************
2853inits a SAMR_R_ADD_GROUPMEM structure.
2854********************************************************************/
2855
2856void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol,
2857 NTSTATUS status)
2858{
2859 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2860
2861 r_u->status = status;
2862}
2863
2864/*******************************************************************
2865reads or writes a structure.
2866********************************************************************/
2867
2868BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u,
2869 prs_struct *ps, int depth)
2870{
2871 if (r_u == NULL)
2872 return False;
2873
2874 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem");
2875 depth++;
2876
2877 if(!prs_align(ps))
2878 return False;
2879
2880 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2881 return False;
2882
2883 return True;
2884}
2885
2886/*******************************************************************
2887inits a SAMR_Q_SET_GROUPINFO structure.
2888********************************************************************/
2889
2890void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e,
2891 POLICY_HND *pol, GROUP_INFO_CTR * ctr)
2892{
2893 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2894
2895 q_e->pol = *pol;
2896 q_e->ctr = ctr;
2897}
2898
2899/*******************************************************************
2900reads or writes a structure.
2901********************************************************************/
2902
2903BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e,
2904 prs_struct *ps, int depth)
2905{
2906 if (q_e == NULL)
2907 return False;
2908
2909 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo");
2910 depth++;
2911
2912 if(!prs_align(ps))
2913 return False;
2914
2915 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2916 return False;
2917
2918 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
2919 return False;
2920
2921 return True;
2922}
2923
2924/*******************************************************************
2925inits a SAMR_R_SET_GROUPINFO structure.
2926********************************************************************/
2927
2928void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status)
2929{
2930 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2931
2932 r_u->status = status;
2933}
2934
2935/*******************************************************************
2936reads or writes a structure.
2937********************************************************************/
2938
2939BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u,
2940 prs_struct *ps, int depth)
2941{
2942 if (r_u == NULL)
2943 return False;
2944
2945 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo");
2946 depth++;
2947
2948 if(!prs_align(ps))
2949 return False;
2950
2951 if(!prs_ntstatus("status", ps, depth, &r_u->status))
2952 return False;
2953
2954 return True;
2955}
2956
2957/*******************************************************************
2958inits a SAMR_Q_QUERY_GROUPINFO structure.
2959********************************************************************/
2960
2961void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e,
2962 POLICY_HND *pol, uint16 switch_level)
2963{
2964 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2965
2966 q_e->pol = *pol;
2967
2968 q_e->switch_level = switch_level;
2969}
2970
2971/*******************************************************************
2972reads or writes a structure.
2973********************************************************************/
2974
2975BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e,
2976 prs_struct *ps, int depth)
2977{
2978 if (q_e == NULL)
2979 return False;
2980
2981 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo");
2982 depth++;
2983
2984 if(!prs_align(ps))
2985 return False;
2986
2987 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
2988 return False;
2989
2990 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
2991 return False;
2992
2993 return True;
2994}
2995
2996/*******************************************************************
2997inits a SAMR_R_QUERY_GROUPINFO structure.
2998********************************************************************/
2999
3000void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u,
3001 GROUP_INFO_CTR * ctr, NTSTATUS status)
3002{
3003 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
3004
3005 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0;
3006 r_u->ctr = ctr;
3007 r_u->status = status;
3008}
3009
3010/*******************************************************************
3011reads or writes a structure.
3012********************************************************************/
3013
3014BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
3015 prs_struct *ps, int depth)
3016{
3017 if (r_u == NULL)
3018 return False;
3019
3020 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo");
3021 depth++;
3022
3023 if(!prs_align(ps))
3024 return False;
3025
3026 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3027 return False;
3028
3029 if (r_u->ptr != 0) {
3030 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
3031 return False;
3032 }
3033
3034 if(!prs_align(ps))
3035 return False;
3036 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3037 return False;
3038
3039 return True;
3040}
3041
3042/*******************************************************************
3043inits a SAMR_Q_QUERY_GROUPMEM structure.
3044********************************************************************/
3045
3046void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd)
3047{
3048 DEBUG(5, ("init_samr_q_query_groupmem\n"));
3049
3050 q_c->group_pol = *hnd;
3051}
3052
3053/*******************************************************************
3054reads or writes a structure.
3055********************************************************************/
3056
3057BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u,
3058 prs_struct *ps, int depth)
3059{
3060 if (q_u == NULL)
3061 return False;
3062
3063 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem");
3064 depth++;
3065
3066 if(!prs_align(ps))
3067 return False;
3068
3069 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth))
3070 return False;
3071
3072 return True;
3073}
3074
3075/*******************************************************************
3076inits a SAMR_R_QUERY_GROUPMEM structure.
3077********************************************************************/
3078
3079void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u,
3080 uint32 num_entries, uint32 *rid,
3081 uint32 *attr, NTSTATUS status)
3082{
3083 DEBUG(5, ("init_samr_r_query_groupmem\n"));
3084
3085 if (NT_STATUS_IS_OK(status)) {
3086 r_u->ptr = 1;
3087 r_u->num_entries = num_entries;
3088
3089 r_u->ptr_attrs = attr != NULL ? 1 : 0;
3090 r_u->ptr_rids = rid != NULL ? 1 : 0;
3091
3092 r_u->num_rids = num_entries;
3093 r_u->rid = rid;
3094
3095 r_u->num_attrs = num_entries;
3096 r_u->attr = attr;
3097 } else {
3098 r_u->ptr = 0;
3099 r_u->num_entries = 0;
3100 }
3101
3102 r_u->status = status;
3103}
3104
3105/*******************************************************************
3106reads or writes a structure.
3107********************************************************************/
3108
3109BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u,
3110 prs_struct *ps, int depth)
3111{
3112 uint32 i;
3113
3114 if (r_u == NULL)
3115 return False;
3116
3117 if (UNMARSHALLING(ps))
3118 ZERO_STRUCTP(r_u);
3119
3120 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem");
3121 depth++;
3122
3123 if(!prs_align(ps))
3124 return False;
3125
3126 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
3127 return False;
3128 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3129 return False;
3130
3131 if (r_u->ptr != 0) {
3132 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
3133 return False;
3134 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs))
3135 return False;
3136
3137 if (r_u->ptr_rids != 0) {
3138 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids))
3139 return False;
3140 if (UNMARSHALLING(ps) && r_u->num_rids != 0) {
3141 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids);
3142 if (r_u->rid == NULL)
3143 return False;
3144 }
3145
3146 for (i = 0; i < r_u->num_rids; i++) {
3147 if(!prs_uint32("", ps, depth, &r_u->rid[i]))
3148 return False;
3149 }
3150 }
3151
3152 if (r_u->ptr_attrs != 0) {
3153 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs))
3154 return False;
3155
3156 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) {
3157 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs);
3158 if (r_u->attr == NULL)
3159 return False;
3160 }
3161
3162 for (i = 0; i < r_u->num_attrs; i++) {
3163 if(!prs_uint32("", ps, depth, &r_u->attr[i]))
3164 return False;
3165 }
3166 }
3167 }
3168
3169 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3170 return False;
3171
3172 return True;
3173}
3174
3175/*******************************************************************
3176inits a SAMR_Q_QUERY_USERGROUPS structure.
3177********************************************************************/
3178
3179void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u,
3180 POLICY_HND *hnd)
3181{
3182 DEBUG(5, ("init_samr_q_query_usergroups\n"));
3183
3184 q_u->pol = *hnd;
3185}
3186
3187/*******************************************************************
3188reads or writes a structure.
3189********************************************************************/
3190
3191BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u,
3192 prs_struct *ps, int depth)
3193{
3194 if (q_u == NULL)
3195 return False;
3196
3197 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups");
3198 depth++;
3199
3200 if(!prs_align(ps))
3201 return False;
3202
3203 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
3204 return False;
3205
3206 return True;
3207}
3208
3209/*******************************************************************
3210inits a SAMR_R_QUERY_USERGROUPS structure.
3211********************************************************************/
3212
3213void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u,
3214 uint32 num_gids, DOM_GID * gid,
3215 NTSTATUS status)
3216{
3217 DEBUG(5, ("init_samr_r_query_usergroups\n"));
3218
3219 if (NT_STATUS_IS_OK(status)) {
3220 r_u->ptr_0 = 1;
3221 r_u->num_entries = num_gids;
3222 r_u->ptr_1 = (num_gids != 0) ? 1 : 0;
3223 r_u->num_entries2 = num_gids;
3224
3225 r_u->gid = gid;
3226 } else {
3227 r_u->ptr_0 = 0;
3228 r_u->num_entries = 0;
3229 r_u->ptr_1 = 0;
3230 r_u->gid = NULL;
3231 }
3232
3233 r_u->status = status;
3234}
3235
3236/*******************************************************************
3237reads or writes a structure.
3238********************************************************************/
3239
3240BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid,
3241 prs_struct *ps, int depth)
3242{
3243 uint32 i;
3244 if (gid == NULL)
3245 return False;
3246
3247 prs_debug(ps, depth, desc, "samr_io_gids");
3248 depth++;
3249
3250 if(!prs_align(ps))
3251 return False;
3252
3253 if(!prs_uint32("num_gids", ps, depth, num_gids))
3254 return False;
3255
3256 if ((*num_gids) != 0) {
3257 if (UNMARSHALLING(ps)) {
3258 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids);
3259 }
3260
3261 if ((*gid) == NULL) {
3262 return False;
3263 }
3264
3265 for (i = 0; i < (*num_gids); i++) {
3266 if(!smb_io_gid("gids", &(*gid)[i], ps, depth))
3267 return False;
3268 }
3269 }
3270
3271 return True;
3272}
3273
3274/*******************************************************************
3275reads or writes a structure.
3276********************************************************************/
3277
3278BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u,
3279 prs_struct *ps, int depth)
3280{
3281 if (r_u == NULL)
3282 return False;
3283
3284 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups");
3285 depth++;
3286
3287 if(!prs_align(ps))
3288 return False;
3289
3290 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
3291 return False;
3292
3293 if (r_u->ptr_0 != 0) {
3294 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries))
3295 return False;
3296 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1))
3297 return False;
3298
3299 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) {
3300 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth))
3301 return False;
3302 }
3303 }
3304
3305 if(!prs_align(ps))
3306 return False;
3307 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3308 return False;
3309
3310 return True;
3311}
3312
3313/*******************************************************************
3314inits a SAMR_Q_ENUM_DOMAINS structure.
3315********************************************************************/
3316
3317void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e,
3318 POLICY_HND *pol,
3319 uint32 start_idx, uint32 size)
3320{
3321 DEBUG(5, ("init_samr_q_enum_domains\n"));
3322
3323 q_e->pol = *pol;
3324
3325 q_e->start_idx = start_idx;
3326 q_e->max_size = size;
3327}
3328
3329/*******************************************************************
3330reads or writes a structure.
3331********************************************************************/
3332
3333BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e,
3334 prs_struct *ps, int depth)
3335{
3336 if (q_e == NULL)
3337 return False;
3338
3339 prs_debug(ps, depth, desc, "samr_io_q_enum_domains");
3340 depth++;
3341
3342 if(!prs_align(ps))
3343 return False;
3344
3345 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3346 return False;
3347
3348 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3349 return False;
3350 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3351 return False;
3352
3353 return True;
3354}
3355
3356/*******************************************************************
3357inits a SAMR_R_ENUM_DOMAINS structure.
3358********************************************************************/
3359
3360void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u,
3361 uint32 next_idx, uint32 num_sam_entries)
3362{
3363 DEBUG(5, ("init_samr_r_enum_domains\n"));
3364
3365 r_u->next_idx = next_idx;
3366
3367 if (num_sam_entries != 0) {
3368 r_u->ptr_entries1 = 1;
3369 r_u->ptr_entries2 = 1;
3370 r_u->num_entries2 = num_sam_entries;
3371 r_u->num_entries3 = num_sam_entries;
3372
3373 r_u->num_entries4 = num_sam_entries;
3374 } else {
3375 r_u->ptr_entries1 = 0;
3376 r_u->num_entries2 = num_sam_entries;
3377 r_u->ptr_entries2 = 1;
3378 }
3379}
3380
3381/*******************************************************************
3382reads or writes a structure.
3383********************************************************************/
3384
3385BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u,
3386 prs_struct *ps, int depth)
3387{
3388 uint32 i;
3389
3390 if (r_u == NULL)
3391 return False;
3392
3393 prs_debug(ps, depth, desc, "samr_io_r_enum_domains");
3394 depth++;
3395
3396 if(!prs_align(ps))
3397 return False;
3398
3399 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3400 return False;
3401 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3402 return False;
3403
3404 if (r_u->ptr_entries1 != 0) {
3405 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3406 return False;
3407 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3408 return False;
3409 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3410 return False;
3411
3412 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3413 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3414 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3415 }
3416
3417 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) {
3418 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3419 r_u->num_entries4 = 0;
3420 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3421 return False;
3422 }
3423
3424 for (i = 0; i < r_u->num_entries2; i++) {
3425 fstring tmp;
3426 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3427 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth))
3428 return False;
3429 }
3430
3431 for (i = 0; i < r_u->num_entries2; i++) {
3432 fstring tmp;
3433 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i);
3434 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i],
3435 r_u->sam[i].hdr_name.buffer, ps,
3436 depth))
3437 return False;
3438 }
3439
3440 }
3441
3442 if(!prs_align(ps))
3443 return False;
3444 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3445 return False;
3446 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3447 return False;
3448
3449 return True;
3450}
3451
3452/*******************************************************************
3453inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3454********************************************************************/
3455
3456void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e,
3457 POLICY_HND *pol,
3458 uint32 start_idx, uint32 size)
3459{
3460 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3461
3462 q_e->pol = *pol;
3463
3464 q_e->start_idx = start_idx;
3465 q_e->max_size = size;
3466}
3467
3468/*******************************************************************
3469reads or writes a structure.
3470********************************************************************/
3471
3472BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e,
3473 prs_struct *ps, int depth)
3474{
3475 if (q_e == NULL)
3476 return False;
3477
3478 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups");
3479 depth++;
3480
3481 if(!prs_align(ps))
3482 return False;
3483
3484 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth))
3485 return False;
3486
3487 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3488 return False;
3489 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3490 return False;
3491
3492 return True;
3493}
3494
3495/*******************************************************************
3496inits a SAMR_R_ENUM_DOM_GROUPS structure.
3497********************************************************************/
3498
3499void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u,
3500 uint32 next_idx, uint32 num_sam_entries)
3501{
3502 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3503
3504 r_u->next_idx = next_idx;
3505
3506 if (num_sam_entries != 0) {
3507 r_u->ptr_entries1 = 1;
3508 r_u->ptr_entries2 = 1;
3509 r_u->num_entries2 = num_sam_entries;
3510 r_u->num_entries3 = num_sam_entries;
3511
3512 r_u->num_entries4 = num_sam_entries;
3513 } else {
3514 r_u->ptr_entries1 = 0;
3515 r_u->num_entries2 = num_sam_entries;
3516 r_u->ptr_entries2 = 1;
3517 }
3518}
3519
3520/*******************************************************************
3521reads or writes a structure.
3522********************************************************************/
3523
3524BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u,
3525 prs_struct *ps, int depth)
3526{
3527 uint32 i;
3528
3529 if (r_u == NULL)
3530 return False;
3531
3532 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups");
3533 depth++;
3534
3535 if(!prs_align(ps))
3536 return False;
3537
3538 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3539 return False;
3540 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3541 return False;
3542
3543 if (r_u->ptr_entries1 != 0) {
3544 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3545 return False;
3546 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3547 return False;
3548 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3549 return False;
3550
3551 if (UNMARSHALLING(ps) && r_u->num_entries2) {
3552 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3553 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3554 }
3555
3556 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) {
3557 DEBUG(0,
3558 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3559 r_u->num_entries4 = 0;
3560 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3561 return False;
3562 }
3563
3564 for (i = 0; i < r_u->num_entries2; i++) {
3565 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3566 return False;
3567 }
3568
3569 for (i = 0; i < r_u->num_entries2; i++) {
3570 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3571 r_u->sam[i].hdr_name.buffer, ps, depth))
3572 return False;
3573 }
3574 }
3575
3576 if(!prs_align(ps))
3577 return False;
3578 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3579 return False;
3580 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3581 return False;
3582
3583 return True;
3584}
3585
3586/*******************************************************************
3587inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3588********************************************************************/
3589
3590void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e,
3591 POLICY_HND *pol, uint32 start_idx,
3592 uint32 size)
3593{
3594 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3595
3596 q_e->pol = *pol;
3597
3598 q_e->start_idx = start_idx;
3599 q_e->max_size = size;
3600}
3601
3602
3603/*******************************************************************
3604reads or writes a structure.
3605********************************************************************/
3606
3607BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e,
3608 prs_struct *ps, int depth)
3609{
3610 if (q_e == NULL)
3611 return False;
3612
3613 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases");
3614 depth++;
3615
3616 if(!prs_align(ps))
3617 return False;
3618
3619 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
3620 return False;
3621
3622 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx))
3623 return False;
3624 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size))
3625 return False;
3626
3627 return True;
3628}
3629
3630/*******************************************************************
3631inits a SAMR_R_ENUM_DOM_ALIASES structure.
3632********************************************************************/
3633
3634void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries)
3635{
3636 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3637
3638 r_u->next_idx = next_idx;
3639
3640 if (num_sam_entries != 0) {
3641 r_u->ptr_entries1 = 1;
3642 r_u->ptr_entries2 = 1;
3643 r_u->num_entries2 = num_sam_entries;
3644 r_u->num_entries3 = num_sam_entries;
3645
3646 r_u->num_entries4 = num_sam_entries;
3647 } else {
3648 r_u->ptr_entries1 = 0;
3649 r_u->num_entries2 = num_sam_entries;
3650 r_u->ptr_entries2 = 1;
3651 }
3652}
3653
3654/*******************************************************************
3655reads or writes a structure.
3656********************************************************************/
3657
3658BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u,
3659 prs_struct *ps, int depth)
3660{
3661 uint32 i;
3662
3663 if (r_u == NULL)
3664 return False;
3665
3666 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases");
3667 depth++;
3668
3669 if(!prs_align(ps))
3670 return False;
3671
3672 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx))
3673 return False;
3674 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1))
3675 return False;
3676
3677 if (r_u->ptr_entries1 != 0) {
3678 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2))
3679 return False;
3680 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2))
3681 return False;
3682 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3))
3683 return False;
3684
3685 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) {
3686 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2);
3687 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2);
3688 }
3689
3690 if (r_u->num_entries2 != 0 &&
3691 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) {
3692 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3693 r_u->num_entries4 = 0;
3694 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED;
3695 return False;
3696 }
3697
3698 for (i = 0; i < r_u->num_entries2; i++) {
3699 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth))
3700 return False;
3701 }
3702
3703 for (i = 0; i < r_u->num_entries2; i++) {
3704 if(!smb_io_unistr2("", &r_u->uni_grp_name[i],
3705 r_u->sam[i].hdr_name.buffer, ps,
3706 depth))
3707 return False;
3708 }
3709 }
3710
3711 if(!prs_align(ps))
3712 return False;
3713 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4))
3714 return False;
3715 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3716 return False;
3717
3718 return True;
3719}
3720
3721/*******************************************************************
3722inits a ALIAS_INFO1 structure.
3723********************************************************************/
3724
3725void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
3726{
3727 DEBUG(5, ("init_samr_alias_info1\n"));
3728
3729 init_unistr4(&al1->name, acct_name, UNI_FLAGS_NONE);
3730 al1->num_member = num_member;
3731 init_unistr4(&al1->description, acct_desc, UNI_FLAGS_NONE);
3732}
3733
3734/*******************************************************************
3735reads or writes a structure.
3736********************************************************************/
3737
3738BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1,
3739 prs_struct *ps, int depth)
3740{
3741 if (al1 == NULL)
3742 return False;
3743
3744 prs_debug(ps, depth, desc, "samr_io_alias_info1");
3745 depth++;
3746
3747 if(!prs_align(ps))
3748 return False;
3749
3750 if ( !prs_unistr4_hdr("name", ps, depth, &al1->name) )
3751 return False;
3752 if ( !prs_uint32("num_member", ps, depth, &al1->num_member) )
3753 return False;
3754 if ( !prs_unistr4_hdr("description", ps, depth, &al1->description) )
3755 return False;
3756
3757 if ( !prs_unistr4_str("name", ps, depth, &al1->name) )
3758 return False;
3759 if ( !prs_align(ps) )
3760 return False;
3761 if ( !prs_unistr4_str("description", ps, depth, &al1->description) )
3762 return False;
3763 if ( !prs_align(ps) )
3764 return False;
3765
3766 return True;
3767}
3768
3769/*******************************************************************
3770inits a ALIAS_INFO3 structure.
3771********************************************************************/
3772
3773void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc)
3774{
3775 DEBUG(5, ("init_samr_alias_info3\n"));
3776
3777 init_unistr4(&al3->description, acct_desc, UNI_FLAGS_NONE);
3778}
3779
3780/*******************************************************************
3781reads or writes a structure.
3782********************************************************************/
3783
3784BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 *al3,
3785 prs_struct *ps, int depth)
3786{
3787 if (al3 == NULL)
3788 return False;
3789
3790 prs_debug(ps, depth, desc, "samr_io_alias_info3");
3791 depth++;
3792
3793 if(!prs_align(ps))
3794 return False;
3795
3796 if (!prs_unistr4("description", ps, depth, &al3->description))
3797 return False;
3798
3799 return True;
3800}
3801
3802/*******************************************************************
3803reads or writes a structure.
3804********************************************************************/
3805
3806BOOL samr_io_alias_info2(const char *desc, ALIAS_INFO2 *al2,
3807 prs_struct *ps, int depth)
3808{
3809 if (al2 == NULL)
3810 return False;
3811
3812 prs_debug(ps, depth, desc, "samr_io_alias_info2");
3813 depth++;
3814
3815 if(!prs_align(ps))
3816 return False;
3817
3818 if (!prs_unistr4("name", ps, depth, &al2->name))
3819 return False;
3820
3821 return True;
3822}
3823
3824/*******************************************************************
3825reads or writes a structure.
3826********************************************************************/
3827
3828BOOL samr_alias_info_ctr(const char *desc, prs_struct *ps, int depth, ALIAS_INFO_CTR * ctr)
3829{
3830 if ( !ctr )
3831 return False;
3832
3833 prs_debug(ps, depth, desc, "samr_alias_info_ctr");
3834 depth++;
3835
3836 if ( !prs_uint16("level", ps, depth, &ctr->level) )
3837 return False;
3838
3839 if(!prs_align(ps))
3840 return False;
3841 switch (ctr->level) {
3842 case 1:
3843 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth))
3844 return False;
3845 break;
3846 case 2:
3847 if(!samr_io_alias_info2("alias_info2", &ctr->alias.info2, ps, depth))
3848 return False;
3849 break;
3850 case 3:
3851 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth))
3852 return False;
3853 break;
3854 default:
3855 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3856 break;
3857 }
3858
3859 return True;
3860}
3861
3862/*******************************************************************
3863inits a SAMR_Q_QUERY_ALIASINFO structure.
3864********************************************************************/
3865
3866void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e,
3867 POLICY_HND *pol, uint32 switch_level)
3868{
3869 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3870
3871 q_e->pol = *pol;
3872 q_e->level = switch_level;
3873}
3874
3875/*******************************************************************
3876reads or writes a structure.
3877********************************************************************/
3878
3879BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO *in,
3880 prs_struct *ps, int depth)
3881{
3882 if ( !in )
3883 return False;
3884
3885 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo");
3886 depth++;
3887
3888 if(!prs_align(ps))
3889 return False;
3890
3891 if ( !smb_io_pol_hnd("pol", &(in->pol), ps, depth) )
3892 return False;
3893
3894 if ( !prs_uint16("level", ps, depth, &in->level) )
3895 return False;
3896
3897 return True;
3898}
3899
3900/*******************************************************************
3901inits a SAMR_R_QUERY_ALIASINFO structure.
3902********************************************************************/
3903
3904void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *out,
3905 ALIAS_INFO_CTR * ctr, NTSTATUS status)
3906{
3907 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3908
3909 out->ctr = ctr;
3910 out->status = status;
3911}
3912
3913/*******************************************************************
3914reads or writes a structure.
3915********************************************************************/
3916
3917BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO *out,
3918 prs_struct *ps, int depth)
3919{
3920 if ( !out )
3921 return False;
3922
3923 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo");
3924 depth++;
3925
3926 if(!prs_align(ps))
3927 return False;
3928
3929 if ( !prs_pointer("alias", ps, depth, (void*)&out->ctr, sizeof(ALIAS_INFO_CTR), (PRS_POINTER_CAST)samr_alias_info_ctr))
3930 return False;
3931 if(!prs_align(ps))
3932 return False;
3933
3934 if(!prs_ntstatus("status", ps, depth, &out->status))
3935 return False;
3936
3937 return True;
3938}
3939
3940/*******************************************************************
3941inits a SAMR_Q_SET_ALIASINFO structure.
3942********************************************************************/
3943
3944void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u,
3945 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr)
3946{
3947 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3948
3949 q_u->alias_pol = *hnd;
3950 q_u->ctr = *ctr;
3951}
3952
3953/*******************************************************************
3954reads or writes a structure.
3955********************************************************************/
3956
3957BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u,
3958 prs_struct *ps, int depth)
3959{
3960 if (q_u == NULL)
3961 return False;
3962
3963 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo");
3964 depth++;
3965
3966 if(!prs_align(ps))
3967 return False;
3968
3969 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
3970 return False;
3971 if(!samr_alias_info_ctr("ctr", ps, depth, &q_u->ctr))
3972 return False;
3973
3974 return True;
3975}
3976
3977/*******************************************************************
3978reads or writes a structure.
3979********************************************************************/
3980
3981BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u,
3982 prs_struct *ps, int depth)
3983{
3984 if (r_u == NULL)
3985 return False;
3986
3987 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo");
3988 depth++;
3989
3990 if(!prs_align(ps))
3991 return False;
3992 if(!prs_ntstatus("status", ps, depth, &r_u->status))
3993 return False;
3994
3995 return True;
3996}
3997
3998/*******************************************************************
3999inits a SAMR_Q_QUERY_USERALIASES structure.
4000********************************************************************/
4001
4002void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u,
4003 POLICY_HND *hnd,
4004 uint32 num_sids,
4005 uint32 *ptr_sid, DOM_SID2 * sid)
4006{
4007 DEBUG(5, ("init_samr_q_query_useraliases\n"));
4008
4009 q_u->pol = *hnd;
4010
4011 q_u->num_sids1 = num_sids;
4012 q_u->ptr = 1;
4013 q_u->num_sids2 = num_sids;
4014
4015 q_u->ptr_sid = ptr_sid;
4016 q_u->sid = sid;
4017}
4018
4019/*******************************************************************
4020reads or writes a SAMR_Q_QUERY_USERALIASES structure.
4021********************************************************************/
4022
4023BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u,
4024 prs_struct *ps, int depth)
4025{
4026 fstring tmp;
4027 uint32 i;
4028
4029 if (q_u == NULL)
4030 return False;
4031
4032 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases");
4033 depth++;
4034
4035 if(!prs_align(ps))
4036 return False;
4037
4038 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4039 return False;
4040
4041 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1))
4042 return False;
4043 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4044 return False;
4045
4046 if (q_u->ptr==0)
4047 return True;
4048
4049 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2))
4050 return False;
4051
4052 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) {
4053 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2);
4054 if (q_u->ptr_sid == NULL)
4055 return False;
4056
4057 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2);
4058 if (q_u->sid == NULL)
4059 return False;
4060 }
4061
4062 for (i = 0; i < q_u->num_sids2; i++) {
4063 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i);
4064 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i]))
4065 return False;
4066 }
4067
4068 for (i = 0; i < q_u->num_sids2; i++) {
4069 if (q_u->ptr_sid[i] != 0) {
4070 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i);
4071 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth))
4072 return False;
4073 }
4074 }
4075
4076 return True;
4077}
4078
4079/*******************************************************************
4080inits a SAMR_R_QUERY_USERALIASES structure.
4081********************************************************************/
4082
4083void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u,
4084 uint32 num_rids, uint32 *rid,
4085 NTSTATUS status)
4086{
4087 DEBUG(5, ("init_samr_r_query_useraliases\n"));
4088
4089 if (NT_STATUS_IS_OK(status)) {
4090 r_u->num_entries = num_rids;
4091 r_u->ptr = 1;
4092 r_u->num_entries2 = num_rids;
4093
4094 r_u->rid = rid;
4095 } else {
4096 r_u->num_entries = 0;
4097 r_u->ptr = 0;
4098 r_u->num_entries2 = 0;
4099 }
4100
4101 r_u->status = status;
4102}
4103
4104/*******************************************************************
4105reads or writes a structure.
4106********************************************************************/
4107
4108BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid,
4109 prs_struct *ps, int depth)
4110{
4111 fstring tmp;
4112 uint32 i;
4113 if (rid == NULL)
4114 return False;
4115
4116 prs_debug(ps, depth, desc, "samr_io_rids");
4117 depth++;
4118
4119 if(!prs_align(ps))
4120 return False;
4121
4122 if(!prs_uint32("num_rids", ps, depth, num_rids))
4123 return False;
4124
4125 if ((*num_rids) != 0) {
4126 if (UNMARSHALLING(ps)) {
4127 /* reading */
4128 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids);
4129 }
4130 if ((*rid) == NULL)
4131 return False;
4132
4133 for (i = 0; i < (*num_rids); i++) {
4134 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i);
4135 if(!prs_uint32(tmp, ps, depth, &((*rid)[i])))
4136 return False;
4137 }
4138 }
4139
4140 return True;
4141}
4142
4143/*******************************************************************
4144reads or writes a structure.
4145********************************************************************/
4146
4147BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u,
4148 prs_struct *ps, int depth)
4149{
4150 if (r_u == NULL)
4151 return False;
4152
4153 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases");
4154 depth++;
4155
4156 if(!prs_align(ps))
4157 return False;
4158
4159 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries))
4160 return False;
4161 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr))
4162 return False;
4163
4164 if (r_u->ptr != 0) {
4165 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth))
4166 return False;
4167 }
4168
4169 if(!prs_align(ps))
4170 return False;
4171 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4172 return False;
4173
4174 return True;
4175}
4176
4177/*******************************************************************
4178inits a SAMR_Q_OPEN_ALIAS structure.
4179********************************************************************/
4180
4181void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol,
4182 uint32 access_mask, uint32 rid)
4183{
4184 DEBUG(5, ("init_samr_q_open_alias\n"));
4185
4186 q_u->dom_pol = *pol;
4187 q_u->access_mask = access_mask;
4188 q_u->rid_alias = rid;
4189}
4190
4191/*******************************************************************
4192reads or writes a structure.
4193********************************************************************/
4194
4195BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u,
4196 prs_struct *ps, int depth)
4197{
4198 if (q_u == NULL)
4199 return False;
4200
4201 prs_debug(ps, depth, desc, "samr_io_q_open_alias");
4202 depth++;
4203
4204 if(!prs_align(ps))
4205 return False;
4206
4207 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth))
4208 return False;
4209
4210 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4211 return False;
4212 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias))
4213 return False;
4214
4215 return True;
4216}
4217
4218/*******************************************************************
4219reads or writes a structure.
4220********************************************************************/
4221
4222BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u,
4223 prs_struct *ps, int depth)
4224{
4225 if (r_u == NULL)
4226 return False;
4227
4228 prs_debug(ps, depth, desc, "samr_io_r_open_alias");
4229 depth++;
4230
4231 if(!prs_align(ps))
4232 return False;
4233
4234 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4235 return False;
4236
4237 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4238 return False;
4239
4240 return True;
4241}
4242
4243/*******************************************************************
4244inits a SAMR_Q_LOOKUP_RIDS structure.
4245********************************************************************/
4246
4247void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u,
4248 POLICY_HND *pol, uint32 flags,
4249 uint32 num_rids, uint32 *rid)
4250{
4251 DEBUG(5, ("init_samr_q_lookup_rids\n"));
4252
4253 q_u->pol = *pol;
4254
4255 q_u->num_rids1 = num_rids;
4256 q_u->flags = flags;
4257 q_u->ptr = 0;
4258 q_u->num_rids2 = num_rids;
4259 if (num_rids) {
4260 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids );
4261 } else {
4262 q_u->rid = NULL;
4263 }
4264 if (q_u->rid == NULL) {
4265 q_u->num_rids1 = 0;
4266 q_u->num_rids2 = 0;
4267 } else {
4268 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0]));
4269 }
4270}
4271
4272/*******************************************************************
4273reads or writes a structure.
4274********************************************************************/
4275
4276BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u,
4277 prs_struct *ps, int depth)
4278{
4279 uint32 i;
4280 fstring tmp;
4281
4282 if (q_u == NULL)
4283 return False;
4284
4285 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids");
4286 depth++;
4287
4288 if (UNMARSHALLING(ps))
4289 ZERO_STRUCTP(q_u);
4290
4291 if(!prs_align(ps))
4292 return False;
4293
4294 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4295 return False;
4296
4297 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1))
4298 return False;
4299 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4300 return False;
4301 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4302 return False;
4303 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2))
4304 return False;
4305
4306 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) {
4307 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2);
4308 if (q_u->rid == NULL)
4309 return False;
4310 }
4311
4312 for (i = 0; i < q_u->num_rids2; i++) {
4313 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
4314 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i]))
4315 return False;
4316 }
4317
4318 return True;
4319}
4320
4321/*******************************************************************
4322inits a SAMR_R_LOOKUP_RIDS structure.
4323********************************************************************/
4324
4325void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u,
4326 uint32 num_names, UNIHDR * hdr_name,
4327 UNISTR2 *uni_name, uint32 *type)
4328{
4329 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4330
4331 r_u->hdr_name = NULL;
4332 r_u->uni_name = NULL;
4333 r_u->type = NULL;
4334
4335 if (num_names != 0) {
4336 r_u->num_names1 = num_names;
4337 r_u->ptr_names = 1;
4338 r_u->num_names2 = num_names;
4339
4340 r_u->num_types1 = num_names;
4341 r_u->ptr_types = 1;
4342 r_u->num_types2 = num_names;
4343
4344 r_u->hdr_name = hdr_name;
4345 r_u->uni_name = uni_name;
4346 r_u->type = type;
4347 } else {
4348 r_u->num_names1 = num_names;
4349 r_u->ptr_names = 0;
4350 r_u->num_names2 = num_names;
4351
4352 r_u->num_types1 = num_names;
4353 r_u->ptr_types = 0;
4354 r_u->num_types2 = num_names;
4355 }
4356}
4357
4358/*******************************************************************
4359reads or writes a structure.
4360********************************************************************/
4361
4362BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u,
4363 prs_struct *ps, int depth)
4364{
4365 uint32 i;
4366 fstring tmp;
4367 if (r_u == NULL)
4368 return False;
4369
4370 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids");
4371 depth++;
4372
4373 if(!prs_align(ps))
4374 return False;
4375
4376 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1))
4377 return False;
4378 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names))
4379 return False;
4380
4381 if (r_u->ptr_names != 0) {
4382
4383 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2))
4384 return False;
4385
4386
4387 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) {
4388 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2);
4389 if (r_u->hdr_name == NULL)
4390 return False;
4391
4392 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2);
4393 if (r_u->uni_name == NULL)
4394 return False;
4395 }
4396
4397 for (i = 0; i < r_u->num_names2; i++) {
4398 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i);
4399 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth))
4400 return False;
4401 }
4402 for (i = 0; i < r_u->num_names2; i++) {
4403 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i);
4404 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth))
4405 return False;
4406 }
4407
4408 }
4409
4410 if(!prs_align(ps))
4411 return False;
4412 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
4413 return False;
4414 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
4415 return False;
4416
4417 if (r_u->ptr_types != 0) {
4418
4419 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
4420 return False;
4421
4422 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) {
4423 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
4424 if (r_u->type == NULL)
4425 return False;
4426 }
4427
4428 for (i = 0; i < r_u->num_types2; i++) {
4429 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
4430 if(!prs_uint32(tmp, ps, depth, &r_u->type[i]))
4431 return False;
4432 }
4433 }
4434
4435 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4436 return False;
4437
4438 return True;
4439}
4440
4441/*******************************************************************
4442inits a SAMR_Q_OPEN_ALIAS structure.
4443********************************************************************/
4444
4445void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd)
4446{
4447 DEBUG(5, ("init_samr_q_delete_alias\n"));
4448
4449 q_u->alias_pol = *hnd;
4450}
4451
4452/*******************************************************************
4453reads or writes a structure.
4454********************************************************************/
4455
4456BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4457 prs_struct *ps, int depth)
4458{
4459 if (q_u == NULL)
4460 return False;
4461
4462 prs_debug(ps, depth, desc, "samr_io_q_delete_alias");
4463 depth++;
4464
4465 if(!prs_align(ps))
4466 return False;
4467
4468 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4469 return False;
4470
4471 return True;
4472}
4473
4474/*******************************************************************
4475reads or writes a structure.
4476********************************************************************/
4477
4478BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4479 prs_struct *ps, int depth)
4480{
4481 if (r_u == NULL)
4482 return False;
4483
4484 prs_debug(ps, depth, desc, "samr_io_r_delete_alias");
4485 depth++;
4486
4487 if(!prs_align(ps))
4488 return False;
4489
4490 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4491 return False;
4492 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4493 return False;
4494
4495 return True;
4496}
4497
4498/*******************************************************************
4499inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4500********************************************************************/
4501
4502void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
4503 POLICY_HND *hnd, const char *acct_desc)
4504{
4505 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4506
4507 q_u->dom_pol = *hnd;
4508
4509 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
4510 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
4511
4512 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
4513}
4514
4515/*******************************************************************
4516reads or writes a structure.
4517********************************************************************/
4518
4519BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u,
4520 prs_struct *ps, int depth)
4521{
4522 if (q_u == NULL)
4523 return False;
4524
4525 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias");
4526 depth++;
4527
4528 if(!prs_align(ps))
4529 return False;
4530
4531 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth))
4532 return False;
4533
4534 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth))
4535 return False;
4536 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc,
4537 q_u->hdr_acct_desc.buffer, ps, depth))
4538 return False;
4539
4540 if(!prs_align(ps))
4541 return False;
4542 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
4543 return False;
4544
4545 return True;
4546}
4547
4548/*******************************************************************
4549reads or writes a structure.
4550********************************************************************/
4551
4552BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u,
4553 prs_struct *ps, int depth)
4554{
4555 if (r_u == NULL)
4556 return False;
4557
4558 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias");
4559 depth++;
4560
4561 if(!prs_align(ps))
4562 return False;
4563
4564 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth))
4565 return False;
4566
4567 if(!prs_uint32("rid", ps, depth, &r_u->rid))
4568 return False;
4569
4570 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4571 return False;
4572
4573 return True;
4574}
4575
4576/*******************************************************************
4577inits a SAMR_Q_ADD_ALIASMEM structure.
4578********************************************************************/
4579
4580void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd,
4581 DOM_SID *sid)
4582{
4583 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4584
4585 q_u->alias_pol = *hnd;
4586 init_dom_sid2(&q_u->sid, sid);
4587}
4588
4589/*******************************************************************
4590reads or writes a structure.
4591********************************************************************/
4592
4593BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u,
4594 prs_struct *ps, int depth)
4595{
4596 if (q_u == NULL)
4597 return False;
4598
4599 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem");
4600 depth++;
4601
4602 if(!prs_align(ps))
4603 return False;
4604
4605 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4606 return False;
4607 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4608 return False;
4609
4610 return True;
4611}
4612
4613/*******************************************************************
4614reads or writes a structure.
4615********************************************************************/
4616
4617BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u,
4618 prs_struct *ps, int depth)
4619{
4620 if (r_u == NULL)
4621 return False;
4622
4623 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem");
4624 depth++;
4625
4626 if(!prs_align(ps))
4627 return False;
4628
4629 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4630 return False;
4631
4632 return True;
4633}
4634
4635/*******************************************************************
4636inits a SAMR_Q_DEL_ALIASMEM structure.
4637********************************************************************/
4638
4639void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd,
4640 DOM_SID *sid)
4641{
4642 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4643
4644 q_u->alias_pol = *hnd;
4645 init_dom_sid2(&q_u->sid, sid);
4646}
4647
4648/*******************************************************************
4649reads or writes a structure.
4650********************************************************************/
4651
4652BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u,
4653 prs_struct *ps, int depth)
4654{
4655 if (q_u == NULL)
4656 return False;
4657
4658 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem");
4659 depth++;
4660
4661 if(!prs_align(ps))
4662 return False;
4663
4664 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4665 return False;
4666 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth))
4667 return False;
4668
4669 return True;
4670}
4671
4672/*******************************************************************
4673reads or writes a structure.
4674********************************************************************/
4675
4676BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u,
4677 prs_struct *ps, int depth)
4678{
4679 if (r_u == NULL)
4680 return False;
4681
4682 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem");
4683 depth++;
4684
4685 if(!prs_align(ps))
4686 return False;
4687
4688 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4689 return False;
4690
4691 return True;
4692}
4693
4694/*******************************************************************
4695inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4696********************************************************************/
4697
4698void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c,
4699 POLICY_HND *hnd)
4700{
4701 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4702
4703 q_c->alias_pol = *hnd;
4704}
4705
4706/*******************************************************************
4707reads or writes a structure.
4708********************************************************************/
4709
4710BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u,
4711 prs_struct *ps, int depth)
4712{
4713 if (q_u == NULL)
4714 return False;
4715
4716 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias");
4717 depth++;
4718
4719 if(!prs_align(ps))
4720 return False;
4721
4722 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4723 return False;
4724
4725 return True;
4726}
4727
4728/*******************************************************************
4729inits a SAMR_R_DELETE_DOM_ALIAS structure.
4730********************************************************************/
4731
4732void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u,
4733 NTSTATUS status)
4734{
4735 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4736
4737 r_u->status = status;
4738}
4739
4740/*******************************************************************
4741reads or writes a structure.
4742********************************************************************/
4743
4744BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u,
4745 prs_struct *ps, int depth)
4746{
4747 if (r_u == NULL)
4748 return False;
4749
4750 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias");
4751 depth++;
4752
4753 if(!prs_align(ps))
4754 return False;
4755
4756 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
4757 return False;
4758
4759 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4760 return False;
4761
4762 return True;
4763}
4764
4765/*******************************************************************
4766inits a SAMR_Q_QUERY_ALIASMEM structure.
4767********************************************************************/
4768
4769void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c,
4770 POLICY_HND *hnd)
4771{
4772 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4773
4774 q_c->alias_pol = *hnd;
4775}
4776
4777/*******************************************************************
4778reads or writes a structure.
4779********************************************************************/
4780
4781BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u,
4782 prs_struct *ps, int depth)
4783{
4784 if (q_u == NULL)
4785 return False;
4786
4787 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem");
4788 depth++;
4789
4790 if(!prs_align(ps))
4791 return False;
4792
4793 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth))
4794 return False;
4795
4796 return True;
4797}
4798
4799/*******************************************************************
4800inits a SAMR_R_QUERY_ALIASMEM structure.
4801********************************************************************/
4802
4803void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u,
4804 uint32 num_sids, DOM_SID2 * sid,
4805 NTSTATUS status)
4806{
4807 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4808
4809 if (NT_STATUS_IS_OK(status)) {
4810 r_u->num_sids = num_sids;
4811 r_u->ptr = (num_sids != 0) ? 1 : 0;
4812 r_u->num_sids1 = num_sids;
4813
4814 r_u->sid = sid;
4815 } else {
4816 r_u->ptr = 0;
4817 r_u->num_sids = 0;
4818 }
4819
4820 r_u->status = status;
4821}
4822
4823/*******************************************************************
4824reads or writes a structure.
4825********************************************************************/
4826
4827BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u,
4828 prs_struct *ps, int depth)
4829{
4830 uint32 i;
4831
4832 if (r_u == NULL)
4833 return False;
4834
4835 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem");
4836 depth++;
4837
4838 if(!prs_align(ps))
4839 return False;
4840
4841 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids))
4842 return False;
4843 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
4844 return False;
4845
4846 if (r_u->ptr != 0 && r_u->num_sids != 0) {
4847 uint32 *ptr_sid = NULL;
4848
4849 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1))
4850 return False;
4851
4852 /* We must always use talloc here even when marshalling. */
4853 if (r_u->num_sids1) {
4854 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1);
4855 if (!ptr_sid) {
4856 return False;
4857 }
4858 } else {
4859 ptr_sid = NULL;
4860 }
4861
4862 for (i = 0; i < r_u->num_sids1; i++) {
4863 ptr_sid[i] = 1;
4864 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i]))
4865 return False;
4866 }
4867
4868 if (UNMARSHALLING(ps)) {
4869 if (r_u->num_sids1) {
4870 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1);
4871 if (!r_u->sid) {
4872 return False;
4873 }
4874 } else {
4875 r_u->sid = NULL;
4876 }
4877 }
4878
4879 for (i = 0; i < r_u->num_sids1; i++) {
4880 if (ptr_sid[i] != 0) {
4881 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth))
4882 return False;
4883 }
4884 }
4885 }
4886
4887 if(!prs_align(ps))
4888 return False;
4889 if(!prs_ntstatus("status", ps, depth, &r_u->status))
4890 return False;
4891
4892 return True;
4893}
4894
4895/*******************************************************************
4896inits a SAMR_Q_LOOKUP_NAMES structure.
4897********************************************************************/
4898
4899NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
4900 POLICY_HND *pol, uint32 flags,
4901 uint32 num_names, const char **name)
4902{
4903 uint32 i;
4904
4905 DEBUG(5, ("init_samr_q_lookup_names\n"));
4906
4907 q_u->pol = *pol;
4908
4909 q_u->num_names1 = num_names;
4910 q_u->flags = flags;
4911 q_u->ptr = 0;
4912 q_u->num_names2 = num_names;
4913
4914 if (num_names) {
4915 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names)))
4916 return NT_STATUS_NO_MEMORY;
4917
4918 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names)))
4919 return NT_STATUS_NO_MEMORY;
4920 } else {
4921 q_u->hdr_name = NULL;
4922 q_u->uni_name = NULL;
4923 }
4924
4925 for (i = 0; i < num_names; i++) {
4926 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
4927 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
4928 }
4929
4930 return NT_STATUS_OK;
4931}
4932
4933/*******************************************************************
4934reads or writes a structure.
4935********************************************************************/
4936
4937BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u,
4938 prs_struct *ps, int depth)
4939{
4940 uint32 i;
4941
4942 if (q_u == NULL)
4943 return False;
4944
4945 prs_debug(ps, depth, desc, "samr_io_q_lookup_names");
4946 depth++;
4947
4948 if (UNMARSHALLING(ps))
4949 ZERO_STRUCTP(q_u);
4950
4951 if(!prs_align(ps))
4952 return False;
4953
4954 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
4955 return False;
4956
4957 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1))
4958 return False;
4959 if(!prs_uint32("flags ", ps, depth, &q_u->flags))
4960 return False;
4961 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
4962 return False;
4963 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2))
4964 return False;
4965
4966 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) {
4967 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2);
4968 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2);
4969 if (!q_u->hdr_name || !q_u->uni_name)
4970 return False;
4971 }
4972
4973 for (i = 0; i < q_u->num_names2; i++) {
4974 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth))
4975 return False;
4976 }
4977
4978 for (i = 0; i < q_u->num_names2; i++) {
4979 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth))
4980 return False;
4981 }
4982
4983 return True;
4984}
4985
4986/*******************************************************************
4987inits a SAMR_R_LOOKUP_NAMES structure.
4988********************************************************************/
4989
4990NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u,
4991 uint32 num_rids,
4992 uint32 *rid, enum lsa_SidType *type,
4993 NTSTATUS status)
4994{
4995 DEBUG(5, ("init_samr_r_lookup_names\n"));
4996
4997 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) {
4998 uint32 i;
4999
5000 r_u->num_types1 = num_rids;
5001 r_u->ptr_types = 1;
5002 r_u->num_types2 = num_rids;
5003
5004 r_u->num_rids1 = num_rids;
5005 r_u->ptr_rids = 1;
5006 r_u->num_rids2 = num_rids;
5007
5008 if (num_rids) {
5009 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
5010 return NT_STATUS_NO_MEMORY;
5011 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids)))
5012 return NT_STATUS_NO_MEMORY;
5013 } else {
5014 r_u->rids = NULL;
5015 r_u->types = NULL;
5016 }
5017
5018 if (!r_u->rids || !r_u->types)
5019 goto empty;
5020
5021 for (i = 0; i < num_rids; i++) {
5022 r_u->rids[i] = rid[i];
5023 r_u->types[i] = type[i];
5024 }
5025 } else {
5026
5027 empty:
5028 r_u->num_types1 = 0;
5029 r_u->ptr_types = 0;
5030 r_u->num_types2 = 0;
5031
5032 r_u->num_rids1 = 0;
5033 r_u->ptr_rids = 0;
5034 r_u->num_rids2 = 0;
5035
5036 r_u->rids = NULL;
5037 r_u->types = NULL;
5038 }
5039
5040 r_u->status = status;
5041
5042 return NT_STATUS_OK;
5043}
5044
5045/*******************************************************************
5046reads or writes a structure.
5047********************************************************************/
5048
5049BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u,
5050 prs_struct *ps, int depth)
5051{
5052 uint32 i;
5053 fstring tmp;
5054
5055 if (r_u == NULL)
5056 return False;
5057
5058 prs_debug(ps, depth, desc, "samr_io_r_lookup_names");
5059 depth++;
5060
5061 if (UNMARSHALLING(ps))
5062 ZERO_STRUCTP(r_u);
5063
5064 if(!prs_align(ps))
5065 return False;
5066
5067 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1))
5068 return False;
5069 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids))
5070 return False;
5071
5072 if (r_u->ptr_rids != 0) {
5073 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2))
5074 return False;
5075
5076 if (r_u->num_rids2 != r_u->num_rids1) {
5077 /* RPC fault */
5078 return False;
5079 }
5080
5081 if (UNMARSHALLING(ps) && r_u->num_rids2) {
5082 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2);
5083
5084 if (!r_u->rids) {
5085 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
5086 return False;
5087 }
5088 }
5089
5090 for (i = 0; i < r_u->num_rids2; i++) {
5091 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i);
5092 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i]))
5093 return False;
5094 }
5095 }
5096
5097 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1))
5098 return False;
5099 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types))
5100 return False;
5101
5102 if (r_u->ptr_types != 0) {
5103 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2))
5104 return False;
5105
5106 if (r_u->num_types2 != r_u->num_types1) {
5107 /* RPC fault */
5108 return False;
5109 }
5110
5111 if (UNMARSHALLING(ps) && r_u->num_types2) {
5112 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2);
5113
5114 if (!r_u->types) {
5115 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
5116 return False;
5117 }
5118 }
5119
5120 for (i = 0; i < r_u->num_types2; i++) {
5121 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i);
5122 if(!prs_uint32(tmp, ps, depth, &r_u->types[i]))
5123 return False;
5124 }
5125 }
5126
5127 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5128 return False;
5129
5130 return True;
5131}
5132
5133/*******************************************************************
5134inits a SAMR_Q_DELETE_DOM_USER structure.
5135********************************************************************/
5136
5137void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c,
5138 POLICY_HND *hnd)
5139{
5140 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
5141
5142 q_c->user_pol = *hnd;
5143}
5144
5145/*******************************************************************
5146reads or writes a structure.
5147********************************************************************/
5148
5149BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u,
5150 prs_struct *ps, int depth)
5151{
5152 if (q_u == NULL)
5153 return False;
5154
5155 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user");
5156 depth++;
5157
5158 if(!prs_align(ps))
5159 return False;
5160
5161 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth))
5162 return False;
5163
5164 return True;
5165}
5166
5167/*******************************************************************
5168reads or writes a structure.
5169********************************************************************/
5170
5171BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u,
5172 prs_struct *ps, int depth)
5173{
5174 if (r_u == NULL)
5175 return False;
5176
5177 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user");
5178 depth++;
5179
5180 if(!prs_align(ps))
5181 return False;
5182
5183 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth))
5184 return False;
5185 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5186 return False;
5187
5188 return True;
5189}
5190
5191/*******************************************************************
5192reads or writes a structure.
5193********************************************************************/
5194
5195void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u,
5196 POLICY_HND *pol,
5197 uint32 access_mask, uint32 rid)
5198{
5199 DEBUG(5, ("samr_init_samr_q_open_user\n"));
5200
5201 q_u->domain_pol = *pol;
5202 q_u->access_mask = access_mask;
5203 q_u->user_rid = rid;
5204}
5205
5206/*******************************************************************
5207reads or writes a structure.
5208********************************************************************/
5209
5210BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u,
5211 prs_struct *ps, int depth)
5212{
5213 if (q_u == NULL)
5214 return False;
5215
5216 prs_debug(ps, depth, desc, "samr_io_q_open_user");
5217 depth++;
5218
5219 if(!prs_align(ps))
5220 return False;
5221
5222 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5223 return False;
5224
5225 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
5226 return False;
5227 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid))
5228 return False;
5229
5230 return True;
5231}
5232
5233/*******************************************************************
5234reads or writes a structure.
5235********************************************************************/
5236
5237BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u,
5238 prs_struct *ps, int depth)
5239{
5240 if (r_u == NULL)
5241 return False;
5242
5243 prs_debug(ps, depth, desc, "samr_io_r_open_user");
5244 depth++;
5245
5246 if(!prs_align(ps))
5247 return False;
5248
5249 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5250 return False;
5251
5252 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5253 return False;
5254
5255 return True;
5256}
5257
5258
5259/*******************************************************************
5260reads or writes a structure.
5261********************************************************************/
5262
5263void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
5264 POLICY_HND *pol,
5265 const char *name,
5266 uint32 acb_info, uint32 acct_flags)
5267{
5268 DEBUG(5, ("samr_init_samr_q_create_user\n"));
5269
5270 q_u->domain_pol = *pol;
5271
5272 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
5273 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
5274
5275 q_u->acb_info = acb_info;
5276 q_u->acct_flags = acct_flags;
5277}
5278
5279/*******************************************************************
5280reads or writes a structure.
5281********************************************************************/
5282
5283BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u,
5284 prs_struct *ps, int depth)
5285{
5286 if (q_u == NULL)
5287 return False;
5288
5289 prs_debug(ps, depth, desc, "samr_io_q_create_user");
5290 depth++;
5291
5292 if(!prs_align(ps))
5293 return False;
5294
5295 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
5296 return False;
5297
5298 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth))
5299 return False;
5300 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth))
5301 return False;
5302
5303 if(!prs_align(ps))
5304 return False;
5305 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info))
5306 return False;
5307 if(!prs_uint32("acct_flags", ps, depth, &q_u->acct_flags))
5308 return False;
5309
5310 return True;
5311}
5312
5313/*******************************************************************
5314reads or writes a structure.
5315********************************************************************/
5316
5317BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u,
5318 prs_struct *ps, int depth)
5319{
5320 if (r_u == NULL)
5321 return False;
5322
5323 prs_debug(ps, depth, desc, "samr_io_r_create_user");
5324 depth++;
5325
5326 if(!prs_align(ps))
5327 return False;
5328
5329 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth))
5330 return False;
5331
5332 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted))
5333 return False;
5334 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid))
5335 return False;
5336 if(!prs_ntstatus("status", ps, depth, &r_u->status))
5337 return False;
5338
5339 return True;
5340}
5341
5342/*******************************************************************
5343inits a SAMR_Q_QUERY_USERINFO structure.
5344********************************************************************/
5345
5346void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u,
5347 const POLICY_HND *hnd, uint16 switch_value)
5348{
5349 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5350
5351 q_u->pol = *hnd;
5352 q_u->switch_value = switch_value;
5353}
5354
5355/*******************************************************************
5356reads or writes a structure.
5357********************************************************************/
5358
5359BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u,
5360 prs_struct *ps, int depth)
5361{
5362 if (q_u == NULL)
5363 return False;
5364
5365 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo");
5366 depth++;
5367
5368 if(!prs_align(ps))
5369 return False;
5370
5371 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
5372 return False;
5373
5374 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */
5375 return False;
5376
5377 return True;
5378}
5379
5380/*******************************************************************
5381reads or writes a LOGON_HRS structure.
5382********************************************************************/
5383
5384static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs,
5385 prs_struct *ps, int depth)
5386{
5387 if (hrs == NULL)
5388 return False;
5389
5390 prs_debug(ps, depth, desc, "sam_io_logon_hrs");
5391 depth++;
5392
5393 if(!prs_align(ps))
5394 return False;
5395
5396 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len))
5397 return False;
5398
5399 if(!prs_uint32("offset", ps, depth, &hrs->offset))
5400 return False;
5401
5402 if(!prs_uint32("len ", ps, depth, &hrs->len))
5403 return False;
5404
5405 if (hrs->len > sizeof(hrs->hours)) {
5406 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len));
5407 hrs->len = sizeof(hrs->hours);
5408 }
5409
5410 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len))
5411 return False;
5412
5413 return True;
5414}
5415
5416/*******************************************************************
5417inits a SAM_USER_INFO_18 structure.
5418********************************************************************/
5419
5420void init_sam_user_info18(SAM_USER_INFO_18 * usr,
5421 const uint8 lm_pwd[16], const uint8 nt_pwd[16])
5422{
5423 DEBUG(5, ("init_sam_user_info18\n"));
5424
5425 usr->lm_pwd_active =
5426 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0;
5427 usr->nt_pwd_active =
5428 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0;
5429}
5430
5431/*******************************************************************
5432reads or writes a structure.
5433********************************************************************/
5434
5435static BOOL sam_io_user_info18(const char *desc, SAM_USER_INFO_18 * u,
5436 prs_struct *ps, int depth)
5437{
5438 if (u == NULL)
5439 return False;
5440
5441 prs_debug(ps, depth, desc, "samr_io_r_user_info18");
5442 depth++;
5443
5444 if(!prs_align(ps))
5445 return False;
5446
5447 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd)))
5448 return False;
5449 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd)))
5450 return False;
5451
5452 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active))
5453 return False;
5454 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active))
5455 return False;
5456
5457 return True;
5458}
5459
5460/*******************************************************************
5461inits a SAM_USER_INFO_7 structure.
5462********************************************************************/
5463
5464void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name)
5465{
5466 DEBUG(5, ("init_sam_user_info7\n"));
5467
5468 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */
5469 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */
5470
5471}
5472
5473/*******************************************************************
5474reads or writes a structure.
5475********************************************************************/
5476
5477static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr,
5478 prs_struct *ps, int depth)
5479{
5480 if (usr == NULL)
5481 return False;
5482
5483 prs_debug(ps, depth, desc, "samr_io_r_user_info7");
5484 depth++;
5485
5486 if(!prs_align(ps))
5487 return False;
5488
5489 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth))
5490 return False;
5491
5492 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth))
5493 return False;
5494
5495 return True;
5496}
5497
5498/*******************************************************************
5499inits a SAM_USER_INFO_9 structure.
5500********************************************************************/
5501
5502void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
5503{
5504 DEBUG(5, ("init_sam_user_info9\n"));
5505
5506 usr->rid_group = rid_group;
5507}
5508
5509/*******************************************************************
5510reads or writes a structure.
5511********************************************************************/
5512
5513static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
5514 prs_struct *ps, int depth)
5515{
5516 if (usr == NULL)
5517 return False;
5518
5519 prs_debug(ps, depth, desc, "samr_io_r_user_info9");
5520 depth++;
5521
5522 if(!prs_align(ps))
5523 return False;
5524
5525 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5526 return False;
5527
5528 return True;
5529}
5530
5531/*******************************************************************
5532inits a SAM_USER_INFO_16 structure.
5533********************************************************************/
5534
5535void init_sam_user_info16(SAM_USER_INFO_16 * usr, uint32 acb_info)
5536{
5537 DEBUG(5, ("init_sam_user_info16\n"));
5538
5539 usr->acb_info = acb_info;
5540}
5541
5542/*******************************************************************
5543reads or writes a structure.
5544********************************************************************/
5545
5546static BOOL sam_io_user_info16(const char *desc, SAM_USER_INFO_16 * usr,
5547 prs_struct *ps, int depth)
5548{
5549 if (usr == NULL)
5550 return False;
5551
5552 prs_debug(ps, depth, desc, "samr_io_r_user_info16");
5553 depth++;
5554
5555 if(!prs_align(ps))
5556 return False;
5557
5558 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info))
5559 return False;
5560
5561 return True;
5562}
5563
5564/*******************************************************************
5565inits a SAM_USER_INFO_17 structure.
5566********************************************************************/
5567
5568void init_sam_user_info17(SAM_USER_INFO_17 * usr,
5569 NTTIME * expiry,
5570 char *mach_acct,
5571 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
5572{
5573 DEBUG(5, ("init_sam_user_info17\n"));
5574
5575 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
5576 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
5577
5578 usr->padding_2 = 0; /* 0 - padding 4 bytes */
5579
5580 usr->ptr_1 = 1; /* pointer */
5581 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */
5582 usr->padding_4 = 0; /* 0 - padding 4 bytes */
5583
5584 usr->ptr_2 = 1; /* pointer */
5585 usr->padding_5 = 0; /* 0 - padding 4 bytes */
5586
5587 usr->ptr_3 = 1; /* pointer */
5588 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */
5589
5590 usr->rid_user = rid_user;
5591 usr->rid_group = rid_group;
5592
5593 usr->acct_ctrl = acct_ctrl;
5594 usr->unknown_3 = 0x0000;
5595
5596 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */
5597 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */
5598
5599 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
5600 usr->padding_8 = 0; /* 0 - padding 4 bytes */
5601
5602 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
5603 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
5604}
5605
5606/*******************************************************************
5607reads or writes a structure.
5608********************************************************************/
5609
5610static BOOL sam_io_user_info17(const char *desc, SAM_USER_INFO_17 * usr,
5611 prs_struct *ps, int depth)
5612{
5613 if (usr == NULL)
5614 return False;
5615
5616 prs_debug(ps, depth, desc, "samr_io_r_unknown_17");
5617 depth++;
5618
5619 if(!prs_align(ps))
5620 return False;
5621
5622 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0)))
5623 return False;
5624
5625 if(!smb_io_time("time", &usr->expiry, ps, depth))
5626 return False;
5627
5628 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1)))
5629 return False;
5630
5631 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth))
5632 return False;
5633
5634 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2))
5635 return False;
5636
5637 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1))
5638 return False;
5639 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3)))
5640 return False;
5641
5642 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4))
5643 return False;
5644
5645 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2))
5646 return False;
5647 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5))
5648 return False;
5649
5650 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3))
5651 return False;
5652 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6)))
5653 return False;
5654
5655 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user))
5656 return False;
5657 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
5658 return False;
5659 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl))
5660 return False;
5661 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3))
5662 return False;
5663 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4))
5664 return False;
5665 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5))
5666 return False;
5667
5668 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7)))
5669 return False;
5670
5671 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8)))
5672 return False;
5673
5674 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth))
5675 return False;
5676
5677 if(!prs_align(ps))
5678 return False;
5679
5680 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9)))
5681 return False;
5682
5683 return True;
5684}
5685
5686/*************************************************************************
5687 init_sam_user_info24
5688 *************************************************************************/
5689
5690void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516],
5691 uint8 pw_len)
5692{
5693 DEBUG(10, ("init_sam_user_info24:\n"));
5694 memcpy(usr->pass, newpass, sizeof(usr->pass));
5695 usr->pw_len = pw_len;
5696}
5697
5698/*******************************************************************
5699reads or writes a structure.
5700********************************************************************/
5701
5702static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr,
5703 prs_struct *ps, int depth)
5704{
5705 if (usr == NULL)
5706 return False;
5707
5708 prs_debug(ps, depth, desc, "sam_io_user_info24");
5709 depth++;
5710
5711 if(!prs_align(ps))
5712 return False;
5713
5714 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5715 sizeof(usr->pass)))
5716 return False;
5717
5718 if (MARSHALLING(ps) && (usr->pw_len != 0)) {
5719 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5720 return False;
5721 } else if (UNMARSHALLING(ps)) {
5722 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5723 return False;
5724 }
5725
5726 return True;
5727}
5728
5729/*******************************************************************
5730reads or writes a structure.
5731********************************************************************/
5732
5733static BOOL sam_io_user_info26(const char *desc, SAM_USER_INFO_26 * usr,
5734 prs_struct *ps, int depth)
5735{
5736 if (usr == NULL)
5737 return False;
5738
5739 prs_debug(ps, depth, desc, "sam_io_user_info26");
5740 depth++;
5741
5742 if(!prs_align(ps))
5743 return False;
5744
5745 if(!prs_uint8s(False, "password", ps, depth, usr->pass,
5746 sizeof(usr->pass)))
5747 return False;
5748
5749 if (!prs_uint8("pw_len", ps, depth, &usr->pw_len))
5750 return False;
5751
5752 return True;
5753}
5754
5755
5756/*************************************************************************
5757 init_sam_user_info23
5758
5759 unknown_6 = 0x0000 04ec
5760
5761 *************************************************************************/
5762
5763void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5764 NTTIME * logoff_time, /* all zeros */
5765 NTTIME * kickoff_time, /* all zeros */
5766 NTTIME * pass_last_set_time, /* all zeros */
5767 NTTIME * pass_can_change_time, /* all zeros */
5768 NTTIME * pass_must_change_time, /* all zeros */
5769 UNISTR2 *user_name,
5770 UNISTR2 *full_name,
5771 UNISTR2 *home_dir,
5772 UNISTR2 *dir_drive,
5773 UNISTR2 *log_scr,
5774 UNISTR2 *prof_path,
5775 UNISTR2 *desc,
5776 UNISTR2 *wkstas,
5777 UNISTR2 *unk_str,
5778 UNISTR2 *mung_dial,
5779 uint32 user_rid, /* 0x0000 0000 */
5780 uint32 group_rid,
5781 uint32 acb_info,
5782 uint32 fields_present,
5783 uint16 logon_divs,
5784 LOGON_HRS * hrs,
5785 uint16 bad_password_count,
5786 uint16 logon_count,
5787 char newpass[516])
5788{
5789 usr->logon_time = *logon_time; /* all zeros */
5790 usr->logoff_time = *logoff_time; /* all zeros */
5791 usr->kickoff_time = *kickoff_time; /* all zeros */
5792 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5793 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5794 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5795
5796 ZERO_STRUCT(usr->nt_pwd);
5797 ZERO_STRUCT(usr->lm_pwd);
5798
5799 usr->user_rid = user_rid; /* 0x0000 0000 */
5800 usr->group_rid = group_rid;
5801 usr->acb_info = acb_info;
5802 usr->fields_present = fields_present; /* 09f8 27fa */
5803
5804 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5805 usr->ptr_logon_hrs = hrs ? 1 : 0;
5806
5807 if (nt_time_is_zero(pass_must_change_time)) {
5808 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5809 } else {
5810 usr->passmustchange=0;
5811 }
5812
5813 ZERO_STRUCT(usr->padding1);
5814 ZERO_STRUCT(usr->padding2);
5815
5816 usr->bad_password_count = bad_password_count;
5817 usr->logon_count = logon_count;
5818
5819 memcpy(usr->pass, newpass, sizeof(usr->pass));
5820
5821 copy_unistr2(&usr->uni_user_name, user_name);
5822 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5823
5824 copy_unistr2(&usr->uni_full_name, full_name);
5825 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5826
5827 copy_unistr2(&usr->uni_home_dir, home_dir);
5828 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5829
5830 copy_unistr2(&usr->uni_dir_drive, dir_drive);
5831 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5832
5833 copy_unistr2(&usr->uni_logon_script, log_scr);
5834 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5835
5836 copy_unistr2(&usr->uni_profile_path, prof_path);
5837 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5838
5839 copy_unistr2(&usr->uni_acct_desc, desc);
5840 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5841
5842 copy_unistr2(&usr->uni_workstations, wkstas);
5843 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5844
5845 copy_unistr2(&usr->uni_comment, unk_str);
5846 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5847
5848 copy_unistr2(&usr->uni_munged_dial, mung_dial);
5849 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5850
5851 if (hrs) {
5852 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5853 } else {
5854 ZERO_STRUCT(usr->logon_hrs);
5855 }
5856}
5857
5858/*************************************************************************
5859 init_sam_user_info23
5860
5861 unknown_6 = 0x0000 04ec
5862
5863 *************************************************************************/
5864
5865void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */
5866 NTTIME * logoff_time, /* all zeros */
5867 NTTIME * kickoff_time, /* all zeros */
5868 NTTIME * pass_last_set_time, /* all zeros */
5869 NTTIME * pass_can_change_time, /* all zeros */
5870 NTTIME * pass_must_change_time, /* all zeros */
5871 char *user_name, /* NULL */
5872 char *full_name,
5873 char *home_dir, char *dir_drive, char *log_scr,
5874 char *prof_path, const char *desc, char *wkstas,
5875 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */
5876 uint32 group_rid, uint32 acb_info,
5877 uint32 fields_present, uint16 logon_divs,
5878 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
5879 char newpass[516])
5880{
5881 DATA_BLOB blob = base64_decode_data_blob(mung_dial);
5882
5883 usr->logon_time = *logon_time; /* all zeros */
5884 usr->logoff_time = *logoff_time; /* all zeros */
5885 usr->kickoff_time = *kickoff_time; /* all zeros */
5886 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */
5887 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
5888 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
5889
5890 ZERO_STRUCT(usr->nt_pwd);
5891 ZERO_STRUCT(usr->lm_pwd);
5892
5893 usr->user_rid = user_rid; /* 0x0000 0000 */
5894 usr->group_rid = group_rid;
5895 usr->acb_info = acb_info;
5896 usr->fields_present = fields_present; /* 09f8 27fa */
5897
5898 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
5899 usr->ptr_logon_hrs = hrs ? 1 : 0;
5900
5901 if (nt_time_is_zero(pass_must_change_time)) {
5902 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
5903 } else {
5904 usr->passmustchange=0;
5905 }
5906
5907 ZERO_STRUCT(usr->padding1);
5908 ZERO_STRUCT(usr->padding2);
5909
5910 usr->bad_password_count = bad_password_count;
5911 usr->logon_count = logon_count;
5912
5913 memcpy(usr->pass, newpass, sizeof(usr->pass));
5914
5915 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
5916 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
5917
5918 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
5919 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
5920
5921 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
5922 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
5923
5924 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
5925 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
5926
5927 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
5928 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
5929
5930 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
5931 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
5932
5933 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
5934 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
5935
5936 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
5937 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
5938
5939 init_unistr2(&usr->uni_comment, unk_str, UNI_FLAGS_NONE);
5940 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
5941
5942 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
5943 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
5944
5945 data_blob_free(&blob);
5946
5947 if (hrs) {
5948 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
5949 } else {
5950 ZERO_STRUCT(usr->logon_hrs);
5951 }
5952}
5953
5954
5955/*************************************************************************
5956 init_samr_user_info25P
5957 fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS
5958*************************************************************************/
5959
5960void init_sam_user_info25P(SAM_USER_INFO_25 * usr,
5961 uint32 fields_present, uint32 acb_info,
5962 char newpass[532])
5963{
5964 usr->fields_present = fields_present;
5965 ZERO_STRUCT(usr->padding1);
5966 ZERO_STRUCT(usr->padding2);
5967
5968 usr->acb_info = acb_info;
5969 memcpy(usr->pass, newpass, sizeof(usr->pass));
5970}
5971
5972
5973/*******************************************************************
5974reads or writes a structure.
5975********************************************************************/
5976
5977static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr,
5978 prs_struct *ps, int depth)
5979{
5980 if (usr == NULL)
5981 return False;
5982
5983 prs_debug(ps, depth, desc, "sam_io_user_info23");
5984 depth++;
5985
5986 if(!prs_align(ps))
5987 return False;
5988
5989 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
5990 return False;
5991 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
5992 return False;
5993 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
5994 return False;
5995 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
5996 return False;
5997 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
5998 return False;
5999 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6000 return False;
6001
6002 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6003 return False;
6004 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6005 return False;
6006 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6007 return False;
6008 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6009 return False;
6010 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6011 return False;
6012 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6013 return False;
6014 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6015 return False;
6016 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6017 return False;
6018 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6019 return False;
6020 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6021 return False;
6022
6023 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6024 return False;
6025 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6026 return False;
6027
6028 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6029 return False;
6030 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6031 return False;
6032 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6033 return False;
6034
6035 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6036 return False;
6037 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6038 return False;
6039 if(!prs_align(ps))
6040 return False;
6041 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6042 return False;
6043
6044 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6045 return False;
6046 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6047 return False;
6048
6049 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6050 return False;
6051 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6052 return False;
6053 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6054 return False;
6055
6056
6057 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6058 return False;
6059
6060 /* here begins pointed-to data */
6061
6062 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6063 return False;
6064
6065 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6066 return False;
6067
6068 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6069 return False;
6070
6071 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6072 return False;
6073
6074 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6075 return False;
6076
6077 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6078 return False;
6079
6080 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6081 return False;
6082
6083 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6084 return False;
6085
6086 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6087 return False;
6088
6089 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6090 return False;
6091
6092 /* ok, this is only guess-work (as usual) */
6093 if (usr->ptr_logon_hrs) {
6094 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6095 return False;
6096 }
6097
6098 return True;
6099}
6100
6101/*******************************************************************
6102 reads or writes a structure.
6103 NB. This structure is *definately* incorrect. It's my best guess
6104 currently for W2K SP2. The password field is encrypted in a different
6105 way than normal... And there are definately other problems. JRA.
6106********************************************************************/
6107
6108static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth)
6109{
6110 if (usr == NULL)
6111 return False;
6112
6113 prs_debug(ps, depth, desc, "sam_io_user_info25");
6114 depth++;
6115
6116 if(!prs_align(ps))
6117 return False;
6118
6119 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6120 return False;
6121 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6122 return False;
6123 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6124 return False;
6125 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth))
6126 return False;
6127 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth))
6128 return False;
6129 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6130 return False;
6131
6132 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6133 return False;
6134 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6135 return False;
6136 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6137 return False;
6138 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6139 return False;
6140 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6141 return False;
6142 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6143 return False;
6144 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6145 return False;
6146 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6147 return False;
6148 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6149 return False;
6150 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6151 return False;
6152
6153 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6154 return False;
6155 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6156 return False;
6157
6158 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6159 return False;
6160 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6161 return False;
6162 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6163 return False;
6164 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6165 return False;
6166
6167 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6168 return False;
6169 if(!prs_align(ps))
6170 return False;
6171 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6172 return False;
6173
6174 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6175 return False;
6176 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6177 return False;
6178
6179 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6180 return False;
6181 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6182 return False;
6183 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6184 return False;
6185
6186
6187 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
6188 return False;
6189
6190 /* here begins pointed-to data */
6191
6192 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
6193 return False;
6194
6195 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
6196 return False;
6197
6198 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
6199 return False;
6200
6201 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
6202 return False;
6203
6204 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
6205 return False;
6206
6207 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
6208 return False;
6209
6210 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */
6211 return False;
6212
6213 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */
6214 return False;
6215
6216 if(!smb_io_unistr2("uni_comment ", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth)) /* unknown string */
6217 return False;
6218
6219 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth))
6220 return False;
6221
6222 /* ok, this is only guess-work (as usual) */
6223 if (usr->ptr_logon_hrs) {
6224 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6225 return False;
6226 }
6227
6228 return True;
6229}
6230
6231
6232/*************************************************************************
6233 init_sam_user_info21W
6234
6235 unknown_6 = 0x0000 04ec
6236
6237 *************************************************************************/
6238
6239void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
6240 NTTIME * logon_time,
6241 NTTIME * logoff_time,
6242 NTTIME * kickoff_time,
6243 NTTIME * pass_last_set_time,
6244 NTTIME * pass_can_change_time,
6245 NTTIME * pass_must_change_time,
6246 UNISTR2 *user_name,
6247 UNISTR2 *full_name,
6248 UNISTR2 *home_dir,
6249 UNISTR2 *dir_drive,
6250 UNISTR2 *log_scr,
6251 UNISTR2 *prof_path,
6252 UNISTR2 *desc,
6253 UNISTR2 *wkstas,
6254 UNISTR2 *unk_str,
6255 UNISTR2 *mung_dial,
6256 uchar lm_pwd[16],
6257 uchar nt_pwd[16],
6258 uint32 user_rid,
6259 uint32 group_rid,
6260 uint32 acb_info,
6261 uint32 fields_present,
6262 uint16 logon_divs,
6263 LOGON_HRS * hrs,
6264 uint16 bad_password_count,
6265 uint16 logon_count)
6266{
6267 usr->logon_time = *logon_time;
6268 usr->logoff_time = *logoff_time;
6269 usr->kickoff_time = *kickoff_time;
6270 usr->pass_last_set_time = *pass_last_set_time;
6271 usr->pass_can_change_time = *pass_can_change_time;
6272 usr->pass_must_change_time = *pass_must_change_time;
6273
6274 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
6275 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
6276
6277 usr->user_rid = user_rid;
6278 usr->group_rid = group_rid;
6279 usr->acb_info = acb_info;
6280 usr->fields_present = fields_present; /* 0x00ff ffff */
6281
6282 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
6283 usr->ptr_logon_hrs = hrs ? 1 : 0;
6284 usr->bad_password_count = bad_password_count;
6285 usr->logon_count = logon_count;
6286
6287 if (nt_time_is_zero(pass_must_change_time)) {
6288 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6289 } else {
6290 usr->passmustchange=0;
6291 }
6292
6293 ZERO_STRUCT(usr->padding1);
6294 ZERO_STRUCT(usr->padding2);
6295
6296 copy_unistr2(&usr->uni_user_name, user_name);
6297 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6298
6299 copy_unistr2(&usr->uni_full_name, full_name);
6300 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6301
6302 copy_unistr2(&usr->uni_home_dir, home_dir);
6303 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6304
6305 copy_unistr2(&usr->uni_dir_drive, dir_drive);
6306 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6307
6308 copy_unistr2(&usr->uni_logon_script, log_scr);
6309 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6310
6311 copy_unistr2(&usr->uni_profile_path, prof_path);
6312 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6313
6314 copy_unistr2(&usr->uni_acct_desc, desc);
6315 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6316
6317 copy_unistr2(&usr->uni_workstations, wkstas);
6318 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6319
6320 copy_unistr2(&usr->uni_comment, unk_str);
6321 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6322
6323 copy_unistr2(&usr->uni_munged_dial, mung_dial);
6324 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6325
6326 if (hrs) {
6327 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs));
6328 } else {
6329 ZERO_STRUCT(usr->logon_hrs);
6330 }
6331}
6332
6333/*************************************************************************
6334 init_sam_user_info21
6335
6336 unknown_6 = 0x0000 04ec
6337
6338 *************************************************************************/
6339
6340NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, struct samu *pw, DOM_SID *domain_sid)
6341{
6342 NTTIME logon_time, logoff_time, kickoff_time,
6343 pass_last_set_time, pass_can_change_time,
6344 pass_must_change_time;
6345
6346 time_t must_change_time;
6347 const char* user_name = pdb_get_username(pw);
6348 const char* full_name = pdb_get_fullname(pw);
6349 const char* home_dir = pdb_get_homedir(pw);
6350 const char* dir_drive = pdb_get_dir_drive(pw);
6351 const char* logon_script = pdb_get_logon_script(pw);
6352 const char* profile_path = pdb_get_profile_path(pw);
6353 const char* description = pdb_get_acct_desc(pw);
6354 const char* workstations = pdb_get_workstations(pw);
6355 const char* munged_dial = pdb_get_munged_dial(pw);
6356 DATA_BLOB munged_dial_blob;
6357
6358 uint32 user_rid;
6359 const DOM_SID *user_sid;
6360
6361 uint32 group_rid;
6362 const DOM_SID *group_sid;
6363
6364 if (munged_dial) {
6365 munged_dial_blob = base64_decode_data_blob(munged_dial);
6366 } else {
6367 munged_dial_blob = data_blob(NULL, 0);
6368 }
6369
6370 /* Create NTTIME structs */
6371 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
6372 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
6373 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw));
6374 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw));
6375 unix_to_nt_time (&pass_can_change_time,pdb_get_pass_can_change_time(pw));
6376 must_change_time = pdb_get_pass_must_change_time(pw);
6377 if (must_change_time == get_time_t_max())
6378 unix_to_nt_time_abs(&pass_must_change_time, must_change_time);
6379 else
6380 unix_to_nt_time(&pass_must_change_time, must_change_time);
6381
6382 /* structure assignment */
6383 usr->logon_time = logon_time;
6384 usr->logoff_time = logoff_time;
6385 usr->kickoff_time = kickoff_time;
6386 usr->pass_last_set_time = pass_last_set_time;
6387 usr->pass_can_change_time = pass_can_change_time;
6388 usr->pass_must_change_time = pass_must_change_time;
6389
6390 ZERO_STRUCT(usr->nt_pwd);
6391 ZERO_STRUCT(usr->lm_pwd);
6392
6393 user_sid = pdb_get_user_sid(pw);
6394
6395 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) {
6396 fstring user_sid_string;
6397 fstring domain_sid_string;
6398 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6399 "the domain sid %s. Failing operation.\n",
6400 user_name,
6401 sid_to_string(user_sid_string, user_sid),
6402 sid_to_string(domain_sid_string, domain_sid)));
6403 data_blob_free(&munged_dial_blob);
6404 return NT_STATUS_UNSUCCESSFUL;
6405 }
6406
6407 become_root();
6408 group_sid = pdb_get_group_sid(pw);
6409 unbecome_root();
6410
6411 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) {
6412 fstring group_sid_string;
6413 fstring domain_sid_string;
6414 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6415 "which conflicts with the domain sid %s. Failing operation.\n",
6416 user_name,
6417 sid_to_string(group_sid_string, group_sid),
6418 sid_to_string(domain_sid_string, domain_sid)));
6419 data_blob_free(&munged_dial_blob);
6420 return NT_STATUS_UNSUCCESSFUL;
6421 }
6422
6423 usr->user_rid = user_rid;
6424 usr->group_rid = group_rid;
6425 usr->acb_info = pdb_get_acct_ctrl(pw);
6426
6427 /*
6428 Look at a user on a real NT4 PDC with usrmgr, press
6429 'ok'. Then you will see that fields_present is set to
6430 0x08f827fa. Look at the user immediately after that again,
6431 and you will see that 0x00fffff is returned. This solves
6432 the problem that you get access denied after having looked
6433 at the user.
6434 -- Volker
6435 */
6436 usr->fields_present = pdb_build_fields_present(pw);
6437
6438 usr->logon_divs = pdb_get_logon_divs(pw);
6439 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
6440 usr->bad_password_count = pdb_get_bad_password_count(pw);
6441 usr->logon_count = pdb_get_logon_count(pw);
6442
6443 if (pdb_get_pass_must_change_time(pw) == 0) {
6444 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
6445 } else {
6446 usr->passmustchange=0;
6447 }
6448
6449 ZERO_STRUCT(usr->padding1);
6450 ZERO_STRUCT(usr->padding2);
6451
6452 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
6453 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
6454
6455 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
6456 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
6457
6458 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
6459 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
6460
6461 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
6462 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
6463
6464 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
6465 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
6466
6467 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
6468 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
6469
6470 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
6471 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
6472
6473 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
6474 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
6475
6476 init_unistr2(&usr->uni_comment, NULL, UNI_STR_TERMINATE);
6477 init_uni_hdr(&usr->hdr_comment, &usr->uni_comment);
6478
6479 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob);
6480 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6481 data_blob_free(&munged_dial_blob);
6482
6483 if (pdb_get_hours(pw)) {
6484 usr->logon_hrs.max_len = 1260;
6485 usr->logon_hrs.offset = 0;
6486 usr->logon_hrs.len = pdb_get_hours_len(pw);
6487 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN);
6488 } else {
6489 usr->logon_hrs.max_len = 1260;
6490 usr->logon_hrs.offset = 0;
6491 usr->logon_hrs.len = 0;
6492 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs));
6493 }
6494
6495 return NT_STATUS_OK;
6496}
6497
6498/*******************************************************************
6499reads or writes a structure.
6500********************************************************************/
6501
6502static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
6503 prs_struct *ps, int depth)
6504{
6505 if (usr == NULL)
6506 return False;
6507
6508 prs_debug(ps, depth, desc, "sam_io_user_info21");
6509 depth++;
6510
6511 if(!prs_align(ps))
6512 return False;
6513
6514 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth))
6515 return False;
6516 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth))
6517 return False;
6518 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth))
6519 return False;
6520 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth))
6521 return False;
6522 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth))
6523 return False;
6524 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth))
6525 return False;
6526
6527 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
6528 return False;
6529 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
6530 return False;
6531 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
6532 return False;
6533 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */
6534 return False;
6535 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
6536 return False;
6537 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
6538 return False;
6539 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */
6540 return False;
6541 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */
6542 return False;
6543 if(!smb_io_unihdr("hdr_comment ", &usr->hdr_comment, ps, depth)) /* unknown string */
6544 return False;
6545 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6546 return False;
6547
6548 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd)))
6549 return False;
6550 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd)))
6551 return False;
6552
6553 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */
6554 return False;
6555 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */
6556 return False;
6557 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info))
6558 return False;
6559
6560 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present))
6561 return False;
6562 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */
6563 return False;
6564 if(!prs_align(ps))
6565 return False;
6566 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
6567 return False;
6568
6569 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count))
6570 return False;
6571 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count))
6572 return False;
6573
6574 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
6575 return False;
6576 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
6577 return False;
6578 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
6579 return False;
6580
6581 /* here begins pointed-to data */
6582
6583 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth))
6584 return False;
6585 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth))
6586 return False;
6587 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth))
6588 return False;
6589 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth))
6590 return False;
6591 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth))
6592 return False;
6593 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth))
6594 return False;
6595 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth))
6596 return False;
6597 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth))
6598 return False;
6599 if(!smb_io_unistr2("uni_comment", &usr->uni_comment, usr->hdr_comment.buffer, ps, depth))
6600 return False;
6601 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth))
6602 return False;
6603
6604 /* ok, this is only guess-work (as usual) */
6605 if (usr->ptr_logon_hrs) {
6606 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth))
6607 return False;
6608 }
6609
6610 return True;
6611}
6612
6613void init_sam_user_info20A(SAM_USER_INFO_20 *usr, struct samu *pw)
6614{
6615 const char *munged_dial = pdb_get_munged_dial(pw);
6616 DATA_BLOB blob;
6617
6618 if (munged_dial) {
6619 blob = base64_decode_data_blob(munged_dial);
6620 } else {
6621 blob = data_blob(NULL, 0);
6622 }
6623
6624 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
6625 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
6626 data_blob_free(&blob);
6627}
6628
6629/*******************************************************************
6630reads or writes a structure.
6631********************************************************************/
6632
6633static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr,
6634 prs_struct *ps, int depth)
6635{
6636 if (usr == NULL)
6637 return False;
6638
6639 prs_debug(ps, depth, desc, "sam_io_user_info20");
6640 depth++;
6641
6642 if(!prs_align(ps))
6643 return False;
6644
6645 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */
6646 return False;
6647
6648 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */
6649 return False;
6650
6651 return True;
6652}
6653
6654/*******************************************************************
6655inits a SAM_USERINFO_CTR structure.
6656********************************************************************/
6657
6658NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr,
6659 uint16 switch_value,
6660 SAM_USER_INFO_21 * usr)
6661{
6662 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6663
6664 ctr->switch_value = switch_value;
6665 ctr->info.id = NULL;
6666
6667 switch (switch_value) {
6668 case 16:
6669 ctr->info.id16 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_16);
6670 if (ctr->info.id16 == NULL)
6671 return NT_STATUS_NO_MEMORY;
6672
6673 init_sam_user_info16(ctr->info.id16, usr->acb_info);
6674 break;
6675#if 0
6676/* whoops - got this wrong. i think. or don't understand what's happening. */
6677 case 17:
6678 {
6679 NTTIME expire;
6680 info = (void *)&id11;
6681
6682 expire.low = 0xffffffff;
6683 expire.high = 0x7fffffff;
6684
6685 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_17);
6686 init_sam_user_info11(ctr->info.id17, &expire,
6687 "BROOKFIELDS$", /* name */
6688 0x03ef, /* user rid */
6689 0x201, /* group rid */
6690 0x0080); /* acb info */
6691
6692 break;
6693 }
6694#endif
6695 case 18:
6696 ctr->info.id18 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_18);
6697 if (ctr->info.id18 == NULL)
6698 return NT_STATUS_NO_MEMORY;
6699
6700 init_sam_user_info18(ctr->info.id18, usr->lm_pwd, usr->nt_pwd);
6701 break;
6702 case 21:
6703 {
6704 SAM_USER_INFO_21 *cusr;
6705 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21);
6706 ctr->info.id21 = cusr;
6707 if (ctr->info.id21 == NULL)
6708 return NT_STATUS_NO_MEMORY;
6709 memcpy(cusr, usr, sizeof(*usr));
6710 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd));
6711 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd));
6712 break;
6713 }
6714 default:
6715 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6716 return NT_STATUS_INVALID_INFO_CLASS;
6717 }
6718
6719 return NT_STATUS_OK;
6720}
6721
6722/*******************************************************************
6723inits a SAM_USERINFO_CTR structure.
6724********************************************************************/
6725
6726static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key,
6727 uint16 switch_value, void *info)
6728{
6729 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6730
6731 ctr->switch_value = switch_value;
6732 ctr->info.id = info;
6733
6734 switch (switch_value) {
6735 case 0x18:
6736 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key);
6737 dump_data(100, (char *)sess_key->data, sess_key->length);
6738 dump_data(100, (char *)ctr->info.id24->pass, 516);
6739 break;
6740 case 0x17:
6741 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key);
6742 dump_data(100, (char *)sess_key->data, sess_key->length);
6743 dump_data(100, (char *)ctr->info.id23->pass, 516);
6744 break;
6745 case 0x07:
6746 break;
6747 default:
6748 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value));
6749 }
6750}
6751
6752/*******************************************************************
6753reads or writes a structure.
6754********************************************************************/
6755
6756static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr,
6757 prs_struct *ps, int depth)
6758{
6759 BOOL ret;
6760 SAM_USERINFO_CTR *ctr;
6761
6762 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr");
6763 depth++;
6764
6765 if (UNMARSHALLING(ps)) {
6766 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1);
6767 if (ctr == NULL)
6768 return False;
6769 *ppctr = ctr;
6770 } else {
6771 ctr = *ppctr;
6772 }
6773
6774 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6775
6776 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value))
6777 return False;
6778 if(!prs_align(ps))
6779 return False;
6780
6781 ret = False;
6782
6783 switch (ctr->switch_value) {
6784 case 7:
6785 if (UNMARSHALLING(ps))
6786 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1);
6787 if (ctr->info.id7 == NULL) {
6788 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6789 return False;
6790 }
6791 ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
6792 break;
6793 case 9:
6794 if (UNMARSHALLING(ps))
6795 ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
6796 if (ctr->info.id9 == NULL) {
6797 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6798 return False;
6799 }
6800 ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
6801 break;
6802 case 16:
6803 if (UNMARSHALLING(ps))
6804 ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);
6805 if (ctr->info.id16 == NULL) {
6806 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6807 return False;
6808 }
6809 ret = sam_io_user_info16("", ctr->info.id16, ps, depth);
6810 break;
6811 case 17:
6812 if (UNMARSHALLING(ps))
6813 ctr->info.id17 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_17,1);
6814
6815 if (ctr->info.id17 == NULL) {
6816 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6817 return False;
6818 }
6819 ret = sam_io_user_info17("", ctr->info.id17, ps, depth);
6820 break;
6821 case 18:
6822 if (UNMARSHALLING(ps))
6823 ctr->info.id18 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_18,1);
6824
6825 if (ctr->info.id18 == NULL) {
6826 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6827 return False;
6828 }
6829 ret = sam_io_user_info18("", ctr->info.id18, ps, depth);
6830 break;
6831 case 20:
6832 if (UNMARSHALLING(ps))
6833 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1);
6834
6835 if (ctr->info.id20 == NULL) {
6836 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6837 return False;
6838 }
6839 ret = sam_io_user_info20("", ctr->info.id20, ps, depth);
6840 break;
6841 case 21:
6842 if (UNMARSHALLING(ps))
6843 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1);
6844
6845 if (ctr->info.id21 == NULL) {
6846 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6847 return False;
6848 }
6849 ret = sam_io_user_info21("", ctr->info.id21, ps, depth);
6850 break;
6851 case 23:
6852 if (UNMARSHALLING(ps))
6853 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1);
6854
6855 if (ctr->info.id23 == NULL) {
6856 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6857 return False;
6858 }
6859 ret = sam_io_user_info23("", ctr->info.id23, ps, depth);
6860 break;
6861 case 24:
6862 if (UNMARSHALLING(ps))
6863 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1);
6864
6865 if (ctr->info.id24 == NULL) {
6866 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6867 return False;
6868 }
6869 ret = sam_io_user_info24("", ctr->info.id24, ps, depth);
6870 break;
6871 case 25:
6872 if (UNMARSHALLING(ps))
6873 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1);
6874
6875 if (ctr->info.id25 == NULL) {
6876 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6877 return False;
6878 }
6879 ret = sam_io_user_info25("", ctr->info.id25, ps, depth);
6880 break;
6881 case 26:
6882 if (UNMARSHALLING(ps))
6883 ctr->info.id26 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_26,1);
6884
6885 if (ctr->info.id26 == NULL) {
6886 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6887 return False;
6888 }
6889 ret = sam_io_user_info26("", ctr->info.id26, ps, depth);
6890 break;
6891 default:
6892 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value));
6893 ret = False;
6894 break;
6895 }
6896
6897 return ret;
6898}
6899
6900/*******************************************************************
6901inits a SAMR_R_QUERY_USERINFO structure.
6902********************************************************************/
6903
6904void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u,
6905 SAM_USERINFO_CTR * ctr, NTSTATUS status)
6906{
6907 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6908
6909 r_u->ptr = 0;
6910 r_u->ctr = NULL;
6911
6912 if (NT_STATUS_IS_OK(status)) {
6913 r_u->ptr = 1;
6914 r_u->ctr = ctr;
6915 }
6916
6917 r_u->status = status; /* return status */
6918}
6919
6920/*******************************************************************
6921reads or writes a structure.
6922********************************************************************/
6923
6924BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u,
6925 prs_struct *ps, int depth)
6926{
6927 if (r_u == NULL)
6928 return False;
6929
6930 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo");
6931 depth++;
6932
6933 if(!prs_align(ps))
6934 return False;
6935
6936 if(!prs_uint32("ptr", ps, depth, &r_u->ptr))
6937 return False;
6938
6939 if (r_u->ptr != 0) {
6940 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth))
6941 return False;
6942 }
6943
6944 if(!prs_align(ps))
6945 return False;
6946 if(!prs_ntstatus("status", ps, depth, &r_u->status))
6947 return False;
6948
6949 return True;
6950}
6951
6952/*******************************************************************
6953inits a SAMR_Q_SET_USERINFO structure.
6954********************************************************************/
6955
6956void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u,
6957 const POLICY_HND *hnd, DATA_BLOB *sess_key,
6958 uint16 switch_value, void *info)
6959{
6960 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6961
6962 q_u->pol = *hnd;
6963 q_u->switch_value = switch_value;
6964 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info);
6965}
6966
6967/*******************************************************************
6968reads or writes a structure.
6969********************************************************************/
6970
6971BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u,
6972 prs_struct *ps, int depth)
6973{
6974 if (q_u == NULL)
6975 return False;
6976
6977 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo");
6978 depth++;
6979
6980 if(!prs_align(ps))
6981 return False;
6982
6983 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth);
6984
6985 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
6986 return False;
6987 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
6988 return False;
6989
6990 return True;
6991}
6992
6993/*******************************************************************
6994inits a SAMR_R_SET_USERINFO structure.
6995********************************************************************/
6996
6997void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status)
6998{
6999 DEBUG(5, ("init_samr_r_set_userinfo\n"));
7000
7001 r_u->status = status; /* return status */
7002}
7003
7004/*******************************************************************
7005reads or writes a structure.
7006********************************************************************/
7007
7008BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u,
7009 prs_struct *ps, int depth)
7010{
7011 if (r_u == NULL)
7012 return False;
7013
7014 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo");
7015 depth++;
7016
7017 if(!prs_align(ps))
7018 return False;
7019
7020 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7021 return False;
7022
7023 return True;
7024}
7025
7026/*******************************************************************
7027inits a SAMR_Q_SET_USERINFO2 structure.
7028********************************************************************/
7029
7030void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u,
7031 const POLICY_HND *hnd, DATA_BLOB *sess_key,
7032 uint16 switch_value, SAM_USERINFO_CTR * ctr)
7033{
7034 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
7035
7036 q_u->pol = *hnd;
7037 q_u->switch_value = switch_value;
7038 q_u->ctr = ctr;
7039
7040 q_u->ctr->switch_value = switch_value;
7041
7042 switch (switch_value) {
7043 case 18:
7044 SamOEMhashBlob(ctr->info.id18->lm_pwd, 16, sess_key);
7045 SamOEMhashBlob(ctr->info.id18->nt_pwd, 16, sess_key);
7046 dump_data(100, (char *)sess_key->data, sess_key->length);
7047 dump_data(100, (char *)ctr->info.id18->lm_pwd, 16);
7048 dump_data(100, (char *)ctr->info.id18->nt_pwd, 16);
7049 break;
7050 }
7051}
7052
7053/*******************************************************************
7054reads or writes a structure.
7055********************************************************************/
7056
7057BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u,
7058 prs_struct *ps, int depth)
7059{
7060 if (q_u == NULL)
7061 return False;
7062
7063 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2");
7064 depth++;
7065
7066 if(!prs_align(ps))
7067 return False;
7068
7069 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth))
7070 return False;
7071
7072 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7073 return False;
7074 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth))
7075 return False;
7076
7077 return True;
7078}
7079
7080/*******************************************************************
7081inits a SAMR_R_SET_USERINFO2 structure.
7082********************************************************************/
7083
7084void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status)
7085{
7086 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
7087
7088 r_u->status = status; /* return status */
7089}
7090
7091/*******************************************************************
7092reads or writes a structure.
7093********************************************************************/
7094
7095BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u,
7096 prs_struct *ps, int depth)
7097{
7098 if (r_u == NULL)
7099 return False;
7100
7101 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2");
7102 depth++;
7103
7104 if(!prs_align(ps))
7105 return False;
7106
7107 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7108 return False;
7109
7110 return True;
7111}
7112
7113/*******************************************************************
7114inits a SAMR_Q_CONNECT structure.
7115********************************************************************/
7116
7117void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
7118 char *srv_name, uint32 access_mask)
7119{
7120 DEBUG(5, ("init_samr_q_connect\n"));
7121
7122 /* make PDC server name \\server */
7123 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7124 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7125
7126 /* example values: 0x0000 0002 */
7127 q_u->access_mask = access_mask;
7128}
7129
7130/*******************************************************************
7131reads or writes a structure.
7132********************************************************************/
7133
7134BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u,
7135 prs_struct *ps, int depth)
7136{
7137 if (q_u == NULL)
7138 return False;
7139
7140 prs_debug(ps, depth, desc, "samr_io_q_connect");
7141 depth++;
7142
7143 if(!prs_align(ps))
7144 return False;
7145
7146 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7147 return False;
7148 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7149 return False;
7150
7151 if(!prs_align(ps))
7152 return False;
7153 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7154 return False;
7155
7156 return True;
7157}
7158
7159/*******************************************************************
7160reads or writes a structure.
7161********************************************************************/
7162
7163BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u,
7164 prs_struct *ps, int depth)
7165{
7166 if (r_u == NULL)
7167 return False;
7168
7169 prs_debug(ps, depth, desc, "samr_io_r_connect");
7170 depth++;
7171
7172 if(!prs_align(ps))
7173 return False;
7174
7175 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7176 return False;
7177
7178 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7179 return False;
7180
7181 return True;
7182}
7183
7184/*******************************************************************
7185inits a SAMR_Q_CONNECT4 structure.
7186********************************************************************/
7187
7188void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
7189 char *srv_name, uint32 access_mask)
7190{
7191 DEBUG(5, ("init_samr_q_connect4\n"));
7192
7193 /* make PDC server name \\server */
7194 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7195 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7196
7197 /* Only value we've seen, possibly an address type ? */
7198 q_u->unk_0 = 2;
7199
7200 /* example values: 0x0000 0002 */
7201 q_u->access_mask = access_mask;
7202}
7203
7204/*******************************************************************
7205reads or writes a structure.
7206********************************************************************/
7207
7208BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u,
7209 prs_struct *ps, int depth)
7210{
7211 if (q_u == NULL)
7212 return False;
7213
7214 prs_debug(ps, depth, desc, "samr_io_q_connect4");
7215 depth++;
7216
7217 if(!prs_align(ps))
7218 return False;
7219
7220 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7221 return False;
7222 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7223 return False;
7224
7225 if(!prs_align(ps))
7226 return False;
7227 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0))
7228 return False;
7229 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7230 return False;
7231
7232 return True;
7233}
7234
7235/*******************************************************************
7236reads or writes a structure.
7237********************************************************************/
7238
7239BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u,
7240 prs_struct *ps, int depth)
7241{
7242 if (r_u == NULL)
7243 return False;
7244
7245 prs_debug(ps, depth, desc, "samr_io_r_connect4");
7246 depth++;
7247
7248 if(!prs_align(ps))
7249 return False;
7250
7251 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7252 return False;
7253
7254 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7255 return False;
7256
7257 return True;
7258}
7259
7260/*******************************************************************
7261inits a SAMR_Q_CONNECT5 structure.
7262********************************************************************/
7263
7264void init_samr_q_connect5(SAMR_Q_CONNECT5 * q_u,
7265 char *srv_name, uint32 access_mask)
7266{
7267 DEBUG(5, ("init_samr_q_connect5\n"));
7268
7269 /* make PDC server name \\server */
7270 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
7271 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
7272
7273 /* example values: 0x0000 0002 */
7274 q_u->access_mask = access_mask;
7275
7276 q_u->level = 1;
7277 q_u->info1_unk1 = 3;
7278 q_u->info1_unk2 = 0;
7279}
7280
7281/*******************************************************************
7282inits a SAMR_R_CONNECT5 structure.
7283********************************************************************/
7284
7285void init_samr_r_connect5(SAMR_R_CONNECT5 * r_u, POLICY_HND *pol, NTSTATUS status)
7286{
7287 DEBUG(5, ("init_samr_q_connect5\n"));
7288
7289 r_u->level = 1;
7290 r_u->info1_unk1 = 3;
7291 r_u->info1_unk2 = 0;
7292
7293 r_u->connect_pol = *pol;
7294 r_u->status = status;
7295}
7296
7297/*******************************************************************
7298reads or writes a structure.
7299********************************************************************/
7300
7301BOOL samr_io_q_connect5(const char *desc, SAMR_Q_CONNECT5 * q_u,
7302 prs_struct *ps, int depth)
7303{
7304 if (q_u == NULL)
7305 return False;
7306
7307 prs_debug(ps, depth, desc, "samr_io_q_connect5");
7308 depth++;
7309
7310 if(!prs_align(ps))
7311 return False;
7312
7313 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name))
7314 return False;
7315 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth))
7316 return False;
7317
7318 if(!prs_align(ps))
7319 return False;
7320 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7321 return False;
7322
7323 if(!prs_uint32("level", ps, depth, &q_u->level))
7324 return False;
7325 if(!prs_uint32("level", ps, depth, &q_u->level))
7326 return False;
7327
7328 if(!prs_uint32("info1_unk1", ps, depth, &q_u->info1_unk1))
7329 return False;
7330 if(!prs_uint32("info1_unk2", ps, depth, &q_u->info1_unk2))
7331 return False;
7332
7333 return True;
7334}
7335
7336/*******************************************************************
7337reads or writes a structure.
7338********************************************************************/
7339
7340BOOL samr_io_r_connect5(const char *desc, SAMR_R_CONNECT5 * r_u,
7341 prs_struct *ps, int depth)
7342{
7343 if (r_u == NULL)
7344 return False;
7345
7346 prs_debug(ps, depth, desc, "samr_io_r_connect5");
7347 depth++;
7348
7349 if(!prs_align(ps))
7350 return False;
7351
7352 if(!prs_uint32("level", ps, depth, &r_u->level))
7353 return False;
7354 if(!prs_uint32("level", ps, depth, &r_u->level))
7355 return False;
7356 if(!prs_uint32("info1_unk1", ps, depth, &r_u->info1_unk1))
7357 return False;
7358 if(!prs_uint32("info1_unk2", ps, depth, &r_u->info1_unk2))
7359 return False;
7360
7361 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7362 return False;
7363
7364 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7365 return False;
7366
7367 return True;
7368}
7369
7370/*******************************************************************
7371inits a SAMR_Q_CONNECT_ANON structure.
7372********************************************************************/
7373
7374void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u)
7375{
7376 DEBUG(5, ("init_samr_q_connect_anon\n"));
7377
7378 q_u->ptr = 1;
7379 q_u->unknown_0 = 0x5c; /* server name (?!!) */
7380 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS;
7381}
7382
7383/*******************************************************************
7384reads or writes a structure.
7385********************************************************************/
7386
7387BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u,
7388 prs_struct *ps, int depth)
7389{
7390 if (q_u == NULL)
7391 return False;
7392
7393 prs_debug(ps, depth, desc, "samr_io_q_connect_anon");
7394 depth++;
7395
7396 if(!prs_align(ps))
7397 return False;
7398
7399 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr))
7400 return False;
7401 if (q_u->ptr) {
7402 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0))
7403 return False;
7404 }
7405 if(!prs_align(ps))
7406 return False;
7407 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask))
7408 return False;
7409
7410 return True;
7411}
7412
7413/*******************************************************************
7414reads or writes a structure.
7415********************************************************************/
7416
7417BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u,
7418 prs_struct *ps, int depth)
7419{
7420 if (r_u == NULL)
7421 return False;
7422
7423 prs_debug(ps, depth, desc, "samr_io_r_connect_anon");
7424 depth++;
7425
7426 if(!prs_align(ps))
7427 return False;
7428
7429 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth))
7430 return False;
7431
7432 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7433 return False;
7434
7435 return True;
7436}
7437
7438/*******************************************************************
7439inits a SAMR_Q_GET_DOM_PWINFO structure.
7440********************************************************************/
7441
7442void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
7443 char *srv_name)
7444{
7445 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7446
7447 q_u->ptr = 1;
7448 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
7449 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
7450}
7451
7452/*******************************************************************
7453reads or writes a structure.
7454********************************************************************/
7455
7456BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u,
7457 prs_struct *ps, int depth)
7458{
7459 if (q_u == NULL)
7460 return False;
7461
7462 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo");
7463 depth++;
7464
7465 if(!prs_align(ps))
7466 return False;
7467
7468 if(!prs_uint32("ptr", ps, depth, &q_u->ptr))
7469 return False;
7470 if (q_u->ptr != 0) {
7471 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth))
7472 return False;
7473 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth))
7474 return False;
7475 }
7476
7477 return True;
7478}
7479
7480/*******************************************************************
7481reads or writes a structure.
7482********************************************************************/
7483
7484BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u,
7485 prs_struct *ps, int depth)
7486{
7487 if (r_u == NULL)
7488 return False;
7489
7490 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo");
7491 depth++;
7492
7493 if(!prs_align(ps))
7494 return False;
7495
7496 if(!prs_uint16("min_pwd_length", ps, depth, &r_u->min_pwd_length))
7497 return False;
7498 if(!prs_align(ps))
7499 return False;
7500 if(!prs_uint32("password_properties", ps, depth, &r_u->password_properties))
7501 return False;
7502
7503 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7504 return False;
7505
7506 return True;
7507}
7508
7509/*******************************************************************
7510make a SAMR_ENC_PASSWD structure.
7511********************************************************************/
7512
7513void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512])
7514{
7515 ZERO_STRUCTP(pwd);
7516
7517 if (pass == NULL) {
7518 pwd->ptr = 0;
7519 } else {
7520 pwd->ptr = 1;
7521 memcpy(pwd->pass, pass, sizeof(pwd->pass));
7522 }
7523}
7524
7525/*******************************************************************
7526reads or writes a SAMR_ENC_PASSWD structure.
7527********************************************************************/
7528
7529BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd,
7530 prs_struct *ps, int depth)
7531{
7532 if (pwd == NULL)
7533 return False;
7534
7535 prs_debug(ps, depth, desc, "samr_io_enc_passwd");
7536 depth++;
7537
7538 if(!prs_align(ps))
7539 return False;
7540
7541 if(!prs_uint32("ptr", ps, depth, &pwd->ptr))
7542 return False;
7543
7544 if (pwd->ptr != 0) {
7545 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass)))
7546 return False;
7547 }
7548
7549 return True;
7550}
7551
7552/*******************************************************************
7553inits a SAMR_ENC_HASH structure.
7554********************************************************************/
7555
7556void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16])
7557{
7558 ZERO_STRUCTP(hsh);
7559
7560 if (hash == NULL) {
7561 hsh->ptr = 0;
7562 } else {
7563 hsh->ptr = 1;
7564 memcpy(hsh->hash, hash, sizeof(hsh->hash));
7565 }
7566}
7567
7568/*******************************************************************
7569reads or writes a SAMR_ENC_HASH structure.
7570********************************************************************/
7571
7572BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh,
7573 prs_struct *ps, int depth)
7574{
7575 if (hsh == NULL)
7576 return False;
7577
7578 prs_debug(ps, depth, desc, "samr_io_enc_hash");
7579 depth++;
7580
7581 if(!prs_align(ps))
7582 return False;
7583
7584 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr))
7585 return False;
7586 if (hsh->ptr != 0) {
7587 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash)))
7588 return False;
7589 }
7590
7591 return True;
7592}
7593
7594/*******************************************************************
7595inits a SAMR_Q_CHGPASSWD_USER structure.
7596********************************************************************/
7597
7598void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
7599 const char *dest_host, const char *user_name,
7600 const uchar nt_newpass[516],
7601 const uchar nt_oldhash[16],
7602 const uchar lm_newpass[516],
7603 const uchar lm_oldhash[16])
7604{
7605 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7606
7607 q_u->ptr_0 = 1;
7608 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7609 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7610
7611 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7612 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7613
7614 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7615 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7616
7617 q_u->unknown = 0x01;
7618
7619 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7620 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7621}
7622
7623/*******************************************************************
7624reads or writes a structure.
7625********************************************************************/
7626
7627BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u,
7628 prs_struct *ps, int depth)
7629{
7630 if (q_u == NULL)
7631 return False;
7632
7633 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user");
7634 depth++;
7635
7636 if(!prs_align(ps))
7637 return False;
7638
7639 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7640 return False;
7641
7642 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7643 return False;
7644 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7645 return False;
7646
7647 if(!prs_align(ps))
7648 return False;
7649 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7650 return False;
7651 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7652 return False;
7653
7654 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7655 return False;
7656 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7657 return False;
7658
7659 if(!prs_uint32("unknown", ps, depth, &q_u->unknown))
7660 return False;
7661
7662 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7663 return False;
7664 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7665 return False;
7666
7667 return True;
7668}
7669
7670/*******************************************************************
7671inits a SAMR_R_CHGPASSWD_USER structure.
7672********************************************************************/
7673
7674void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status)
7675{
7676 DEBUG(5, ("init_samr_r_chgpasswd_user\n"));
7677
7678 r_u->status = status;
7679}
7680
7681/*******************************************************************
7682reads or writes a structure.
7683********************************************************************/
7684
7685BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u,
7686 prs_struct *ps, int depth)
7687{
7688 if (r_u == NULL)
7689 return False;
7690
7691 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user");
7692 depth++;
7693
7694 if(!prs_align(ps))
7695 return False;
7696
7697 if(!prs_ntstatus("status", ps, depth, &r_u->status))
7698 return False;
7699
7700 return True;
7701}
7702
7703/*******************************************************************
7704inits a SAMR_Q_CHGPASSWD3 structure.
7705********************************************************************/
7706
7707void init_samr_q_chgpasswd_user3(SAMR_Q_CHGPASSWD_USER3 * q_u,
7708 const char *dest_host, const char *user_name,
7709 const uchar nt_newpass[516],
7710 const uchar nt_oldhash[16],
7711 const uchar lm_newpass[516],
7712 const uchar lm_oldhash[16])
7713{
7714 DEBUG(5, ("init_samr_q_chgpasswd_user3\n"));
7715
7716 q_u->ptr_0 = 1;
7717 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
7718 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
7719
7720 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
7721 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
7722
7723 init_enc_passwd(&q_u->nt_newpass, (const char *)nt_newpass);
7724 init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
7725
7726 q_u->lm_change = 0x01;
7727
7728 init_enc_passwd(&q_u->lm_newpass, (const char *)lm_newpass);
7729 init_enc_hash(&q_u->lm_oldhash, lm_oldhash);
7730
7731 init_enc_passwd(&q_u->password3, NULL);
7732}
7733
7734/*******************************************************************
7735reads or writes a structure.
7736********************************************************************/
7737
7738BOOL samr_io_q_chgpasswd_user3(const char *desc, SAMR_Q_CHGPASSWD_USER3 * q_u,
7739 prs_struct *ps, int depth)
7740{
7741 if (q_u == NULL)
7742 return False;
7743
7744 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user3");
7745 depth++;
7746
7747 if(!prs_align(ps))
7748 return False;
7749
7750 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0))
7751 return False;
7752
7753 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth))
7754 return False;
7755 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth))
7756 return False;
7757
7758 if(!prs_align(ps))
7759 return False;
7760 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth))
7761 return False;
7762 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth))
7763 return False;
7764
7765 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth))
7766 return False;
7767 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth))
7768 return False;
7769
7770 if(!prs_uint32("lm_change", ps, depth, &q_u->lm_change))
7771 return False;
7772
7773 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth))
7774 return False;
7775 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth))
7776 return False;
7777
7778 if(!samr_io_enc_passwd("password3", &q_u->password3, ps, depth))
7779 return False;
7780
7781 return True;
7782}
7783
7784/*******************************************************************
7785inits a SAMR_R_CHGPASSWD_USER3 structure.
7786********************************************************************/
7787
7788void init_samr_r_chgpasswd_user3(SAMR_R_CHGPASSWD_USER3 *r_u, NTSTATUS status,
7789 SAMR_CHANGE_REJECT *reject, SAM_UNK_INFO_1 *info)
7790{
7791 DEBUG(5, ("init_samr_r_chgpasswd_user3\n"));
7792
7793 r_u->status = status;
7794 r_u->info = 0;
7795 r_u->ptr_info = 0;
7796 r_u->reject = 0;
7797 r_u->ptr_reject = 0;
7798
7799 if (info) {
7800 r_u->info = info;
7801 r_u->ptr_info = 1;
7802 }
7803 if (reject && (reject->reject_reason != Undefined)) {
7804 r_u->reject = reject;
7805 r_u->ptr_reject = 1;
7806 }
7807}
7808
7809/*******************************************************************
7810 Reads or writes an SAMR_CHANGE_REJECT structure.
7811********************************************************************/
7812
7813BOOL samr_io_change_reject(const char *desc, SAMR_CHANGE_REJECT *reject, prs_struct *ps, int depth)
7814{
7815 if (reject == NULL)
7816 return False;
7817
7818 prs_debug(ps, depth, desc, "samr_io_change_reject");
7819 depth++;
7820
7821 if(!prs_align(ps))
7822 return False;
7823
7824 if(UNMARSHALLING(ps))
7825 ZERO_STRUCTP(reject);
7826
7827 if (!prs_uint32("reject_reason", ps, depth, &reject->reject_reason))
7828 return False;
7829
7830 if (!prs_uint32("unknown1", ps, depth, &reject->unknown1))
7831 return False;
7832
7833 if (!prs_uint32("unknown2", ps, depth, &reject->unknown2))
7834 return False;
7835
7836 return True;
7837}
7838
7839/*******************************************************************
7840reads or writes a structure.
7841********************************************************************/
7842
7843BOOL samr_io_r_chgpasswd_user3(const char *desc, SAMR_R_CHGPASSWD_USER3 *r_u,
7844 prs_struct *ps, int depth)
7845{
7846 if (r_u == NULL)
7847 return False;
7848
7849 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user3");
7850 depth++;
7851
7852 if (!prs_align(ps))
7853 return False;
7854
7855 if (!prs_uint32("ptr_info", ps, depth, &r_u->ptr_info))
7856 return False;
7857
7858 /* special case: Windows 2000 can return stub data here saying
7859 NT_STATUS_NOT_SUPPORTED */
7860
7861 if ( NT_STATUS_EQUAL( NT_STATUS_NOT_SUPPORTED, NT_STATUS(r_u->ptr_info)) ) {
7862 r_u->status = NT_STATUS_NOT_SUPPORTED;
7863 return True;
7864 }
7865
7866 if (r_u->ptr_info && r_u->info != NULL) {
7867 /* SAM_UNK_INFO_1 */
7868 if (!sam_io_unk_info1("info", r_u->info, ps, depth))
7869 return False;
7870 }
7871
7872 if (!prs_uint32("ptr_reject", ps, depth, &r_u->ptr_reject))
7873 return False;
7874
7875 if (r_u->ptr_reject && r_u->reject != NULL) {
7876 /* SAMR_CHANGE_REJECT */
7877 if (!samr_io_change_reject("reject", r_u->reject, ps, depth))
7878 return False;
7879 }
7880
7881 if (!prs_ntstatus("status", ps, depth, &r_u->status))
7882 return False;
7883
7884 return True;
7885}
7886
7887/*******************************************************************
7888reads or writes a structure.
7889********************************************************************/
7890
7891void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7892 POLICY_HND *domain_pol, uint16 switch_value)
7893{
7894 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7895
7896 q_u->domain_pol = *domain_pol;
7897 q_u->switch_value = switch_value;
7898}
7899
7900/*******************************************************************
7901reads or writes a structure.
7902********************************************************************/
7903
7904BOOL samr_io_q_query_domain_info2(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u,
7905 prs_struct *ps, int depth)
7906{
7907 if (q_u == NULL)
7908 return False;
7909
7910 prs_debug(ps, depth, desc, "samr_io_q_query_domain_info2");
7911 depth++;
7912
7913 if(!prs_align(ps))
7914 return False;
7915
7916 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
7917 return False;
7918
7919 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
7920 return False;
7921
7922 return True;
7923}
7924
7925/*******************************************************************
7926inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7927********************************************************************/
7928
7929void init_samr_r_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7930 uint16 switch_value, SAM_UNK_CTR * ctr,
7931 NTSTATUS status)
7932{
7933 DEBUG(5, ("init_samr_r_query_domain_info2\n"));
7934
7935 r_u->ptr_0 = 0;
7936 r_u->switch_value = 0;
7937 r_u->status = status; /* return status */
7938
7939 if (NT_STATUS_IS_OK(status)) {
7940 r_u->switch_value = switch_value;
7941 r_u->ptr_0 = 1;
7942 r_u->ctr = ctr;
7943 }
7944}
7945
7946/*******************************************************************
7947reads or writes a structure.
7948********************************************************************/
7949
7950BOOL samr_io_r_query_domain_info2(const char *desc, SAMR_R_QUERY_DOMAIN_INFO2 * r_u,
7951 prs_struct *ps, int depth)
7952{
7953 if (r_u == NULL)
7954 return False;
7955
7956 prs_debug(ps, depth, desc, "samr_io_r_query_domain_info2");
7957 depth++;
7958
7959 if(!prs_align(ps))
7960 return False;
7961
7962 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0))
7963 return False;
7964
7965 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) {
7966 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value))
7967 return False;
7968 if(!prs_align(ps))
7969 return False;
7970
7971 switch (r_u->switch_value) {
7972 case 0x0d:
7973 if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth))
7974 return False;
7975 break;
7976 case 0x0c:
7977 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth))
7978 return False;
7979 break;
7980 case 0x09:
7981 if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth))
7982 return False;
7983 break;
7984 case 0x08:
7985 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth))
7986 return False;
7987 break;
7988 case 0x07:
7989 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth))
7990 return False;
7991 break;
7992 case 0x06:
7993 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth))
7994 return False;
7995 break;
7996 case 0x05:
7997 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth))
7998 return False;
7999 break;
8000 case 0x04:
8001 if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth))
8002 return False;
8003 break;
8004 case 0x03:
8005 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth))
8006 return False;
8007 break;
8008 case 0x02:
8009 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth))
8010 return False;
8011 break;
8012 case 0x01:
8013 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth))
8014 return False;
8015 break;
8016 default:
8017 DEBUG(0, ("samr_io_r_query_domain_info2: unknown switch level 0x%x\n",
8018 r_u->switch_value));
8019 r_u->status = NT_STATUS_INVALID_INFO_CLASS;
8020 return False;
8021 }
8022 }
8023
8024 if(!prs_align(ps))
8025 return False;
8026
8027 if(!prs_ntstatus("status", ps, depth, &r_u->status))
8028 return False;
8029
8030 return True;
8031}
8032
8033
8034/*******************************************************************
8035reads or writes a structure.
8036********************************************************************/
8037
8038void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u,
8039 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr)
8040{
8041 DEBUG(5, ("init_samr_q_set_domain_info\n"));
8042
8043 q_u->domain_pol = *domain_pol;
8044 q_u->switch_value0 = switch_value;
8045
8046 q_u->switch_value = switch_value;
8047 q_u->ctr = ctr;
8048
8049}
8050
8051/*******************************************************************
8052reads or writes a structure.
8053********************************************************************/
8054
8055BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u,
8056 prs_struct *ps, int depth)
8057{
8058 if (q_u == NULL)
8059 return False;
8060
8061 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info");
8062 depth++;
8063
8064 if(!prs_align(ps))
8065 return False;
8066
8067 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
8068 return False;
8069
8070 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0))
8071 return False;
8072
8073 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value))
8074 return False;
8075
8076 if(!prs_align(ps))
8077 return False;
8078
8079 if (UNMARSHALLING(ps)) {
8080 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL)
8081 return False;
8082 }
8083
8084 switch (q_u->switch_value) {
8085
8086 case 0x0c:
8087 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth))
8088 return False;
8089 break;
8090 case 0x07:
8091 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth))
8092 return False;
8093 break;
8094 case 0x06:
8095 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth))
8096 return False;
8097 break;
8098 case 0x05:
8099 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth))
8100 return False;
8101 break;
8102 case 0x03:
8103 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth))
8104 return False;
8105 break;
8106 case 0x02:
8107 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth))
8108 return False;
8109 break;
8110 case 0x01:
8111 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth))
8112 return False;
8113 break;
8114 default:
8115 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
8116 q_u->switch_value));
8117 return False;
8118 }
8119
8120 return True;
8121}
8122
8123/*******************************************************************
8124inits a SAMR_R_QUERY_DOMAIN_INFO structure.
8125********************************************************************/
8126
8127void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status)
8128{
8129 DEBUG(5, ("init_samr_r_set_domain_info\n"));
8130
8131 r_u->status = status; /* return status */
8132}
8133
8134/*******************************************************************
8135reads or writes a structure.
8136********************************************************************/
8137
8138BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u,
8139 prs_struct *ps, int depth)
8140{
8141 if (r_u == NULL)
8142 return False;
8143
8144 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e");
8145 depth++;
8146
8147 if(!prs_align(ps))
8148 return False;
8149
8150 if(!prs_ntstatus("status", ps, depth, &r_u->status))
8151 return False;
8152
8153 return True;
8154}
Note: See TracBrowser for help on using the repository browser.