2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-2000,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
6 * Copyright (C) Paul Ashton 1997-2000,
7 * Copyright (C) Elrond 2000,
8 * Copyright (C) Jeremy Allison 2001,
9 * Copyright (C) Jean François Micouleau 1998-2001,
10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #define DBGC_CLASS DBGC_RPC_PARSE
32 /*******************************************************************
33 inits a SAMR_Q_CLOSE_HND structure.
34 ********************************************************************/
36 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND
* q_c
, POLICY_HND
*hnd
)
38 DEBUG(5, ("init_samr_q_close_hnd\n"));
43 /*******************************************************************
44 reads or writes a structure.
45 ********************************************************************/
47 BOOL
samr_io_q_close_hnd(const char *desc
, SAMR_Q_CLOSE_HND
* q_u
,
48 prs_struct
*ps
, int depth
)
53 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
59 return smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
);
62 /*******************************************************************
63 reads or writes a structure.
64 ********************************************************************/
66 BOOL
samr_io_r_close_hnd(const char *desc
, SAMR_R_CLOSE_HND
* r_u
,
67 prs_struct
*ps
, int depth
)
72 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
78 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
81 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
87 /*******************************************************************
88 inits a SAMR_Q_LOOKUP_DOMAIN structure.
89 ********************************************************************/
91 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN
* q_u
,
92 POLICY_HND
*pol
, char *dom_name
)
94 DEBUG(5, ("init_samr_q_lookup_domain\n"));
96 q_u
->connect_pol
= *pol
;
98 init_unistr2(&q_u
->uni_domain
, dom_name
, UNI_FLAGS_NONE
);
99 init_uni_hdr(&q_u
->hdr_domain
, &q_u
->uni_domain
);
102 /*******************************************************************
103 reads or writes a structure.
104 ********************************************************************/
105 BOOL
samr_io_q_lookup_domain(const char *desc
, SAMR_Q_LOOKUP_DOMAIN
* q_u
,
106 prs_struct
*ps
, int depth
)
111 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_domain");
117 if(!smb_io_pol_hnd("connect_pol", &q_u
->connect_pol
, ps
, depth
))
120 if(!smb_io_unihdr("hdr_domain", &q_u
->hdr_domain
, ps
, depth
))
123 if(!smb_io_unistr2("uni_domain", &q_u
->uni_domain
, q_u
->hdr_domain
.buffer
, ps
, depth
))
129 /*******************************************************************
130 inits a SAMR_R_LOOKUP_DOMAIN structure.
131 ********************************************************************/
133 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN
* r_u
,
134 DOM_SID
*dom_sid
, NTSTATUS status
)
136 DEBUG(5, ("init_samr_r_lookup_domain\n"));
138 r_u
->status
= status
;
140 if (NT_STATUS_IS_OK(status
)) {
142 init_dom_sid2(&r_u
->dom_sid
, dom_sid
);
146 /*******************************************************************
147 reads or writes a structure.
148 ********************************************************************/
150 BOOL
samr_io_r_lookup_domain(const char *desc
, SAMR_R_LOOKUP_DOMAIN
* r_u
,
151 prs_struct
*ps
, int depth
)
156 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_domain");
162 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr_sid
))
165 if (r_u
->ptr_sid
!= 0) {
166 if(!smb_io_dom_sid2("sid", &r_u
->dom_sid
, ps
, depth
))
172 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
178 /*******************************************************************
179 reads or writes a structure.
180 ********************************************************************/
182 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
, POLICY_HND
*dom_pol
, DOM_SID
*sid
)
184 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
186 q_u
->dom_pol
= *dom_pol
;
187 init_dom_sid2(&q_u
->sid
, sid
);
190 /*******************************************************************
191 reads or writes a structure.
192 ********************************************************************/
194 BOOL
samr_io_q_remove_sid_foreign_domain(const char *desc
, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
,
195 prs_struct
*ps
, int depth
)
200 prs_debug(ps
, depth
, desc
, "samr_io_q_remove_sid_foreign_domain");
206 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
209 if(!smb_io_dom_sid2("sid", &q_u
->sid
, ps
, depth
))
218 /*******************************************************************
219 reads or writes a structure.
220 ********************************************************************/
222 BOOL
samr_io_r_remove_sid_foreign_domain(const char *desc
, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN
* r_u
,
223 prs_struct
*ps
, int depth
)
228 prs_debug(ps
, depth
, desc
, "samr_io_r_remove_sid_foreign_domain");
234 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
240 /*******************************************************************
241 reads or writes a structure.
242 ********************************************************************/
244 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
* q_u
,
245 POLICY_HND
*pol
, uint32 flags
,
248 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
252 init_dom_sid2(&q_u
->dom_sid
, sid
);
255 /*******************************************************************
256 reads or writes a structure.
257 ********************************************************************/
259 BOOL
samr_io_q_open_domain(const char *desc
, SAMR_Q_OPEN_DOMAIN
* q_u
,
260 prs_struct
*ps
, int depth
)
265 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
271 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
274 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
277 if(!smb_io_dom_sid2("sid", &q_u
->dom_sid
, ps
, depth
))
283 /*******************************************************************
284 reads or writes a structure.
285 ********************************************************************/
287 BOOL
samr_io_r_open_domain(const char *desc
, SAMR_R_OPEN_DOMAIN
* r_u
,
288 prs_struct
*ps
, int depth
)
293 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
299 if(!smb_io_pol_hnd("domain_pol", &r_u
->domain_pol
, ps
, depth
))
302 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
308 /*******************************************************************
309 reads or writes a structure.
310 ********************************************************************/
312 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
313 POLICY_HND
*user_pol
)
315 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
317 q_u
->user_pol
= *user_pol
;
320 /*******************************************************************
321 reads or writes a structure.
322 ********************************************************************/
324 BOOL
samr_io_q_get_usrdom_pwinfo(const char *desc
, SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
325 prs_struct
*ps
, int depth
)
330 prs_debug(ps
, depth
, desc
, "samr_io_q_get_usrdom_pwinfo");
336 return smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
);
339 /*******************************************************************
341 ********************************************************************/
343 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO
*r_u
, NTSTATUS status
)
345 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
347 r_u
->unknown_0
= 0x0000;
351 * r_u->unknown_1 = 0x0015;
354 r_u
->unknown_1
= 0x01D1;
355 r_u
->unknown_1
= 0x0015;
357 r_u
->unknown_2
= 0x00000000;
359 r_u
->status
= status
;
362 /*******************************************************************
363 reads or writes a structure.
364 ********************************************************************/
366 BOOL
samr_io_r_get_usrdom_pwinfo(const char *desc
, SAMR_R_GET_USRDOM_PWINFO
* r_u
,
367 prs_struct
*ps
, int depth
)
372 prs_debug(ps
, depth
, desc
, "samr_io_r_get_usrdom_pwinfo");
378 if(!prs_uint16("unknown_0", ps
, depth
, &r_u
->unknown_0
))
380 if(!prs_uint16("unknown_1", ps
, depth
, &r_u
->unknown_1
))
382 if(!prs_uint32("unknown_2", ps
, depth
, &r_u
->unknown_2
))
384 if(!prs_ntstatus("status ", ps
, depth
, &r_u
->status
))
391 /*******************************************************************
392 reads or writes a structure.
393 ********************************************************************/
395 BOOL
samr_io_q_set_sec_obj(const char *desc
, SAMR_Q_SET_SEC_OBJ
* q_u
,
396 prs_struct
*ps
, int depth
)
401 prs_debug(ps
, depth
, desc
, "samr_io_q_set_sec_obj");
407 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
410 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
413 if(!sec_io_desc_buf("sec_desc", &q_u
->buf
, ps
, depth
))
420 /*******************************************************************
421 reads or writes a structure.
422 ********************************************************************/
424 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ
* q_u
,
425 POLICY_HND
*user_pol
, uint32 sec_info
)
427 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
429 q_u
->user_pol
= *user_pol
;
430 q_u
->sec_info
= sec_info
;
434 /*******************************************************************
435 reads or writes a structure.
436 ********************************************************************/
438 BOOL
samr_io_q_query_sec_obj(const char *desc
, SAMR_Q_QUERY_SEC_OBJ
* q_u
,
439 prs_struct
*ps
, int depth
)
444 prs_debug(ps
, depth
, desc
, "samr_io_q_query_sec_obj");
450 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
453 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
459 /*******************************************************************
460 reads or writes a structure.
461 ********************************************************************/
463 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
464 POLICY_HND
*domain_pol
, uint16 switch_value
)
466 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
468 q_u
->domain_pol
= *domain_pol
;
469 q_u
->switch_value
= switch_value
;
472 /*******************************************************************
473 reads or writes a structure.
474 ********************************************************************/
476 BOOL
samr_io_q_query_dom_info(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
477 prs_struct
*ps
, int depth
)
482 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dom_info");
488 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
491 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
498 /*******************************************************************
500 ********************************************************************/
502 void init_unk_info3(SAM_UNK_INFO_3
*u_3
, NTTIME nt_logout
)
504 u_3
->logout
.low
= nt_logout
.low
;
505 u_3
->logout
.high
= nt_logout
.high
;
508 /*******************************************************************
509 reads or writes a structure.
510 ********************************************************************/
512 static BOOL
sam_io_unk_info3(const char *desc
, SAM_UNK_INFO_3
* u_3
,
513 prs_struct
*ps
, int depth
)
518 prs_debug(ps
, depth
, desc
, "sam_io_unk_info3");
521 if(!smb_io_time("logout", &u_3
->logout
, ps
, depth
))
527 /*******************************************************************
529 ********************************************************************/
531 void init_unk_info6(SAM_UNK_INFO_6
* u_6
)
533 u_6
->unknown_0
= 0x00000000;
535 memset(u_6
->padding
, 0, sizeof(u_6
->padding
)); /* 12 bytes zeros */
538 /*******************************************************************
539 reads or writes a structure.
540 ********************************************************************/
542 static BOOL
sam_io_unk_info6(const char *desc
, SAM_UNK_INFO_6
* u_6
,
543 prs_struct
*ps
, int depth
)
548 prs_debug(ps
, depth
, desc
, "sam_io_unk_info6");
551 if(!prs_uint32("unknown_0", ps
, depth
, &u_6
->unknown_0
)) /* 0x0000 0000 */
553 if(!prs_uint32("ptr_0", ps
, depth
, &u_6
->ptr_0
)) /* pointer to unknown structure */
555 if(!prs_uint8s(False
, "padding", ps
, depth
, u_6
->padding
, sizeof(u_6
->padding
))) /* 12 bytes zeros */
561 /*******************************************************************
563 ********************************************************************/
565 void init_unk_info7(SAM_UNK_INFO_7
* u_7
, uint32 server_role
)
567 u_7
->server_role
= server_role
;
570 /*******************************************************************
571 reads or writes a structure.
572 ********************************************************************/
574 static BOOL
sam_io_unk_info7(const char *desc
, SAM_UNK_INFO_7
* u_7
,
575 prs_struct
*ps
, int depth
)
580 prs_debug(ps
, depth
, desc
, "sam_io_unk_info7");
583 if(!prs_uint16("server_role", ps
, depth
, &u_7
->server_role
))
589 /*******************************************************************
591 ********************************************************************/
593 void init_unk_info8(SAM_UNK_INFO_8
* u_8
, uint32 seq_num
)
595 unix_to_nt_time(&u_8
->domain_create_time
, 0);
596 u_8
->seq_num
.low
= seq_num
;
597 u_8
->seq_num
.high
= 0x0000;
600 /*******************************************************************
601 reads or writes a structure.
602 ********************************************************************/
604 static BOOL
sam_io_unk_info8(const char *desc
, SAM_UNK_INFO_8
* u_8
,
605 prs_struct
*ps
, int depth
)
610 prs_debug(ps
, depth
, desc
, "sam_io_unk_info8");
613 if (!prs_uint64("seq_num", ps
, depth
, &u_8
->seq_num
))
616 if(!smb_io_time("domain_create_time", &u_8
->domain_create_time
, ps
, depth
))
623 /*******************************************************************
625 ********************************************************************/
627 void init_unk_info12(SAM_UNK_INFO_12
* u_12
, NTTIME nt_lock_duration
, NTTIME nt_reset_time
, uint16 lockout
)
629 u_12
->duration
.low
= nt_lock_duration
.low
;
630 u_12
->duration
.high
= nt_lock_duration
.high
;
631 u_12
->reset_count
.low
= nt_reset_time
.low
;
632 u_12
->reset_count
.high
= nt_reset_time
.high
;
634 u_12
->bad_attempt_lockout
= lockout
;
637 /*******************************************************************
638 reads or writes a structure.
639 ********************************************************************/
641 static BOOL
sam_io_unk_info12(const char *desc
, SAM_UNK_INFO_12
* u_12
,
642 prs_struct
*ps
, int depth
)
647 prs_debug(ps
, depth
, desc
, "sam_io_unk_info12");
650 if(!smb_io_time("duration", &u_12
->duration
, ps
, depth
))
652 if(!smb_io_time("reset_count", &u_12
->reset_count
, ps
, depth
))
654 if(!prs_uint16("bad_attempt_lockout", ps
, depth
, &u_12
->bad_attempt_lockout
))
660 /*******************************************************************
662 ********************************************************************/
664 void init_unk_info5(SAM_UNK_INFO_5
* u_5
,const char *server
)
666 init_unistr2(&u_5
->uni_server
, server
, UNI_FLAGS_NONE
);
667 init_uni_hdr(&u_5
->hdr_server
, &u_5
->uni_server
);
670 /*******************************************************************
671 reads or writes a structure.
672 ********************************************************************/
674 static BOOL
sam_io_unk_info5(const char *desc
, SAM_UNK_INFO_5
* u_5
,
675 prs_struct
*ps
, int depth
)
680 prs_debug(ps
, depth
, desc
, "sam_io_unk_info5");
683 if(!smb_io_unihdr("hdr_server", &u_5
->hdr_server
, ps
, depth
))
686 if(!smb_io_unistr2("uni_server", &u_5
->uni_server
, u_5
->hdr_server
.buffer
, ps
, depth
))
692 /*******************************************************************
694 ********************************************************************/
696 void init_unk_info2(SAM_UNK_INFO_2
* u_2
,
697 const char *comment
, const char *domain
, const char *server
,
698 uint32 seq_num
, uint32 num_users
, uint32 num_groups
, uint32 num_alias
, NTTIME nt_logout
, uint32 server_role
)
700 u_2
->logout
.low
= nt_logout
.low
;
701 u_2
->logout
.high
= nt_logout
.high
;
703 u_2
->seq_num
.low
= seq_num
;
704 u_2
->seq_num
.high
= 0x00000000;
707 u_2
->unknown_4
= 0x00000001;
708 u_2
->server_role
= server_role
;
709 u_2
->unknown_6
= 0x00000001;
710 u_2
->num_domain_usrs
= num_users
;
711 u_2
->num_domain_grps
= num_groups
;
712 u_2
->num_local_grps
= num_alias
;
714 memset(u_2
->padding
, 0, sizeof(u_2
->padding
)); /* 12 bytes zeros */
716 init_unistr2(&u_2
->uni_comment
, comment
, UNI_FLAGS_NONE
);
717 init_uni_hdr(&u_2
->hdr_comment
, &u_2
->uni_comment
);
718 init_unistr2(&u_2
->uni_domain
, domain
, UNI_FLAGS_NONE
);
719 init_uni_hdr(&u_2
->hdr_domain
, &u_2
->uni_domain
);
720 init_unistr2(&u_2
->uni_server
, server
, UNI_FLAGS_NONE
);
721 init_uni_hdr(&u_2
->hdr_server
, &u_2
->uni_server
);
724 /*******************************************************************
725 reads or writes a structure.
726 ********************************************************************/
728 static BOOL
sam_io_unk_info2(const char *desc
, SAM_UNK_INFO_2
* u_2
,
729 prs_struct
*ps
, int depth
)
734 prs_debug(ps
, depth
, desc
, "sam_io_unk_info2");
737 if(!smb_io_time("logout", &u_2
->logout
, ps
, depth
))
739 if(!smb_io_unihdr("hdr_comment", &u_2
->hdr_comment
, ps
, depth
))
741 if(!smb_io_unihdr("hdr_domain", &u_2
->hdr_domain
, ps
, depth
))
743 if(!smb_io_unihdr("hdr_server", &u_2
->hdr_server
, ps
, depth
))
746 /* put all the data in here, at the moment, including what the above
747 pointer is referring to
750 if(!prs_uint64("seq_num ", ps
, depth
, &u_2
->seq_num
))
753 if(!prs_uint32("unknown_4 ", ps
, depth
, &u_2
->unknown_4
)) /* 0x0000 0001 */
755 if(!prs_uint32("server_role ", ps
, depth
, &u_2
->server_role
))
757 if(!prs_uint32("unknown_6 ", ps
, depth
, &u_2
->unknown_6
)) /* 0x0000 0001 */
759 if(!prs_uint32("num_domain_usrs ", ps
, depth
, &u_2
->num_domain_usrs
))
761 if(!prs_uint32("num_domain_grps", ps
, depth
, &u_2
->num_domain_grps
))
763 if(!prs_uint32("num_local_grps", ps
, depth
, &u_2
->num_local_grps
))
766 if(!smb_io_unistr2("uni_comment", &u_2
->uni_comment
, u_2
->hdr_comment
.buffer
, ps
, depth
))
768 if(!smb_io_unistr2("uni_domain", &u_2
->uni_domain
, u_2
->hdr_domain
.buffer
, ps
, depth
))
770 if(!smb_io_unistr2("uni_server", &u_2
->uni_server
, u_2
->hdr_server
.buffer
, ps
, depth
))
776 /*******************************************************************
778 ********************************************************************/
780 void init_unk_info1(SAM_UNK_INFO_1
*u_1
, uint16 min_pass_len
, uint16 pass_hist
,
781 uint32 password_properties
, NTTIME nt_expire
, NTTIME nt_min_age
)
783 u_1
->min_length_password
= min_pass_len
;
784 u_1
->password_history
= pass_hist
;
785 u_1
->password_properties
= password_properties
;
787 /* password never expire */
788 u_1
->expire
.high
= nt_expire
.high
;
789 u_1
->expire
.low
= nt_expire
.low
;
791 /* can change the password now */
792 u_1
->min_passwordage
.high
= nt_min_age
.high
;
793 u_1
->min_passwordage
.low
= nt_min_age
.low
;
797 /*******************************************************************
798 reads or writes a structure.
799 ********************************************************************/
801 static BOOL
sam_io_unk_info1(const char *desc
, SAM_UNK_INFO_1
* u_1
,
802 prs_struct
*ps
, int depth
)
807 prs_debug(ps
, depth
, desc
, "sam_io_unk_info1");
810 if(!prs_uint16("min_length_password", ps
, depth
, &u_1
->min_length_password
))
812 if(!prs_uint16("password_history", ps
, depth
, &u_1
->password_history
))
814 if(!prs_uint32("password_properties", ps
, depth
, &u_1
->password_properties
))
816 if(!smb_io_time("expire", &u_1
->expire
, ps
, depth
))
818 if(!smb_io_time("min_passwordage", &u_1
->min_passwordage
, ps
, depth
))
824 /*******************************************************************
825 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
826 ********************************************************************/
828 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
829 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
832 DEBUG(5, ("init_samr_r_query_dom_info\n"));
835 r_u
->switch_value
= 0;
836 r_u
->status
= status
; /* return status */
838 if (NT_STATUS_IS_OK(status
)) {
839 r_u
->switch_value
= switch_value
;
845 /*******************************************************************
846 reads or writes a structure.
847 ********************************************************************/
849 BOOL
samr_io_r_query_dom_info(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
850 prs_struct
*ps
, int depth
)
855 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dom_info");
861 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
864 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
865 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
870 switch (r_u
->switch_value
) {
872 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
876 if(!sam_io_unk_info8("unk_inf8",&r_u
->ctr
->info
.inf8
, ps
,depth
))
880 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
884 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
888 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
892 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
896 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
900 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
904 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
906 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
914 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
920 /*******************************************************************
921 reads or writes a SAMR_R_SET_SEC_OBJ structure.
922 ********************************************************************/
924 BOOL
samr_io_r_set_sec_obj(const char *desc
, SAMR_R_SET_SEC_OBJ
* r_u
,
925 prs_struct
*ps
, int depth
)
930 prs_debug(ps
, depth
, desc
, "samr_io_r_set_sec_obj");
936 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
942 /*******************************************************************
943 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
944 ********************************************************************/
946 BOOL
samr_io_r_query_sec_obj(const char *desc
, SAMR_R_QUERY_SEC_OBJ
* r_u
,
947 prs_struct
*ps
, int depth
)
952 prs_debug(ps
, depth
, desc
, "samr_io_r_query_sec_obj");
958 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
961 if(!sec_io_desc_buf("sec", &r_u
->buf
, ps
, depth
))
965 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
971 /*******************************************************************
972 reads or writes a SAM_STR1 structure.
973 ********************************************************************/
975 static BOOL
sam_io_sam_str1(const char *desc
, SAM_STR1
* sam
, uint32 acct_buf
,
976 uint32 name_buf
, uint32 desc_buf
,
977 prs_struct
*ps
, int depth
)
982 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
987 if (!smb_io_unistr2("name", &sam
->uni_acct_name
, acct_buf
, ps
, depth
))
990 if (!smb_io_unistr2("desc", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
))
993 if (!smb_io_unistr2("full", &sam
->uni_full_name
, name_buf
, ps
, depth
))
999 /*******************************************************************
1000 inits a SAM_ENTRY1 structure.
1001 ********************************************************************/
1003 static void init_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
1004 UNISTR2
*sam_name
, UNISTR2
*sam_full
,
1005 UNISTR2
*sam_desc
, uint32 rid_user
,
1008 DEBUG(5, ("init_sam_entry1\n"));
1012 sam
->user_idx
= user_idx
;
1013 sam
->rid_user
= rid_user
;
1014 sam
->acb_info
= acb_info
;
1016 init_uni_hdr(&sam
->hdr_acct_name
, sam_name
);
1017 init_uni_hdr(&sam
->hdr_user_name
, sam_full
);
1018 init_uni_hdr(&sam
->hdr_user_desc
, sam_desc
);
1021 /*******************************************************************
1022 reads or writes a SAM_ENTRY1 structure.
1023 ********************************************************************/
1025 static BOOL
sam_io_sam_entry1(const char *desc
, SAM_ENTRY1
* sam
,
1026 prs_struct
*ps
, int depth
)
1031 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
1037 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1040 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1042 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1048 if (!smb_io_unihdr("hdr_acct_name", &sam
->hdr_acct_name
, ps
, depth
))
1050 if (!smb_io_unihdr("hdr_user_desc", &sam
->hdr_user_desc
, ps
, depth
))
1052 if (!smb_io_unihdr("hdr_user_name", &sam
->hdr_user_name
, ps
, depth
))
1058 /*******************************************************************
1059 reads or writes a SAM_STR2 structure.
1060 ********************************************************************/
1062 static BOOL
sam_io_sam_str2(const char *desc
, SAM_STR2
* sam
, uint32 acct_buf
,
1063 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1068 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
1074 if(!smb_io_unistr2("uni_srv_name", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1076 if(!smb_io_unistr2("uni_srv_desc", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1082 /*******************************************************************
1083 inits a SAM_ENTRY2 structure.
1084 ********************************************************************/
1085 static void init_sam_entry2(SAM_ENTRY2
* sam
, uint32 user_idx
,
1086 UNISTR2
*sam_name
, UNISTR2
*sam_desc
,
1087 uint32 rid_user
, uint16 acb_info
)
1089 DEBUG(5, ("init_sam_entry2\n"));
1091 sam
->user_idx
= user_idx
;
1092 sam
->rid_user
= rid_user
;
1093 sam
->acb_info
= acb_info
;
1095 init_uni_hdr(&sam
->hdr_srv_name
, sam_name
);
1096 init_uni_hdr(&sam
->hdr_srv_desc
, sam_desc
);
1099 /*******************************************************************
1100 reads or writes a SAM_ENTRY2 structure.
1101 ********************************************************************/
1103 static BOOL
sam_io_sam_entry2(const char *desc
, SAM_ENTRY2
* sam
,
1104 prs_struct
*ps
, int depth
)
1109 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
1115 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1118 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1120 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1126 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
1128 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
1134 /*******************************************************************
1135 reads or writes a SAM_STR3 structure.
1136 ********************************************************************/
1138 static BOOL
sam_io_sam_str3(const char *desc
, SAM_STR3
* sam
, uint32 acct_buf
,
1139 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1144 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
1150 if(!smb_io_unistr2("uni_grp_name", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1152 if(!smb_io_unistr2("uni_grp_desc", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1158 /*******************************************************************
1159 inits a SAM_ENTRY3 structure.
1160 ********************************************************************/
1162 static void init_sam_entry3(SAM_ENTRY3
* sam
, uint32 grp_idx
,
1163 UNISTR2
*grp_name
, UNISTR2
*grp_desc
,
1166 DEBUG(5, ("init_sam_entry3\n"));
1168 sam
->grp_idx
= grp_idx
;
1169 sam
->rid_grp
= rid_grp
;
1170 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1172 init_uni_hdr(&sam
->hdr_grp_name
, grp_name
);
1173 init_uni_hdr(&sam
->hdr_grp_desc
, grp_desc
);
1176 /*******************************************************************
1177 reads or writes a SAM_ENTRY3 structure.
1178 ********************************************************************/
1180 static BOOL
sam_io_sam_entry3(const char *desc
, SAM_ENTRY3
* sam
,
1181 prs_struct
*ps
, int depth
)
1186 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
1192 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1195 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
1197 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
1200 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
1202 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
1208 /*******************************************************************
1209 inits a SAM_ENTRY4 structure.
1210 ********************************************************************/
1212 static void init_sam_entry4(SAM_ENTRY4
* sam
, uint32 user_idx
,
1213 uint32 len_acct_name
)
1215 DEBUG(5, ("init_sam_entry4\n"));
1217 sam
->user_idx
= user_idx
;
1218 init_str_hdr(&sam
->hdr_acct_name
, len_acct_name
+1, len_acct_name
, len_acct_name
!= 0);
1221 /*******************************************************************
1222 reads or writes a SAM_ENTRY4 structure.
1223 ********************************************************************/
1225 static BOOL
sam_io_sam_entry4(const char *desc
, SAM_ENTRY4
* sam
,
1226 prs_struct
*ps
, int depth
)
1231 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry4");
1237 if(!prs_uint32("user_idx", ps
, depth
, &sam
->user_idx
))
1239 if(!smb_io_strhdr("strhdr", &sam
->hdr_acct_name
, ps
, depth
))
1245 /*******************************************************************
1246 inits a SAM_ENTRY5 structure.
1247 ********************************************************************/
1249 static void init_sam_entry5(SAM_ENTRY5
* sam
, uint32 grp_idx
,
1250 uint32 len_grp_name
)
1252 DEBUG(5, ("init_sam_entry5\n"));
1254 sam
->grp_idx
= grp_idx
;
1255 init_str_hdr(&sam
->hdr_grp_name
, len_grp_name
, len_grp_name
,
1259 /*******************************************************************
1260 reads or writes a SAM_ENTRY5 structure.
1261 ********************************************************************/
1263 static BOOL
sam_io_sam_entry5(const char *desc
, SAM_ENTRY5
* sam
,
1264 prs_struct
*ps
, int depth
)
1269 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry5");
1275 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1277 if(!smb_io_strhdr("strhdr", &sam
->hdr_grp_name
, ps
, depth
))
1283 /*******************************************************************
1284 inits a SAM_ENTRY structure.
1285 ********************************************************************/
1287 void init_sam_entry(SAM_ENTRY
*sam
, UNISTR2
*uni2
, uint32 rid
)
1289 DEBUG(10, ("init_sam_entry: %d\n", rid
));
1292 init_uni_hdr(&sam
->hdr_name
, uni2
);
1295 /*******************************************************************
1296 reads or writes a SAM_ENTRY structure.
1297 ********************************************************************/
1299 static BOOL
sam_io_sam_entry(const char *desc
, SAM_ENTRY
* sam
,
1300 prs_struct
*ps
, int depth
)
1305 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
1310 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
1312 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
1318 /*******************************************************************
1319 inits a SAMR_Q_ENUM_DOM_USERS structure.
1320 ********************************************************************/
1322 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
* q_e
, POLICY_HND
*pol
,
1324 uint16 acb_mask
, uint16 unk_1
, uint32 size
)
1326 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1330 q_e
->start_idx
= start_idx
; /* zero indicates lots */
1331 q_e
->acb_mask
= acb_mask
;
1332 q_e
->unknown_1
= unk_1
;
1333 q_e
->max_size
= size
;
1336 /*******************************************************************
1337 reads or writes a structure.
1338 ********************************************************************/
1340 BOOL
samr_io_q_enum_dom_users(const char *desc
, SAMR_Q_ENUM_DOM_USERS
* q_e
,
1341 prs_struct
*ps
, int depth
)
1346 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
1352 if(!smb_io_pol_hnd("domain_pol", &q_e
->pol
, ps
, depth
))
1355 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1357 if(!prs_uint16("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
1359 if(!prs_uint16("unknown_1", ps
, depth
, &q_e
->unknown_1
))
1362 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1369 /*******************************************************************
1370 inits a SAMR_R_ENUM_DOM_USERS structure.
1371 ********************************************************************/
1373 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
* r_u
,
1374 uint32 next_idx
, uint32 num_sam_entries
)
1376 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1378 r_u
->next_idx
= next_idx
;
1380 if (num_sam_entries
!= 0) {
1381 r_u
->ptr_entries1
= 1;
1382 r_u
->ptr_entries2
= 1;
1383 r_u
->num_entries2
= num_sam_entries
;
1384 r_u
->num_entries3
= num_sam_entries
;
1386 r_u
->num_entries4
= num_sam_entries
;
1388 r_u
->ptr_entries1
= 0;
1389 r_u
->num_entries2
= num_sam_entries
;
1390 r_u
->ptr_entries2
= 1;
1394 /*******************************************************************
1395 reads or writes a structure.
1396 ********************************************************************/
1398 BOOL
samr_io_r_enum_dom_users(const char *desc
, SAMR_R_ENUM_DOM_USERS
* r_u
,
1399 prs_struct
*ps
, int depth
)
1406 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
1412 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1414 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1417 if (r_u
->ptr_entries1
!= 0) {
1418 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1420 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1422 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1425 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
!= 0)) {
1426 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
, r_u
->num_entries2
);
1427 r_u
->uni_acct_name
= PRS_ALLOC_MEM(ps
,UNISTR2
, r_u
->num_entries2
);
1430 if ((r_u
->sam
== NULL
|| r_u
->uni_acct_name
== NULL
) && r_u
->num_entries2
!= 0) {
1431 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1432 r_u
->num_entries4
= 0;
1433 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
1437 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1438 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1442 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1443 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],r_u
->sam
[i
].hdr_name
.buffer
, ps
,depth
))
1452 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1454 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1460 /*******************************************************************
1461 inits a SAMR_Q_QUERY_DISPINFO structure.
1462 ********************************************************************/
1464 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
* q_e
, POLICY_HND
*pol
,
1465 uint16 switch_level
, uint32 start_idx
,
1466 uint32 max_entries
, uint32 max_size
)
1468 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1470 q_e
->domain_pol
= *pol
;
1472 q_e
->switch_level
= switch_level
;
1474 q_e
->start_idx
= start_idx
;
1475 q_e
->max_entries
= max_entries
;
1476 q_e
->max_size
= max_size
;
1479 /*******************************************************************
1480 reads or writes a structure.
1481 ********************************************************************/
1483 BOOL
samr_io_q_query_dispinfo(const char *desc
, SAMR_Q_QUERY_DISPINFO
* q_e
,
1484 prs_struct
*ps
, int depth
)
1489 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
1495 if(!smb_io_pol_hnd("domain_pol", &q_e
->domain_pol
, ps
, depth
))
1498 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1503 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1505 if(!prs_uint32("max_entries ", ps
, depth
, &q_e
->max_entries
))
1507 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1513 /*******************************************************************
1514 inits a SAM_DISPINFO_1 structure.
1515 ********************************************************************/
1517 NTSTATUS
init_sam_dispinfo_1(TALLOC_CTX
*ctx
, SAM_DISPINFO_1
**sam
,
1518 uint32 num_entries
, uint32 start_idx
,
1519 struct samr_displayentry
*entries
)
1523 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries
));
1526 return NT_STATUS_OK
;
1528 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_1
, num_entries
);
1530 return NT_STATUS_NO_MEMORY
;
1532 (*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY1
, num_entries
);
1533 if ((*sam
)->sam
== NULL
)
1534 return NT_STATUS_NO_MEMORY
;
1536 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR1
, num_entries
);
1537 if ((*sam
)->str
== NULL
)
1538 return NT_STATUS_NO_MEMORY
;
1540 for (i
= 0; i
< num_entries
; i
++) {
1541 init_unistr2(&(*sam
)->str
[i
].uni_acct_name
,
1542 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1543 init_unistr2(&(*sam
)->str
[i
].uni_full_name
,
1544 entries
[i
].fullname
, UNI_FLAGS_NONE
);
1545 init_unistr2(&(*sam
)->str
[i
].uni_acct_desc
,
1546 entries
[i
].description
, UNI_FLAGS_NONE
);
1548 init_sam_entry1(&(*sam
)->sam
[i
], start_idx
+i
+1,
1549 &(*sam
)->str
[i
].uni_acct_name
,
1550 &(*sam
)->str
[i
].uni_full_name
,
1551 &(*sam
)->str
[i
].uni_acct_desc
,
1552 entries
[i
].rid
, entries
[i
].acct_flags
);
1555 return NT_STATUS_OK
;
1558 /*******************************************************************
1559 reads or writes a structure.
1560 ********************************************************************/
1562 static BOOL
sam_io_sam_dispinfo_1(const char *desc
, SAM_DISPINFO_1
* sam
,
1564 prs_struct
*ps
, int depth
)
1568 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_1");
1574 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1576 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY1
, num_entries
)) == NULL
) {
1577 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1581 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR1
, num_entries
)) == NULL
) {
1582 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1587 for (i
= 0; i
< num_entries
; i
++) {
1588 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
1592 for (i
= 0; i
< num_entries
; i
++) {
1593 if(!sam_io_sam_str1("", &sam
->str
[i
],
1594 sam
->sam
[i
].hdr_acct_name
.buffer
,
1595 sam
->sam
[i
].hdr_user_name
.buffer
,
1596 sam
->sam
[i
].hdr_user_desc
.buffer
, ps
, depth
))
1603 /*******************************************************************
1604 inits a SAM_DISPINFO_2 structure.
1605 ********************************************************************/
1607 NTSTATUS
init_sam_dispinfo_2(TALLOC_CTX
*ctx
, SAM_DISPINFO_2
**sam
,
1608 uint32 num_entries
, uint32 start_idx
,
1609 struct samr_displayentry
*entries
)
1613 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries
));
1616 return NT_STATUS_OK
;
1618 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_2
, num_entries
);
1620 return NT_STATUS_NO_MEMORY
;
1622 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY2
, num_entries
);
1623 if ((*sam
)->sam
== NULL
)
1624 return NT_STATUS_NO_MEMORY
;
1626 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR2
, num_entries
);
1627 if ((*sam
)->str
== NULL
)
1628 return NT_STATUS_NO_MEMORY
;
1630 for (i
= 0; i
< num_entries
; i
++) {
1631 init_unistr2(&(*sam
)->str
[i
].uni_srv_name
,
1632 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1633 init_unistr2(&(*sam
)->str
[i
].uni_srv_desc
,
1634 entries
[i
].description
, UNI_FLAGS_NONE
);
1636 init_sam_entry2(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
1637 &(*sam
)->str
[i
].uni_srv_name
,
1638 &(*sam
)->str
[i
].uni_srv_desc
,
1639 entries
[i
].rid
, entries
[i
].acct_flags
);
1642 return NT_STATUS_OK
;
1645 /*******************************************************************
1646 reads or writes a structure.
1647 ********************************************************************/
1649 static BOOL
sam_io_sam_dispinfo_2(const char *desc
, SAM_DISPINFO_2
* sam
,
1651 prs_struct
*ps
, int depth
)
1658 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_2");
1664 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1666 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY2
, num_entries
)) == NULL
) {
1667 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1671 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR2
, num_entries
)) == NULL
) {
1672 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1677 for (i
= 0; i
< num_entries
; i
++) {
1678 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
1682 for (i
= 0; i
< num_entries
; i
++) {
1683 if(!sam_io_sam_str2("", &sam
->str
[i
],
1684 sam
->sam
[i
].hdr_srv_name
.buffer
,
1685 sam
->sam
[i
].hdr_srv_desc
.buffer
, ps
, depth
))
1692 /*******************************************************************
1693 inits a SAM_DISPINFO_3 structure.
1694 ********************************************************************/
1696 NTSTATUS
init_sam_dispinfo_3(TALLOC_CTX
*ctx
, SAM_DISPINFO_3
**sam
,
1697 uint32 num_entries
, uint32 start_idx
,
1698 struct samr_displayentry
*entries
)
1702 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries
));
1705 return NT_STATUS_OK
;
1707 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_3
, num_entries
);
1709 return NT_STATUS_NO_MEMORY
;
1711 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY3
, num_entries
)))
1712 return NT_STATUS_NO_MEMORY
;
1714 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR3
, num_entries
)))
1715 return NT_STATUS_NO_MEMORY
;
1717 for (i
= 0; i
< num_entries
; i
++) {
1718 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i
));
1720 init_unistr2(&(*sam
)->str
[i
].uni_grp_name
,
1721 entries
[i
].account_name
, UNI_FLAGS_NONE
);
1722 init_unistr2(&(*sam
)->str
[i
].uni_grp_desc
,
1723 entries
[i
].description
, UNI_FLAGS_NONE
);
1725 init_sam_entry3(&(*sam
)->sam
[i
], start_idx
+i
+1,
1726 &(*sam
)->str
[i
].uni_grp_name
,
1727 &(*sam
)->str
[i
].uni_grp_desc
,
1731 return NT_STATUS_OK
;
1734 /*******************************************************************
1735 reads or writes a structure.
1736 ********************************************************************/
1738 static BOOL
sam_io_sam_dispinfo_3(const char *desc
, SAM_DISPINFO_3
* sam
,
1740 prs_struct
*ps
, int depth
)
1747 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_3");
1753 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1755 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY3
, num_entries
)) == NULL
) {
1756 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1760 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR3
, num_entries
)) == NULL
) {
1761 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1766 for (i
= 0; i
< num_entries
; i
++) {
1767 if(!sam_io_sam_entry3("", &sam
->sam
[i
], ps
, depth
))
1771 for (i
= 0; i
< num_entries
; i
++) {
1772 if(!sam_io_sam_str3("", &sam
->str
[i
],
1773 sam
->sam
[i
].hdr_grp_name
.buffer
,
1774 sam
->sam
[i
].hdr_grp_desc
.buffer
, ps
, depth
))
1781 /*******************************************************************
1782 inits a SAM_DISPINFO_4 structure.
1783 ********************************************************************/
1785 NTSTATUS
init_sam_dispinfo_4(TALLOC_CTX
*ctx
, SAM_DISPINFO_4
**sam
,
1786 uint32 num_entries
, uint32 start_idx
,
1787 struct samr_displayentry
*entries
)
1791 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries
));
1794 return NT_STATUS_OK
;
1796 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_4
, num_entries
);
1798 return NT_STATUS_NO_MEMORY
;
1800 (*sam
)->sam
= TALLOC_ARRAY(ctx
, SAM_ENTRY4
, num_entries
);
1801 if ((*sam
)->sam
== NULL
)
1802 return NT_STATUS_NO_MEMORY
;
1804 (*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR4
, num_entries
);
1805 if ((*sam
)->str
== NULL
)
1806 return NT_STATUS_NO_MEMORY
;
1808 for (i
= 0; i
< num_entries
; i
++) {
1809 size_t len_sam_name
= strlen(entries
[i
].account_name
);
1811 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1813 init_sam_entry4(&(*sam
)->sam
[i
], start_idx
+ i
+ 1,
1816 init_string2(&(*sam
)->str
[i
].acct_name
,
1817 entries
[i
].account_name
, len_sam_name
+1,
1821 return NT_STATUS_OK
;
1824 /*******************************************************************
1825 reads or writes a structure.
1826 ********************************************************************/
1828 static BOOL
sam_io_sam_dispinfo_4(const char *desc
, SAM_DISPINFO_4
* sam
,
1830 prs_struct
*ps
, int depth
)
1837 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_4");
1843 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1845 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY4
, num_entries
)) == NULL
) {
1846 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1850 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR4
, num_entries
)) == NULL
) {
1851 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1856 for (i
= 0; i
< num_entries
; i
++) {
1857 if(!sam_io_sam_entry4("", &sam
->sam
[i
], ps
, depth
))
1861 for (i
= 0; i
< num_entries
; i
++) {
1862 if(!smb_io_string2("acct_name", &sam
->str
[i
].acct_name
,
1863 sam
->sam
[i
].hdr_acct_name
.buffer
, ps
, depth
))
1870 /*******************************************************************
1871 inits a SAM_DISPINFO_5 structure.
1872 ********************************************************************/
1874 NTSTATUS
init_sam_dispinfo_5(TALLOC_CTX
*ctx
, SAM_DISPINFO_5
**sam
,
1875 uint32 num_entries
, uint32 start_idx
,
1876 struct samr_displayentry
*entries
)
1878 uint32 len_sam_name
;
1881 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries
));
1884 return NT_STATUS_OK
;
1886 *sam
= TALLOC_ZERO_ARRAY(ctx
, SAM_DISPINFO_5
, num_entries
);
1888 return NT_STATUS_NO_MEMORY
;
1890 if (!((*sam
)->sam
=TALLOC_ARRAY(ctx
, SAM_ENTRY5
, num_entries
)))
1891 return NT_STATUS_NO_MEMORY
;
1893 if (!((*sam
)->str
=TALLOC_ARRAY(ctx
, SAM_STR5
, num_entries
)))
1894 return NT_STATUS_NO_MEMORY
;
1896 for (i
= 0; i
< num_entries
; i
++) {
1897 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i
));
1899 len_sam_name
= strlen(entries
[i
].account_name
);
1901 init_sam_entry5(&(*sam
)->sam
[i
], start_idx
+i
+1, len_sam_name
);
1902 init_string2(&(*sam
)->str
[i
].grp_name
, entries
[i
].account_name
,
1903 len_sam_name
+1, len_sam_name
);
1906 return NT_STATUS_OK
;
1909 /*******************************************************************
1910 reads or writes a structure.
1911 ********************************************************************/
1913 static BOOL
sam_io_sam_dispinfo_5(const char *desc
, SAM_DISPINFO_5
* sam
,
1915 prs_struct
*ps
, int depth
)
1922 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_5");
1928 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1930 if ((sam
->sam
= PRS_ALLOC_MEM(ps
, SAM_ENTRY5
, num_entries
)) == NULL
) {
1931 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1935 if ((sam
->str
= PRS_ALLOC_MEM(ps
, SAM_STR5
, num_entries
)) == NULL
) {
1936 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1941 for (i
= 0; i
< num_entries
; i
++) {
1942 if(!sam_io_sam_entry5("", &sam
->sam
[i
], ps
, depth
))
1946 for (i
= 0; i
< num_entries
; i
++) {
1947 if(!smb_io_string2("grp_name", &sam
->str
[i
].grp_name
,
1948 sam
->sam
[i
].hdr_grp_name
.buffer
, ps
, depth
))
1955 /*******************************************************************
1956 inits a SAMR_R_QUERY_DISPINFO structure.
1957 ********************************************************************/
1959 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
* r_u
,
1960 uint32 num_entries
, uint32 total_size
, uint32 data_size
,
1961 uint16 switch_level
, SAM_DISPINFO_CTR
* ctr
,
1964 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level
));
1966 r_u
->total_size
= total_size
;
1968 r_u
->data_size
= data_size
;
1970 r_u
->switch_level
= switch_level
;
1971 r_u
->num_entries
= num_entries
;
1974 r_u
->ptr_entries
= 0;
1976 r_u
->ptr_entries
= 1;
1978 r_u
->num_entries2
= num_entries
;
1981 r_u
->status
= status
;
1984 /*******************************************************************
1985 reads or writes a structure.
1986 ********************************************************************/
1988 BOOL
samr_io_r_query_dispinfo(const char *desc
, SAMR_R_QUERY_DISPINFO
* r_u
,
1989 prs_struct
*ps
, int depth
)
1994 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
2000 if(!prs_uint32("total_size ", ps
, depth
, &r_u
->total_size
))
2002 if(!prs_uint32("data_size ", ps
, depth
, &r_u
->data_size
))
2004 if(!prs_uint16("switch_level", ps
, depth
, &r_u
->switch_level
))
2009 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2011 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
2014 if (r_u
->ptr_entries
==0) {
2017 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2023 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2026 switch (r_u
->switch_level
) {
2028 if(!sam_io_sam_dispinfo_1("users", r_u
->ctr
->sam
.info1
,
2029 r_u
->num_entries
, ps
, depth
))
2033 if(!sam_io_sam_dispinfo_2("servers", r_u
->ctr
->sam
.info2
,
2034 r_u
->num_entries
, ps
, depth
))
2038 if(!sam_io_sam_dispinfo_3("groups", r_u
->ctr
->sam
.info3
,
2039 r_u
->num_entries
, ps
, depth
))
2043 if(!sam_io_sam_dispinfo_4("user list",
2044 r_u
->ctr
->sam
.info4
,
2045 r_u
->num_entries
, ps
, depth
))
2049 if(!sam_io_sam_dispinfo_5("group list",
2050 r_u
->ctr
->sam
.info5
,
2051 r_u
->num_entries
, ps
, depth
))
2055 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2061 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2067 /*******************************************************************
2068 inits a SAMR_Q_OPEN_GROUP structure.
2069 ********************************************************************/
2071 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP
* q_c
,
2073 uint32 access_mask
, uint32 rid
)
2075 DEBUG(5, ("init_samr_q_open_group\n"));
2077 q_c
->domain_pol
= *hnd
;
2078 q_c
->access_mask
= access_mask
;
2079 q_c
->rid_group
= rid
;
2082 /*******************************************************************
2083 reads or writes a structure.
2084 ********************************************************************/
2086 BOOL
samr_io_q_open_group(const char *desc
, SAMR_Q_OPEN_GROUP
* q_u
,
2087 prs_struct
*ps
, int depth
)
2092 prs_debug(ps
, depth
, desc
, "samr_io_q_open_group");
2098 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
2101 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
2103 if(!prs_uint32("rid_group", ps
, depth
, &q_u
->rid_group
))
2109 /*******************************************************************
2110 reads or writes a structure.
2111 ********************************************************************/
2113 BOOL
samr_io_r_open_group(const char *desc
, SAMR_R_OPEN_GROUP
* r_u
,
2114 prs_struct
*ps
, int depth
)
2119 prs_debug(ps
, depth
, desc
, "samr_io_r_open_group");
2125 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2128 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2134 /*******************************************************************
2135 inits a GROUP_INFO1 structure.
2136 ********************************************************************/
2138 void init_samr_group_info1(GROUP_INFO1
* gr1
,
2139 char *acct_name
, char *acct_desc
,
2142 DEBUG(5, ("init_samr_group_info1\n"));
2144 gr1
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
2145 gr1
->num_members
= num_members
;
2147 init_unistr2(&gr1
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2148 init_uni_hdr(&gr1
->hdr_acct_name
, &gr1
->uni_acct_name
);
2149 init_unistr2(&gr1
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2150 init_uni_hdr(&gr1
->hdr_acct_desc
, &gr1
->uni_acct_desc
);
2153 /*******************************************************************
2154 reads or writes a structure.
2155 ********************************************************************/
2157 BOOL
samr_io_group_info1(const char *desc
, GROUP_INFO1
* gr1
,
2158 prs_struct
*ps
, int depth
)
2165 prs_debug(ps
, depth
, desc
, "samr_io_group_info1");
2168 if(!prs_uint16("level", ps
, depth
, &dummy
))
2174 if(!smb_io_unihdr("hdr_acct_name", &gr1
->hdr_acct_name
, ps
, depth
))
2177 if(!prs_uint32("group_attr", ps
, depth
, &gr1
->group_attr
))
2179 if(!prs_uint32("num_members", ps
, depth
, &gr1
->num_members
))
2182 if(!smb_io_unihdr("hdr_acct_desc", &gr1
->hdr_acct_desc
, ps
, depth
))
2185 if(!smb_io_unistr2("uni_acct_name", &gr1
->uni_acct_name
,
2186 gr1
->hdr_acct_name
.buffer
, ps
, depth
))
2189 if(!smb_io_unistr2("uni_acct_desc", &gr1
->uni_acct_desc
,
2190 gr1
->hdr_acct_desc
.buffer
, ps
, depth
))
2196 /*******************************************************************
2197 inits a GROUP_INFO2 structure.
2198 ********************************************************************/
2200 void init_samr_group_info2(GROUP_INFO2
* gr2
, const char *acct_name
)
2202 DEBUG(5, ("init_samr_group_info2\n"));
2205 init_unistr2(&gr2
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2206 init_uni_hdr(&gr2
->hdr_acct_name
, &gr2
->uni_acct_name
);
2209 /*******************************************************************
2210 reads or writes a structure.
2211 ********************************************************************/
2213 BOOL
samr_io_group_info2(const char *desc
, GROUP_INFO2
*gr2
, prs_struct
*ps
, int depth
)
2218 prs_debug(ps
, depth
, desc
, "samr_io_group_info2");
2221 if(!prs_uint16("hdr_level", ps
, depth
, &gr2
->level
))
2224 if(!smb_io_unihdr("hdr_acct_name", &gr2
->hdr_acct_name
, ps
, depth
))
2226 if(!smb_io_unistr2("uni_acct_name", &gr2
->uni_acct_name
,
2227 gr2
->hdr_acct_name
.buffer
, ps
, depth
))
2233 /*******************************************************************
2234 inits a GROUP_INFO3 structure.
2235 ********************************************************************/
2237 void init_samr_group_info3(GROUP_INFO3
*gr3
)
2239 DEBUG(5, ("init_samr_group_info3\n"));
2241 gr3
->group_attr
= (SE_GROUP_MANDATORY
|SE_GROUP_ENABLED_BY_DEFAULT
); /* why not | SE_GROUP_ENABLED ? */
2244 /*******************************************************************
2245 reads or writes a structure.
2246 ********************************************************************/
2248 BOOL
samr_io_group_info3(const char *desc
, GROUP_INFO3
*gr3
, prs_struct
*ps
, int depth
)
2253 prs_debug(ps
, depth
, desc
, "samr_io_group_info3");
2259 if(!prs_uint32("group_attr", ps
, depth
, &gr3
->group_attr
))
2265 /*******************************************************************
2266 inits a GROUP_INFO4 structure.
2267 ********************************************************************/
2269 void init_samr_group_info4(GROUP_INFO4
* gr4
, const char *acct_desc
)
2271 DEBUG(5, ("init_samr_group_info4\n"));
2274 init_unistr2(&gr4
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2275 init_uni_hdr(&gr4
->hdr_acct_desc
, &gr4
->uni_acct_desc
);
2278 /*******************************************************************
2279 reads or writes a structure.
2280 ********************************************************************/
2282 BOOL
samr_io_group_info4(const char *desc
, GROUP_INFO4
* gr4
,
2283 prs_struct
*ps
, int depth
)
2288 prs_debug(ps
, depth
, desc
, "samr_io_group_info4");
2291 if(!prs_uint16("hdr_level", ps
, depth
, &gr4
->level
))
2293 if(!smb_io_unihdr("hdr_acct_desc", &gr4
->hdr_acct_desc
, ps
, depth
))
2295 if(!smb_io_unistr2("uni_acct_desc", &gr4
->uni_acct_desc
,
2296 gr4
->hdr_acct_desc
.buffer
, ps
, depth
))
2302 /*******************************************************************
2303 reads or writes a structure.
2304 ********************************************************************/
2306 static BOOL
samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
2307 prs_struct
*ps
, int depth
)
2309 if (UNMARSHALLING(ps
))
2310 *ctr
= PRS_ALLOC_MEM(ps
,GROUP_INFO_CTR
,1);
2315 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
2318 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
2321 switch ((*ctr
)->switch_value1
) {
2323 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
2327 if(!samr_io_group_info2("group_info2", &(*ctr
)->group
.info2
, ps
, depth
))
2331 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
2335 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
2339 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2346 /*******************************************************************
2347 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2348 ********************************************************************/
2350 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2351 POLICY_HND
*pol
, const char *acct_desc
,
2354 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2358 init_unistr2(&q_e
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2359 init_uni_hdr(&q_e
->hdr_acct_desc
, &q_e
->uni_acct_desc
);
2361 q_e
->access_mask
= access_mask
;
2364 /*******************************************************************
2365 reads or writes a structure.
2366 ********************************************************************/
2368 BOOL
samr_io_q_create_dom_group(const char *desc
, SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2369 prs_struct
*ps
, int depth
)
2374 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_group");
2380 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2383 if(!smb_io_unihdr("hdr_acct_desc", &q_e
->hdr_acct_desc
, ps
, depth
))
2385 if(!smb_io_unistr2("uni_acct_desc", &q_e
->uni_acct_desc
,
2386 q_e
->hdr_acct_desc
.buffer
, ps
, depth
))
2391 if(!prs_uint32("access", ps
, depth
, &q_e
->access_mask
))
2397 /*******************************************************************
2398 reads or writes a structure.
2399 ********************************************************************/
2401 BOOL
samr_io_r_create_dom_group(const char *desc
, SAMR_R_CREATE_DOM_GROUP
* r_u
,
2402 prs_struct
*ps
, int depth
)
2407 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_group");
2413 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2416 if(!prs_uint32("rid ", ps
, depth
, &r_u
->rid
))
2418 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2424 /*******************************************************************
2425 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2426 ********************************************************************/
2428 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP
* q_c
,
2431 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2433 q_c
->group_pol
= *hnd
;
2436 /*******************************************************************
2437 reads or writes a structure.
2438 ********************************************************************/
2440 BOOL
samr_io_q_delete_dom_group(const char *desc
, SAMR_Q_DELETE_DOM_GROUP
* q_u
,
2441 prs_struct
*ps
, int depth
)
2446 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_group");
2452 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2458 /*******************************************************************
2459 reads or writes a structure.
2460 ********************************************************************/
2462 BOOL
samr_io_r_delete_dom_group(const char *desc
, SAMR_R_DELETE_DOM_GROUP
* r_u
,
2463 prs_struct
*ps
, int depth
)
2468 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_group");
2474 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2477 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2483 /*******************************************************************
2484 inits a SAMR_Q_DEL_GROUPMEM structure.
2485 ********************************************************************/
2487 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM
* q_e
,
2488 POLICY_HND
*pol
, uint32 rid
)
2490 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2496 /*******************************************************************
2497 reads or writes a structure.
2498 ********************************************************************/
2500 BOOL
samr_io_q_del_groupmem(const char *desc
, SAMR_Q_DEL_GROUPMEM
* q_e
,
2501 prs_struct
*ps
, int depth
)
2506 prs_debug(ps
, depth
, desc
, "samr_io_q_del_groupmem");
2512 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2515 if(!prs_uint32("rid", ps
, depth
, &q_e
->rid
))
2521 /*******************************************************************
2522 inits a SAMR_R_DEL_GROUPMEM structure.
2523 ********************************************************************/
2525 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2528 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2530 r_u
->status
= status
;
2533 /*******************************************************************
2534 reads or writes a structure.
2535 ********************************************************************/
2537 BOOL
samr_io_r_del_groupmem(const char *desc
, SAMR_R_DEL_GROUPMEM
* r_u
,
2538 prs_struct
*ps
, int depth
)
2543 prs_debug(ps
, depth
, desc
, "samr_io_r_del_groupmem");
2549 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2555 /*******************************************************************
2556 inits a SAMR_Q_ADD_GROUPMEM structure.
2557 ********************************************************************/
2559 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM
* q_e
,
2560 POLICY_HND
*pol
, uint32 rid
)
2562 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2566 q_e
->unknown
= 0x0005;
2569 /*******************************************************************
2570 reads or writes a structure.
2571 ********************************************************************/
2573 BOOL
samr_io_q_add_groupmem(const char *desc
, SAMR_Q_ADD_GROUPMEM
* q_e
,
2574 prs_struct
*ps
, int depth
)
2579 prs_debug(ps
, depth
, desc
, "samr_io_q_add_groupmem");
2585 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2588 if(!prs_uint32("rid ", ps
, depth
, &q_e
->rid
))
2590 if(!prs_uint32("unknown", ps
, depth
, &q_e
->unknown
))
2596 /*******************************************************************
2597 inits a SAMR_R_ADD_GROUPMEM structure.
2598 ********************************************************************/
2600 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2603 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2605 r_u
->status
= status
;
2608 /*******************************************************************
2609 reads or writes a structure.
2610 ********************************************************************/
2612 BOOL
samr_io_r_add_groupmem(const char *desc
, SAMR_R_ADD_GROUPMEM
* r_u
,
2613 prs_struct
*ps
, int depth
)
2618 prs_debug(ps
, depth
, desc
, "samr_io_r_add_groupmem");
2624 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2630 /*******************************************************************
2631 inits a SAMR_Q_SET_GROUPINFO structure.
2632 ********************************************************************/
2634 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO
* q_e
,
2635 POLICY_HND
*pol
, GROUP_INFO_CTR
* ctr
)
2637 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2643 /*******************************************************************
2644 reads or writes a structure.
2645 ********************************************************************/
2647 BOOL
samr_io_q_set_groupinfo(const char *desc
, SAMR_Q_SET_GROUPINFO
* q_e
,
2648 prs_struct
*ps
, int depth
)
2653 prs_debug(ps
, depth
, desc
, "samr_io_q_set_groupinfo");
2659 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2662 if(!samr_group_info_ctr("ctr", &q_e
->ctr
, ps
, depth
))
2668 /*******************************************************************
2669 inits a SAMR_R_SET_GROUPINFO structure.
2670 ********************************************************************/
2672 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO
* r_u
, NTSTATUS status
)
2674 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2676 r_u
->status
= status
;
2679 /*******************************************************************
2680 reads or writes a structure.
2681 ********************************************************************/
2683 BOOL
samr_io_r_set_groupinfo(const char *desc
, SAMR_R_SET_GROUPINFO
* r_u
,
2684 prs_struct
*ps
, int depth
)
2689 prs_debug(ps
, depth
, desc
, "samr_io_r_set_groupinfo");
2695 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2701 /*******************************************************************
2702 inits a SAMR_Q_QUERY_GROUPINFO structure.
2703 ********************************************************************/
2705 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
2706 POLICY_HND
*pol
, uint16 switch_level
)
2708 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2712 q_e
->switch_level
= switch_level
;
2715 /*******************************************************************
2716 reads or writes a structure.
2717 ********************************************************************/
2719 BOOL
samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
2720 prs_struct
*ps
, int depth
)
2725 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
2731 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2734 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
2740 /*******************************************************************
2741 inits a SAMR_R_QUERY_GROUPINFO structure.
2742 ********************************************************************/
2744 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
2745 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
2747 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2749 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
2751 r_u
->status
= status
;
2754 /*******************************************************************
2755 reads or writes a structure.
2756 ********************************************************************/
2758 BOOL
samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
2759 prs_struct
*ps
, int depth
)
2764 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
2770 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2773 if (r_u
->ptr
!= 0) {
2774 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
2780 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2786 /*******************************************************************
2787 inits a SAMR_Q_QUERY_GROUPMEM structure.
2788 ********************************************************************/
2790 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM
* q_c
, POLICY_HND
*hnd
)
2792 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2794 q_c
->group_pol
= *hnd
;
2797 /*******************************************************************
2798 reads or writes a structure.
2799 ********************************************************************/
2801 BOOL
samr_io_q_query_groupmem(const char *desc
, SAMR_Q_QUERY_GROUPMEM
* q_u
,
2802 prs_struct
*ps
, int depth
)
2807 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupmem");
2813 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2819 /*******************************************************************
2820 inits a SAMR_R_QUERY_GROUPMEM structure.
2821 ********************************************************************/
2823 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM
* r_u
,
2824 uint32 num_entries
, uint32
*rid
,
2825 uint32
*attr
, NTSTATUS status
)
2827 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2829 if (NT_STATUS_IS_OK(status
)) {
2831 r_u
->num_entries
= num_entries
;
2833 r_u
->ptr_attrs
= attr
!= NULL
? 1 : 0;
2834 r_u
->ptr_rids
= rid
!= NULL
? 1 : 0;
2836 r_u
->num_rids
= num_entries
;
2839 r_u
->num_attrs
= num_entries
;
2843 r_u
->num_entries
= 0;
2846 r_u
->status
= status
;
2849 /*******************************************************************
2850 reads or writes a structure.
2851 ********************************************************************/
2853 BOOL
samr_io_r_query_groupmem(const char *desc
, SAMR_R_QUERY_GROUPMEM
* r_u
,
2854 prs_struct
*ps
, int depth
)
2861 if (UNMARSHALLING(ps
))
2864 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupmem");
2870 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2872 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2875 if (r_u
->ptr
!= 0) {
2876 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2878 if(!prs_uint32("ptr_attrs", ps
, depth
, &r_u
->ptr_attrs
))
2881 if (r_u
->ptr_rids
!= 0) {
2882 if(!prs_uint32("num_rids", ps
, depth
, &r_u
->num_rids
))
2884 if (UNMARSHALLING(ps
) && r_u
->num_rids
!= 0) {
2885 r_u
->rid
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_rids
);
2886 if (r_u
->rid
== NULL
)
2890 for (i
= 0; i
< r_u
->num_rids
; i
++) {
2891 if(!prs_uint32("", ps
, depth
, &r_u
->rid
[i
]))
2896 if (r_u
->ptr_attrs
!= 0) {
2897 if(!prs_uint32("num_attrs", ps
, depth
, &r_u
->num_attrs
))
2900 if (UNMARSHALLING(ps
) && r_u
->num_attrs
!= 0) {
2901 r_u
->attr
= PRS_ALLOC_MEM(ps
,uint32
,r_u
->num_attrs
);
2902 if (r_u
->attr
== NULL
)
2906 for (i
= 0; i
< r_u
->num_attrs
; i
++) {
2907 if(!prs_uint32("", ps
, depth
, &r_u
->attr
[i
]))
2913 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2919 /*******************************************************************
2920 inits a SAMR_Q_QUERY_USERGROUPS structure.
2921 ********************************************************************/
2923 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
2926 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2931 /*******************************************************************
2932 reads or writes a structure.
2933 ********************************************************************/
2935 BOOL
samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
2936 prs_struct
*ps
, int depth
)
2941 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
2947 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2953 /*******************************************************************
2954 inits a SAMR_R_QUERY_USERGROUPS structure.
2955 ********************************************************************/
2957 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
2958 uint32 num_gids
, DOM_GID
* gid
,
2961 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2963 if (NT_STATUS_IS_OK(status
)) {
2965 r_u
->num_entries
= num_gids
;
2966 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
2967 r_u
->num_entries2
= num_gids
;
2972 r_u
->num_entries
= 0;
2977 r_u
->status
= status
;
2980 /*******************************************************************
2981 reads or writes a structure.
2982 ********************************************************************/
2984 BOOL
samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
2985 prs_struct
*ps
, int depth
)
2991 prs_debug(ps
, depth
, desc
, "samr_io_gids");
2997 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
3000 if ((*num_gids
) != 0) {
3001 if (UNMARSHALLING(ps
)) {
3002 (*gid
) = PRS_ALLOC_MEM(ps
,DOM_GID
,*num_gids
);
3005 if ((*gid
) == NULL
) {
3009 for (i
= 0; i
< (*num_gids
); i
++) {
3010 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
3018 /*******************************************************************
3019 reads or writes a structure.
3020 ********************************************************************/
3022 BOOL
samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
3023 prs_struct
*ps
, int depth
)
3028 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
3034 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
3037 if (r_u
->ptr_0
!= 0) {
3038 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
3040 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
3043 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
3044 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
3051 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3057 /*******************************************************************
3058 inits a SAMR_Q_ENUM_DOMAINS structure.
3059 ********************************************************************/
3061 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
3063 uint32 start_idx
, uint32 size
)
3065 DEBUG(5, ("init_samr_q_enum_domains\n"));
3069 q_e
->start_idx
= start_idx
;
3070 q_e
->max_size
= size
;
3073 /*******************************************************************
3074 reads or writes a structure.
3075 ********************************************************************/
3077 BOOL
samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
3078 prs_struct
*ps
, int depth
)
3083 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
3089 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3092 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3094 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3100 /*******************************************************************
3101 inits a SAMR_R_ENUM_DOMAINS structure.
3102 ********************************************************************/
3104 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
3105 uint32 next_idx
, uint32 num_sam_entries
)
3107 DEBUG(5, ("init_samr_r_enum_domains\n"));
3109 r_u
->next_idx
= next_idx
;
3111 if (num_sam_entries
!= 0) {
3112 r_u
->ptr_entries1
= 1;
3113 r_u
->ptr_entries2
= 1;
3114 r_u
->num_entries2
= num_sam_entries
;
3115 r_u
->num_entries3
= num_sam_entries
;
3117 r_u
->num_entries4
= num_sam_entries
;
3119 r_u
->ptr_entries1
= 0;
3120 r_u
->num_entries2
= num_sam_entries
;
3121 r_u
->ptr_entries2
= 1;
3125 /*******************************************************************
3126 reads or writes a structure.
3127 ********************************************************************/
3129 BOOL
samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
3130 prs_struct
*ps
, int depth
)
3137 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
3143 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3145 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3148 if (r_u
->ptr_entries1
!= 0) {
3149 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3151 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3153 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3156 if (UNMARSHALLING(ps
)) {
3157 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3158 r_u
->uni_dom_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3161 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
3162 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3163 r_u
->num_entries4
= 0;
3164 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3168 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3170 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3171 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
3175 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3177 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3178 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
3179 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3188 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3190 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3196 /*******************************************************************
3197 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3198 ********************************************************************/
3200 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3202 uint32 start_idx
, uint32 size
)
3204 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3208 q_e
->start_idx
= start_idx
;
3209 q_e
->max_size
= size
;
3212 /*******************************************************************
3213 reads or writes a structure.
3214 ********************************************************************/
3216 BOOL
samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3217 prs_struct
*ps
, int depth
)
3222 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
3228 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3231 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3233 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3239 /*******************************************************************
3240 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3241 ********************************************************************/
3243 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3244 uint32 next_idx
, uint32 num_sam_entries
)
3246 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3248 r_u
->next_idx
= next_idx
;
3250 if (num_sam_entries
!= 0) {
3251 r_u
->ptr_entries1
= 1;
3252 r_u
->ptr_entries2
= 1;
3253 r_u
->num_entries2
= num_sam_entries
;
3254 r_u
->num_entries3
= num_sam_entries
;
3256 r_u
->num_entries4
= num_sam_entries
;
3258 r_u
->ptr_entries1
= 0;
3259 r_u
->num_entries2
= num_sam_entries
;
3260 r_u
->ptr_entries2
= 1;
3264 /*******************************************************************
3265 reads or writes a structure.
3266 ********************************************************************/
3268 BOOL
samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3269 prs_struct
*ps
, int depth
)
3276 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
3282 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3284 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3287 if (r_u
->ptr_entries1
!= 0) {
3288 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3290 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3292 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3295 if (UNMARSHALLING(ps
)) {
3296 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3297 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3300 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
3302 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3303 r_u
->num_entries4
= 0;
3304 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3308 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3309 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3313 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3314 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3315 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
3322 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3324 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3330 /*******************************************************************
3331 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3332 ********************************************************************/
3334 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3335 POLICY_HND
*pol
, uint32 start_idx
,
3338 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3342 q_e
->start_idx
= start_idx
;
3343 q_e
->max_size
= size
;
3347 /*******************************************************************
3348 reads or writes a structure.
3349 ********************************************************************/
3351 BOOL
samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3352 prs_struct
*ps
, int depth
)
3357 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
3363 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3366 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3368 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3374 /*******************************************************************
3375 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3376 ********************************************************************/
3378 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
3380 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3382 r_u
->next_idx
= next_idx
;
3384 if (num_sam_entries
!= 0) {
3385 r_u
->ptr_entries1
= 1;
3386 r_u
->ptr_entries2
= 1;
3387 r_u
->num_entries2
= num_sam_entries
;
3388 r_u
->num_entries3
= num_sam_entries
;
3390 r_u
->num_entries4
= num_sam_entries
;
3392 r_u
->ptr_entries1
= 0;
3393 r_u
->num_entries2
= num_sam_entries
;
3394 r_u
->ptr_entries2
= 1;
3398 /*******************************************************************
3399 reads or writes a structure.
3400 ********************************************************************/
3402 BOOL
samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
3403 prs_struct
*ps
, int depth
)
3410 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
3416 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3418 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3421 if (r_u
->ptr_entries1
!= 0) {
3422 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3424 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3426 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3429 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
3430 r_u
->sam
= PRS_ALLOC_MEM(ps
,SAM_ENTRY
,r_u
->num_entries2
);
3431 r_u
->uni_grp_name
= PRS_ALLOC_MEM(ps
,UNISTR2
,r_u
->num_entries2
);
3434 if (r_u
->num_entries2
!= 0 &&
3435 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
3436 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3437 r_u
->num_entries4
= 0;
3438 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3442 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3443 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3447 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3448 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3449 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3457 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3459 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3465 /*******************************************************************
3466 inits a ALIAS_INFO1 structure.
3467 ********************************************************************/
3469 void init_samr_alias_info1(ALIAS_INFO1
* al1
, char *acct_name
, uint32 num_member
, char *acct_desc
)
3471 DEBUG(5, ("init_samr_alias_info1\n"));
3473 init_unistr4(&al1
->name
, acct_name
, UNI_FLAGS_NONE
);
3474 al1
->num_member
= num_member
;
3475 init_unistr4(&al1
->description
, acct_desc
, UNI_FLAGS_NONE
);
3478 /*******************************************************************
3479 reads or writes a structure.
3480 ********************************************************************/
3482 BOOL
samr_io_alias_info1(const char *desc
, ALIAS_INFO1
* al1
,
3483 prs_struct
*ps
, int depth
)
3488 prs_debug(ps
, depth
, desc
, "samr_io_alias_info1");
3494 if ( !prs_unistr4_hdr("name", ps
, depth
, &al1
->name
) )
3496 if ( !prs_uint32("num_member", ps
, depth
, &al1
->num_member
) )
3498 if ( !prs_unistr4_hdr("description", ps
, depth
, &al1
->description
) )
3501 if ( !prs_unistr4_str("name", ps
, depth
, &al1
->name
) )
3503 if ( !prs_align(ps
) )
3505 if ( !prs_unistr4_str("description", ps
, depth
, &al1
->description
) )
3507 if ( !prs_align(ps
) )
3513 /*******************************************************************
3514 inits a ALIAS_INFO3 structure.
3515 ********************************************************************/
3517 void init_samr_alias_info3(ALIAS_INFO3
* al3
, const char *acct_desc
)
3519 DEBUG(5, ("init_samr_alias_info3\n"));
3521 init_unistr4(&al3
->description
, acct_desc
, UNI_FLAGS_NONE
);
3524 /*******************************************************************
3525 reads or writes a structure.
3526 ********************************************************************/
3528 BOOL
samr_io_alias_info3(const char *desc
, ALIAS_INFO3
*al3
,
3529 prs_struct
*ps
, int depth
)
3534 prs_debug(ps
, depth
, desc
, "samr_io_alias_info3");
3540 if (!prs_unistr4("description", ps
, depth
, &al3
->description
))
3546 /*******************************************************************
3547 reads or writes a structure.
3548 ********************************************************************/
3550 BOOL
samr_alias_info_ctr(const char *desc
, prs_struct
*ps
, int depth
, ALIAS_INFO_CTR
* ctr
)
3555 prs_debug(ps
, depth
, desc
, "samr_alias_info_ctr");
3558 if ( !prs_uint16("level", ps
, depth
, &ctr
->level
) )
3563 switch (ctr
->level
) {
3565 if(!samr_io_alias_info1("alias_info1", &ctr
->alias
.info1
, ps
, depth
))
3569 if(!samr_io_alias_info3("alias_info3", &ctr
->alias
.info3
, ps
, depth
))
3573 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3580 /*******************************************************************
3581 inits a SAMR_Q_QUERY_ALIASINFO structure.
3582 ********************************************************************/
3584 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
* q_e
,
3585 POLICY_HND
*pol
, uint32 switch_level
)
3587 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3590 q_e
->level
= switch_level
;
3593 /*******************************************************************
3594 reads or writes a structure.
3595 ********************************************************************/
3597 BOOL
samr_io_q_query_aliasinfo(const char *desc
, SAMR_Q_QUERY_ALIASINFO
*in
,
3598 prs_struct
*ps
, int depth
)
3603 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
3609 if ( !smb_io_pol_hnd("pol", &(in
->pol
), ps
, depth
) )
3612 if ( !prs_uint16("level", ps
, depth
, &in
->level
) )
3618 /*******************************************************************
3619 inits a SAMR_R_QUERY_ALIASINFO structure.
3620 ********************************************************************/
3622 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
*out
,
3623 ALIAS_INFO_CTR
* ctr
, NTSTATUS status
)
3625 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3628 out
->status
= status
;
3631 /*******************************************************************
3632 reads or writes a structure.
3633 ********************************************************************/
3635 BOOL
samr_io_r_query_aliasinfo(const char *desc
, SAMR_R_QUERY_ALIASINFO
*out
,
3636 prs_struct
*ps
, int depth
)
3641 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
3647 if ( !prs_pointer("alias", ps
, depth
, (void**)&out
->ctr
, sizeof(ALIAS_INFO_CTR
), (PRS_POINTER_CAST
)samr_alias_info_ctr
))
3652 if(!prs_ntstatus("status", ps
, depth
, &out
->status
))
3658 /*******************************************************************
3659 inits a SAMR_Q_SET_ALIASINFO structure.
3660 ********************************************************************/
3662 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO
* q_u
,
3663 POLICY_HND
*hnd
, ALIAS_INFO_CTR
* ctr
)
3665 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3667 q_u
->alias_pol
= *hnd
;
3671 /*******************************************************************
3672 reads or writes a structure.
3673 ********************************************************************/
3675 BOOL
samr_io_q_set_aliasinfo(const char *desc
, SAMR_Q_SET_ALIASINFO
* q_u
,
3676 prs_struct
*ps
, int depth
)
3681 prs_debug(ps
, depth
, desc
, "samr_io_q_set_aliasinfo");
3687 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
3689 if(!samr_alias_info_ctr("ctr", ps
, depth
, &q_u
->ctr
))
3695 /*******************************************************************
3696 reads or writes a structure.
3697 ********************************************************************/
3699 BOOL
samr_io_r_set_aliasinfo(const char *desc
, SAMR_R_SET_ALIASINFO
* r_u
,
3700 prs_struct
*ps
, int depth
)
3705 prs_debug(ps
, depth
, desc
, "samr_io_r_set_aliasinfo");
3710 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3716 /*******************************************************************
3717 inits a SAMR_Q_QUERY_USERALIASES structure.
3718 ********************************************************************/
3720 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES
* q_u
,
3723 uint32
*ptr_sid
, DOM_SID2
* sid
)
3725 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3729 q_u
->num_sids1
= num_sids
;
3731 q_u
->num_sids2
= num_sids
;
3733 q_u
->ptr_sid
= ptr_sid
;
3737 /*******************************************************************
3738 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3739 ********************************************************************/
3741 BOOL
samr_io_q_query_useraliases(const char *desc
, SAMR_Q_QUERY_USERALIASES
* q_u
,
3742 prs_struct
*ps
, int depth
)
3750 prs_debug(ps
, depth
, desc
, "samr_io_q_query_useraliases");
3756 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3759 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
3761 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3767 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
3770 if (UNMARSHALLING(ps
) && (q_u
->num_sids2
!= 0)) {
3771 q_u
->ptr_sid
= PRS_ALLOC_MEM(ps
,uint32
,q_u
->num_sids2
);
3772 if (q_u
->ptr_sid
== NULL
)
3775 q_u
->sid
= PRS_ALLOC_MEM(ps
, DOM_SID2
, q_u
->num_sids2
);
3776 if (q_u
->sid
== NULL
)
3780 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3781 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
3782 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
3786 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3787 if (q_u
->ptr_sid
[i
] != 0) {
3788 slprintf(tmp
, sizeof(tmp
) - 1, "sid[%02d]", i
);
3789 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
3797 /*******************************************************************
3798 inits a SAMR_R_QUERY_USERALIASES structure.
3799 ********************************************************************/
3801 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES
* r_u
,
3802 uint32 num_rids
, uint32
*rid
,
3805 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3807 if (NT_STATUS_IS_OK(status
)) {
3808 r_u
->num_entries
= num_rids
;
3810 r_u
->num_entries2
= num_rids
;
3814 r_u
->num_entries
= 0;
3816 r_u
->num_entries2
= 0;
3819 r_u
->status
= status
;
3822 /*******************************************************************
3823 reads or writes a structure.
3824 ********************************************************************/
3826 BOOL
samr_io_rids(const char *desc
, uint32
*num_rids
, uint32
**rid
,
3827 prs_struct
*ps
, int depth
)
3834 prs_debug(ps
, depth
, desc
, "samr_io_rids");
3840 if(!prs_uint32("num_rids", ps
, depth
, num_rids
))
3843 if ((*num_rids
) != 0) {
3844 if (UNMARSHALLING(ps
)) {
3846 (*rid
) = PRS_ALLOC_MEM(ps
,uint32
, *num_rids
);
3851 for (i
= 0; i
< (*num_rids
); i
++) {
3852 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d]", i
);
3853 if(!prs_uint32(tmp
, ps
, depth
, &((*rid
)[i
])))
3861 /*******************************************************************
3862 reads or writes a structure.
3863 ********************************************************************/
3865 BOOL
samr_io_r_query_useraliases(const char *desc
, SAMR_R_QUERY_USERALIASES
* r_u
,
3866 prs_struct
*ps
, int depth
)
3871 prs_debug(ps
, depth
, desc
, "samr_io_r_query_useraliases");
3877 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
3879 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
3882 if (r_u
->ptr
!= 0) {
3883 if(!samr_io_rids("rids", &r_u
->num_entries2
, &r_u
->rid
, ps
, depth
))
3889 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3895 /*******************************************************************
3896 inits a SAMR_Q_OPEN_ALIAS structure.
3897 ********************************************************************/
3899 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
* q_u
, POLICY_HND
*pol
,
3900 uint32 access_mask
, uint32 rid
)
3902 DEBUG(5, ("init_samr_q_open_alias\n"));
3904 q_u
->dom_pol
= *pol
;
3905 q_u
->access_mask
= access_mask
;
3906 q_u
->rid_alias
= rid
;
3909 /*******************************************************************
3910 reads or writes a structure.
3911 ********************************************************************/
3913 BOOL
samr_io_q_open_alias(const char *desc
, SAMR_Q_OPEN_ALIAS
* q_u
,
3914 prs_struct
*ps
, int depth
)
3919 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
3925 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
3928 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
3930 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
3936 /*******************************************************************
3937 reads or writes a structure.
3938 ********************************************************************/
3940 BOOL
samr_io_r_open_alias(const char *desc
, SAMR_R_OPEN_ALIAS
* r_u
,
3941 prs_struct
*ps
, int depth
)
3946 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
3952 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
3955 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3961 /*******************************************************************
3962 inits a SAMR_Q_LOOKUP_RIDS structure.
3963 ********************************************************************/
3965 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
3966 POLICY_HND
*pol
, uint32 flags
,
3967 uint32 num_rids
, uint32
*rid
)
3969 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3973 q_u
->num_rids1
= num_rids
;
3976 q_u
->num_rids2
= num_rids
;
3977 q_u
->rid
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
);
3978 if (q_u
->rid
== NULL
) {
3982 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
3986 /*******************************************************************
3987 reads or writes a structure.
3988 ********************************************************************/
3990 BOOL
samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
3991 prs_struct
*ps
, int depth
)
3999 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
4002 if (UNMARSHALLING(ps
))
4008 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4011 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
4013 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4015 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4017 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
4020 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
4021 q_u
->rid
= PRS_ALLOC_MEM(ps
, uint32
, q_u
->num_rids2
);
4022 if (q_u
->rid
== NULL
)
4026 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
4027 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4028 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
4035 /*******************************************************************
4036 inits a SAMR_R_LOOKUP_RIDS structure.
4037 ********************************************************************/
4039 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
4040 uint32 num_names
, UNIHDR
* hdr_name
,
4041 UNISTR2
*uni_name
, uint32
*type
)
4043 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4045 r_u
->hdr_name
= NULL
;
4046 r_u
->uni_name
= NULL
;
4049 if (num_names
!= 0) {
4050 r_u
->num_names1
= num_names
;
4052 r_u
->num_names2
= num_names
;
4054 r_u
->num_types1
= num_names
;
4056 r_u
->num_types2
= num_names
;
4058 r_u
->hdr_name
= hdr_name
;
4059 r_u
->uni_name
= uni_name
;
4062 r_u
->num_names1
= num_names
;
4064 r_u
->num_names2
= num_names
;
4066 r_u
->num_types1
= num_names
;
4068 r_u
->num_types2
= num_names
;
4072 /*******************************************************************
4073 reads or writes a structure.
4074 ********************************************************************/
4076 BOOL
samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
4077 prs_struct
*ps
, int depth
)
4084 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
4090 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
4092 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
4095 if (r_u
->ptr_names
!= 0) {
4097 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
4101 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
4102 r_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, r_u
->num_names2
);
4103 if (r_u
->hdr_name
== NULL
)
4106 r_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, r_u
->num_names2
);
4107 if (r_u
->uni_name
== NULL
)
4111 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4112 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
4113 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
4116 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4117 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
4118 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
4126 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4128 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4131 if (r_u
->ptr_types
!= 0) {
4133 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4136 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
4137 r_u
->type
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4138 if (r_u
->type
== NULL
)
4142 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4143 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4144 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
4149 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4155 /*******************************************************************
4156 inits a SAMR_Q_OPEN_ALIAS structure.
4157 ********************************************************************/
4159 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_u
, POLICY_HND
*hnd
)
4161 DEBUG(5, ("init_samr_q_delete_alias\n"));
4163 q_u
->alias_pol
= *hnd
;
4166 /*******************************************************************
4167 reads or writes a structure.
4168 ********************************************************************/
4170 BOOL
samr_io_q_delete_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4171 prs_struct
*ps
, int depth
)
4176 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_alias");
4182 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4188 /*******************************************************************
4189 reads or writes a structure.
4190 ********************************************************************/
4192 BOOL
samr_io_r_delete_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4193 prs_struct
*ps
, int depth
)
4198 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_alias");
4204 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4206 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4212 /*******************************************************************
4213 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4214 ********************************************************************/
4216 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4217 POLICY_HND
*hnd
, const char *acct_desc
)
4219 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4221 q_u
->dom_pol
= *hnd
;
4223 init_unistr2(&q_u
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
4224 init_uni_hdr(&q_u
->hdr_acct_desc
, &q_u
->uni_acct_desc
);
4226 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
4229 /*******************************************************************
4230 reads or writes a structure.
4231 ********************************************************************/
4233 BOOL
samr_io_q_create_dom_alias(const char *desc
, SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4234 prs_struct
*ps
, int depth
)
4239 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_alias");
4245 if(!smb_io_pol_hnd("dom_pol", &q_u
->dom_pol
, ps
, depth
))
4248 if(!smb_io_unihdr("hdr_acct_desc", &q_u
->hdr_acct_desc
, ps
, depth
))
4250 if(!smb_io_unistr2("uni_acct_desc", &q_u
->uni_acct_desc
,
4251 q_u
->hdr_acct_desc
.buffer
, ps
, depth
))
4256 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4262 /*******************************************************************
4263 reads or writes a structure.
4264 ********************************************************************/
4266 BOOL
samr_io_r_create_dom_alias(const char *desc
, SAMR_R_CREATE_DOM_ALIAS
* r_u
,
4267 prs_struct
*ps
, int depth
)
4272 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_alias");
4278 if(!smb_io_pol_hnd("alias_pol", &r_u
->alias_pol
, ps
, depth
))
4281 if(!prs_uint32("rid", ps
, depth
, &r_u
->rid
))
4284 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4290 /*******************************************************************
4291 inits a SAMR_Q_ADD_ALIASMEM structure.
4292 ********************************************************************/
4294 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4297 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4299 q_u
->alias_pol
= *hnd
;
4300 init_dom_sid2(&q_u
->sid
, sid
);
4303 /*******************************************************************
4304 reads or writes a structure.
4305 ********************************************************************/
4307 BOOL
samr_io_q_add_aliasmem(const char *desc
, SAMR_Q_ADD_ALIASMEM
* q_u
,
4308 prs_struct
*ps
, int depth
)
4313 prs_debug(ps
, depth
, desc
, "samr_io_q_add_aliasmem");
4319 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4321 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4327 /*******************************************************************
4328 reads or writes a structure.
4329 ********************************************************************/
4331 BOOL
samr_io_r_add_aliasmem(const char *desc
, SAMR_R_ADD_ALIASMEM
* r_u
,
4332 prs_struct
*ps
, int depth
)
4337 prs_debug(ps
, depth
, desc
, "samr_io_r_add_aliasmem");
4343 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4349 /*******************************************************************
4350 inits a SAMR_Q_DEL_ALIASMEM structure.
4351 ********************************************************************/
4353 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4356 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4358 q_u
->alias_pol
= *hnd
;
4359 init_dom_sid2(&q_u
->sid
, sid
);
4362 /*******************************************************************
4363 reads or writes a structure.
4364 ********************************************************************/
4366 BOOL
samr_io_q_del_aliasmem(const char *desc
, SAMR_Q_DEL_ALIASMEM
* q_u
,
4367 prs_struct
*ps
, int depth
)
4372 prs_debug(ps
, depth
, desc
, "samr_io_q_del_aliasmem");
4378 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4380 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4386 /*******************************************************************
4387 reads or writes a structure.
4388 ********************************************************************/
4390 BOOL
samr_io_r_del_aliasmem(const char *desc
, SAMR_R_DEL_ALIASMEM
* r_u
,
4391 prs_struct
*ps
, int depth
)
4396 prs_debug(ps
, depth
, desc
, "samr_io_r_del_aliasmem");
4402 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4408 /*******************************************************************
4409 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4410 ********************************************************************/
4412 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_c
,
4415 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4417 q_c
->alias_pol
= *hnd
;
4420 /*******************************************************************
4421 reads or writes a structure.
4422 ********************************************************************/
4424 BOOL
samr_io_q_delete_dom_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4425 prs_struct
*ps
, int depth
)
4430 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_alias");
4436 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4442 /*******************************************************************
4443 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4444 ********************************************************************/
4446 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4449 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4451 r_u
->status
= status
;
4454 /*******************************************************************
4455 reads or writes a structure.
4456 ********************************************************************/
4458 BOOL
samr_io_r_delete_dom_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4459 prs_struct
*ps
, int depth
)
4464 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_alias");
4470 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4476 /*******************************************************************
4477 inits a SAMR_Q_QUERY_ALIASMEM structure.
4478 ********************************************************************/
4480 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM
* q_c
,
4483 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4485 q_c
->alias_pol
= *hnd
;
4488 /*******************************************************************
4489 reads or writes a structure.
4490 ********************************************************************/
4492 BOOL
samr_io_q_query_aliasmem(const char *desc
, SAMR_Q_QUERY_ALIASMEM
* q_u
,
4493 prs_struct
*ps
, int depth
)
4498 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasmem");
4504 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4510 /*******************************************************************
4511 inits a SAMR_R_QUERY_ALIASMEM structure.
4512 ********************************************************************/
4514 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM
* r_u
,
4515 uint32 num_sids
, DOM_SID2
* sid
,
4518 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4520 if (NT_STATUS_IS_OK(status
)) {
4521 r_u
->num_sids
= num_sids
;
4522 r_u
->ptr
= (num_sids
!= 0) ? 1 : 0;
4523 r_u
->num_sids1
= num_sids
;
4531 r_u
->status
= status
;
4534 /*******************************************************************
4535 reads or writes a structure.
4536 ********************************************************************/
4538 BOOL
samr_io_r_query_aliasmem(const char *desc
, SAMR_R_QUERY_ALIASMEM
* r_u
,
4539 prs_struct
*ps
, int depth
)
4546 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasmem");
4552 if(!prs_uint32("num_sids ", ps
, depth
, &r_u
->num_sids
))
4554 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4557 if (r_u
->ptr
!= 0 && r_u
->num_sids
!= 0) {
4558 uint32
*ptr_sid
= NULL
;
4560 if(!prs_uint32("num_sids1", ps
, depth
, &r_u
->num_sids1
))
4563 ptr_sid
= TALLOC_ARRAY(ps
->mem_ctx
, uint32
, r_u
->num_sids1
);
4568 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4570 if(!prs_uint32("ptr_sid", ps
, depth
, &ptr_sid
[i
]))
4574 if (UNMARSHALLING(ps
)) {
4575 r_u
->sid
= TALLOC_ARRAY(ps
->mem_ctx
, DOM_SID2
, r_u
->num_sids1
);
4578 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4579 if (ptr_sid
[i
] != 0) {
4580 if(!smb_io_dom_sid2("sid", &r_u
->sid
[i
], ps
, depth
))
4588 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4594 /*******************************************************************
4595 inits a SAMR_Q_LOOKUP_NAMES structure.
4596 ********************************************************************/
4598 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4599 POLICY_HND
*pol
, uint32 flags
,
4600 uint32 num_names
, const char **name
)
4604 DEBUG(5, ("init_samr_q_lookup_names\n"));
4608 q_u
->num_names1
= num_names
;
4611 q_u
->num_names2
= num_names
;
4613 if (!(q_u
->hdr_name
= TALLOC_ZERO_ARRAY(ctx
, UNIHDR
, num_names
)))
4614 return NT_STATUS_NO_MEMORY
;
4616 if (!(q_u
->uni_name
= TALLOC_ZERO_ARRAY(ctx
, UNISTR2
, num_names
)))
4617 return NT_STATUS_NO_MEMORY
;
4619 for (i
= 0; i
< num_names
; i
++) {
4620 init_unistr2(&q_u
->uni_name
[i
], name
[i
], UNI_FLAGS_NONE
); /* unicode string for machine account */
4621 init_uni_hdr(&q_u
->hdr_name
[i
], &q_u
->uni_name
[i
]); /* unicode header for user_name */
4624 return NT_STATUS_OK
;
4627 /*******************************************************************
4628 reads or writes a structure.
4629 ********************************************************************/
4631 BOOL
samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4632 prs_struct
*ps
, int depth
)
4639 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
4642 if (UNMARSHALLING(ps
))
4648 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4651 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
4653 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4655 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4657 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
4660 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
4661 q_u
->hdr_name
= PRS_ALLOC_MEM(ps
, UNIHDR
, q_u
->num_names2
);
4662 q_u
->uni_name
= PRS_ALLOC_MEM(ps
, UNISTR2
, q_u
->num_names2
);
4663 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
4667 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4668 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
4672 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4673 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
4680 /*******************************************************************
4681 inits a SAMR_R_LOOKUP_NAMES structure.
4682 ********************************************************************/
4684 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
4686 uint32
*rid
, uint32
*type
,
4689 DEBUG(5, ("init_samr_r_lookup_names\n"));
4691 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
4694 r_u
->num_types1
= num_rids
;
4696 r_u
->num_types2
= num_rids
;
4698 r_u
->num_rids1
= num_rids
;
4700 r_u
->num_rids2
= num_rids
;
4702 if (!(r_u
->rids
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4703 return NT_STATUS_NO_MEMORY
;
4704 if (!(r_u
->types
= TALLOC_ZERO_ARRAY(ctx
, uint32
, num_rids
)))
4705 return NT_STATUS_NO_MEMORY
;
4707 if (!r_u
->rids
|| !r_u
->types
)
4710 for (i
= 0; i
< num_rids
; i
++) {
4711 r_u
->rids
[i
] = rid
[i
];
4712 r_u
->types
[i
] = type
[i
];
4717 r_u
->num_types1
= 0;
4719 r_u
->num_types2
= 0;
4729 r_u
->status
= status
;
4731 return NT_STATUS_OK
;
4734 /*******************************************************************
4735 reads or writes a structure.
4736 ********************************************************************/
4738 BOOL
samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
4739 prs_struct
*ps
, int depth
)
4747 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
4750 if (UNMARSHALLING(ps
))
4756 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
4758 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
4761 if (r_u
->ptr_rids
!= 0) {
4762 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
4765 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
4770 if (UNMARSHALLING(ps
))
4771 r_u
->rids
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_rids2
);
4774 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4778 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
4779 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4780 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
4785 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4787 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4790 if (r_u
->ptr_types
!= 0) {
4791 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4794 if (r_u
->num_types2
!= r_u
->num_types1
) {
4799 if (UNMARSHALLING(ps
))
4800 r_u
->types
= PRS_ALLOC_MEM(ps
, uint32
, r_u
->num_types2
);
4803 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4807 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4808 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4809 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
4814 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4820 /*******************************************************************
4821 inits a SAMR_Q_DELETE_DOM_USER structure.
4822 ********************************************************************/
4824 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER
* q_c
,
4827 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4829 q_c
->user_pol
= *hnd
;
4832 /*******************************************************************
4833 reads or writes a structure.
4834 ********************************************************************/
4836 BOOL
samr_io_q_delete_dom_user(const char *desc
, SAMR_Q_DELETE_DOM_USER
* q_u
,
4837 prs_struct
*ps
, int depth
)
4842 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_user");
4848 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
4854 /*******************************************************************
4855 reads or writes a structure.
4856 ********************************************************************/
4858 BOOL
samr_io_r_delete_dom_user(const char *desc
, SAMR_R_DELETE_DOM_USER
* r_u
,
4859 prs_struct
*ps
, int depth
)
4864 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_user");
4870 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4872 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4878 /*******************************************************************
4879 reads or writes a structure.
4880 ********************************************************************/
4882 void init_samr_q_open_user(SAMR_Q_OPEN_USER
* q_u
,
4884 uint32 access_mask
, uint32 rid
)
4886 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4888 q_u
->domain_pol
= *pol
;
4889 q_u
->access_mask
= access_mask
;
4890 q_u
->user_rid
= rid
;
4893 /*******************************************************************
4894 reads or writes a structure.
4895 ********************************************************************/
4897 BOOL
samr_io_q_open_user(const char *desc
, SAMR_Q_OPEN_USER
* q_u
,
4898 prs_struct
*ps
, int depth
)
4903 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
4909 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4912 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4914 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
4920 /*******************************************************************
4921 reads or writes a structure.
4922 ********************************************************************/
4924 BOOL
samr_io_r_open_user(const char *desc
, SAMR_R_OPEN_USER
* r_u
,
4925 prs_struct
*ps
, int depth
)
4930 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
4936 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
4939 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4946 /*******************************************************************
4947 reads or writes a structure.
4948 ********************************************************************/
4950 void init_samr_q_create_user(SAMR_Q_CREATE_USER
* q_u
,
4953 uint32 acb_info
, uint32 access_mask
)
4955 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4957 q_u
->domain_pol
= *pol
;
4959 init_unistr2(&q_u
->uni_name
, name
, UNI_FLAGS_NONE
);
4960 init_uni_hdr(&q_u
->hdr_name
, &q_u
->uni_name
);
4962 q_u
->acb_info
= acb_info
;
4963 q_u
->access_mask
= access_mask
;
4966 /*******************************************************************
4967 reads or writes a structure.
4968 ********************************************************************/
4970 BOOL
samr_io_q_create_user(const char *desc
, SAMR_Q_CREATE_USER
* q_u
,
4971 prs_struct
*ps
, int depth
)
4976 prs_debug(ps
, depth
, desc
, "samr_io_q_create_user");
4982 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4985 if(!smb_io_unihdr("hdr_name", &q_u
->hdr_name
, ps
, depth
))
4987 if(!smb_io_unistr2("uni_name", &q_u
->uni_name
, q_u
->hdr_name
.buffer
, ps
, depth
))
4992 if(!prs_uint32("acb_info ", ps
, depth
, &q_u
->acb_info
))
4994 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5000 /*******************************************************************
5001 reads or writes a structure.
5002 ********************************************************************/
5004 BOOL
samr_io_r_create_user(const char *desc
, SAMR_R_CREATE_USER
* r_u
,
5005 prs_struct
*ps
, int depth
)
5010 prs_debug(ps
, depth
, desc
, "samr_io_r_create_user");
5016 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5019 if(!prs_uint32("access_granted", ps
, depth
, &r_u
->access_granted
))
5021 if(!prs_uint32("user_rid ", ps
, depth
, &r_u
->user_rid
))
5023 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5029 /*******************************************************************
5030 inits a SAMR_Q_QUERY_USERINFO structure.
5031 ********************************************************************/
5033 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
5034 const POLICY_HND
*hnd
, uint16 switch_value
)
5036 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5039 q_u
->switch_value
= switch_value
;
5042 /*******************************************************************
5043 reads or writes a structure.
5044 ********************************************************************/
5046 BOOL
samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
5047 prs_struct
*ps
, int depth
)
5052 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
5058 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
5061 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
5067 /*******************************************************************
5068 reads or writes a LOGON_HRS structure.
5069 ********************************************************************/
5071 static BOOL
sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
5072 prs_struct
*ps
, int depth
)
5077 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
5083 if(!prs_uint32("maxlen", ps
, depth
, &hrs
->max_len
))
5086 if(!prs_uint32("offset", ps
, depth
, &hrs
->offset
))
5089 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
5092 if (hrs
->len
> sizeof(hrs
->hours
)) {
5093 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
5094 hrs
->len
= sizeof(hrs
->hours
);
5097 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
5103 /*******************************************************************
5104 inits a SAM_USER_INFO_18 structure.
5105 ********************************************************************/
5107 void init_sam_user_info18(SAM_USER_INFO_18
* usr
,
5108 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
5110 DEBUG(5, ("init_sam_user_info18\n"));
5112 usr
->lm_pwd_active
=
5113 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
5114 usr
->nt_pwd_active
=
5115 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
5118 /*******************************************************************
5119 reads or writes a structure.
5120 ********************************************************************/
5122 static BOOL
sam_io_user_info18(const char *desc
, SAM_USER_INFO_18
* u
,
5123 prs_struct
*ps
, int depth
)
5128 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info18");
5134 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
5136 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
5139 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
5141 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
5147 /*******************************************************************
5148 inits a SAM_USER_INFO_7 structure.
5149 ********************************************************************/
5151 void init_sam_user_info7(SAM_USER_INFO_7
* usr
, const char *name
)
5153 DEBUG(5, ("init_sam_user_info7\n"));
5155 init_unistr2(&usr
->uni_name
, name
, UNI_FLAGS_NONE
); /* unicode string for name */
5156 init_uni_hdr(&usr
->hdr_name
, &usr
->uni_name
); /* unicode header for name */
5160 /*******************************************************************
5161 reads or writes a structure.
5162 ********************************************************************/
5164 static BOOL
sam_io_user_info7(const char *desc
, SAM_USER_INFO_7
* usr
,
5165 prs_struct
*ps
, int depth
)
5170 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info7");
5176 if(!smb_io_unihdr("unihdr", &usr
->hdr_name
, ps
, depth
))
5179 if(!smb_io_unistr2("unistr2", &usr
->uni_name
, True
, ps
, depth
))
5185 /*******************************************************************
5186 inits a SAM_USER_INFO_9 structure.
5187 ********************************************************************/
5189 void init_sam_user_info9(SAM_USER_INFO_9
* usr
, uint32 rid_group
)
5191 DEBUG(5, ("init_sam_user_info9\n"));
5193 usr
->rid_group
= rid_group
;
5196 /*******************************************************************
5197 reads or writes a structure.
5198 ********************************************************************/
5200 static BOOL
sam_io_user_info9(const char *desc
, SAM_USER_INFO_9
* usr
,
5201 prs_struct
*ps
, int depth
)
5206 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info9");
5212 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5218 /*******************************************************************
5219 inits a SAM_USER_INFO_16 structure.
5220 ********************************************************************/
5222 void init_sam_user_info16(SAM_USER_INFO_16
* usr
, uint32 acb_info
)
5224 DEBUG(5, ("init_sam_user_info16\n"));
5226 usr
->acb_info
= acb_info
;
5229 /*******************************************************************
5230 reads or writes a structure.
5231 ********************************************************************/
5233 static BOOL
sam_io_user_info16(const char *desc
, SAM_USER_INFO_16
* usr
,
5234 prs_struct
*ps
, int depth
)
5239 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info16");
5245 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
5251 /*******************************************************************
5252 inits a SAM_USER_INFO_17 structure.
5253 ********************************************************************/
5255 void init_sam_user_info17(SAM_USER_INFO_17
* usr
,
5258 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
5260 DEBUG(5, ("init_sam_user_info17\n"));
5262 memcpy(&usr
->expiry
, expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
5263 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
5265 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
5267 usr
->ptr_1
= 1; /* pointer */
5268 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
5269 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
5271 usr
->ptr_2
= 1; /* pointer */
5272 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
5274 usr
->ptr_3
= 1; /* pointer */
5275 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
5277 usr
->rid_user
= rid_user
;
5278 usr
->rid_group
= rid_group
;
5280 usr
->acct_ctrl
= acct_ctrl
;
5281 usr
->unknown_3
= 0x0000;
5283 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
5284 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
5286 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
5287 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
5289 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, UNI_FLAGS_NONE
); /* unicode string for machine account */
5290 init_uni_hdr(&usr
->hdr_mach_acct
, &usr
->uni_mach_acct
); /* unicode header for machine account */
5293 /*******************************************************************
5294 reads or writes a structure.
5295 ********************************************************************/
5297 static BOOL
sam_io_user_info17(const char *desc
, SAM_USER_INFO_17
* usr
,
5298 prs_struct
*ps
, int depth
)
5303 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_17");
5309 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
5312 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
5315 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
5318 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
5321 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
5324 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
5326 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
5329 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
5332 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
5334 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
5337 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
5339 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
5342 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
5344 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5346 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
5348 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
5350 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
5352 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
5355 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
5358 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
5361 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
5367 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
5373 /*************************************************************************
5375 *************************************************************************/
5377 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516], uint16 pw_len
)
5379 DEBUG(10, ("init_sam_user_info24:\n"));
5380 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5381 usr
->pw_len
= pw_len
;
5384 /*******************************************************************
5385 reads or writes a structure.
5386 ********************************************************************/
5388 static BOOL
sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
5389 prs_struct
*ps
, int depth
)
5394 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
5400 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5404 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
5405 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5414 /*************************************************************************
5415 init_sam_user_info23
5417 unknown_6 = 0x0000 04ec
5419 *************************************************************************/
5421 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5422 NTTIME
* logoff_time
, /* all zeros */
5423 NTTIME
* kickoff_time
, /* all zeros */
5424 NTTIME
* pass_last_set_time
, /* all zeros */
5425 NTTIME
* pass_can_change_time
, /* all zeros */
5426 NTTIME
* pass_must_change_time
, /* all zeros */
5437 uint32 user_rid
, /* 0x0000 0000 */
5440 uint32 fields_present
,
5443 uint16 bad_password_count
,
5447 usr
->logon_time
= *logon_time
; /* all zeros */
5448 usr
->logoff_time
= *logoff_time
; /* all zeros */
5449 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5450 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5451 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5452 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5454 ZERO_STRUCT(usr
->nt_pwd
);
5455 ZERO_STRUCT(usr
->lm_pwd
);
5457 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5458 usr
->group_rid
= group_rid
;
5459 usr
->acb_info
= acb_info
;
5460 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5462 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5463 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5465 if (nt_time_is_zero(pass_must_change_time
)) {
5466 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5468 usr
->passmustchange
=0;
5471 ZERO_STRUCT(usr
->padding1
);
5472 ZERO_STRUCT(usr
->padding2
);
5474 usr
->bad_password_count
= bad_password_count
;
5475 usr
->logon_count
= logon_count
;
5477 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5479 copy_unistr2(&usr
->uni_user_name
, user_name
);
5480 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5482 copy_unistr2(&usr
->uni_full_name
, full_name
);
5483 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5485 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5486 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5488 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5489 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5491 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5492 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5494 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5495 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5497 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5498 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5500 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5501 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5503 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5504 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5506 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5507 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5509 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5512 /*************************************************************************
5513 init_sam_user_info23
5515 unknown_6 = 0x0000 04ec
5517 *************************************************************************/
5519 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5520 NTTIME
* logoff_time
, /* all zeros */
5521 NTTIME
* kickoff_time
, /* all zeros */
5522 NTTIME
* pass_last_set_time
, /* all zeros */
5523 NTTIME
* pass_can_change_time
, /* all zeros */
5524 NTTIME
* pass_must_change_time
, /* all zeros */
5525 char *user_name
, /* NULL */
5527 char *home_dir
, char *dir_drive
, char *log_scr
,
5528 char *prof_path
, const char *desc
, char *wkstas
,
5529 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
5530 uint32 group_rid
, uint32 acb_info
,
5531 uint32 fields_present
, uint16 logon_divs
,
5532 LOGON_HRS
* hrs
, uint16 bad_password_count
, uint16 logon_count
,
5535 DATA_BLOB blob
= base64_decode_data_blob(mung_dial
);
5537 usr
->logon_time
= *logon_time
; /* all zeros */
5538 usr
->logoff_time
= *logoff_time
; /* all zeros */
5539 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5540 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5541 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5542 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5544 ZERO_STRUCT(usr
->nt_pwd
);
5545 ZERO_STRUCT(usr
->lm_pwd
);
5547 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5548 usr
->group_rid
= group_rid
;
5549 usr
->acb_info
= acb_info
;
5550 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5552 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5553 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5555 if (nt_time_is_zero(pass_must_change_time
)) {
5556 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5558 usr
->passmustchange
=0;
5561 ZERO_STRUCT(usr
->padding1
);
5562 ZERO_STRUCT(usr
->padding2
);
5564 usr
->bad_password_count
= bad_password_count
;
5565 usr
->logon_count
= logon_count
;
5567 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5569 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
5570 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5572 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
5573 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5575 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
5576 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5578 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
5579 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5581 init_unistr2(&usr
->uni_logon_script
, log_scr
, UNI_FLAGS_NONE
);
5582 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5584 init_unistr2(&usr
->uni_profile_path
, prof_path
, UNI_FLAGS_NONE
);
5585 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5587 init_unistr2(&usr
->uni_acct_desc
, desc
, UNI_FLAGS_NONE
);
5588 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5590 init_unistr2(&usr
->uni_workstations
, wkstas
, UNI_FLAGS_NONE
);
5591 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5593 init_unistr2(&usr
->uni_unknown_str
, unk_str
, UNI_FLAGS_NONE
);
5594 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5596 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
5597 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5599 data_blob_free(&blob
);
5601 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5604 /*******************************************************************
5605 reads or writes a structure.
5606 ********************************************************************/
5608 static BOOL
sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
5609 prs_struct
*ps
, int depth
)
5614 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
5620 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5622 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5624 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5626 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5628 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5630 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5633 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5635 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5637 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5639 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5641 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5643 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5645 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5647 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5649 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5651 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5654 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5656 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5659 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5661 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5663 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5666 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
5668 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
5672 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
5675 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
5677 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
5680 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
5682 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
5684 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
5688 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5691 /* here begins pointed-to data */
5693 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5696 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5699 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5702 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5705 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5708 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5711 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5714 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5717 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5720 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5723 /* ok, this is only guess-work (as usual) */
5724 if (usr
->ptr_logon_hrs
) {
5725 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5732 /*******************************************************************
5733 reads or writes a structure.
5734 NB. This structure is *definately* incorrect. It's my best guess
5735 currently for W2K SP2. The password field is encrypted in a different
5736 way than normal... And there are definately other problems. JRA.
5737 ********************************************************************/
5739 static BOOL
sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
5744 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
5750 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5752 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5754 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5756 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5758 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5760 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5763 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5765 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5767 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5769 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5771 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5773 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5775 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5777 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5779 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5781 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5784 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5786 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5789 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5791 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5793 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5796 if(!prs_uint32s(False
, "unknown_6 ", ps
, depth
, usr
->unknown_6
, 6))
5799 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5802 /* here begins pointed-to data */
5804 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5807 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5810 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5813 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5816 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5819 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5822 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5825 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5828 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5831 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5834 #if 0 /* JRA - unknown... */
5835 /* ok, this is only guess-work (as usual) */
5836 if (usr
->ptr_logon_hrs
) {
5837 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5846 /*************************************************************************
5847 init_sam_user_info21W
5849 unknown_6 = 0x0000 04ec
5851 *************************************************************************/
5853 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
5854 NTTIME
* logon_time
,
5855 NTTIME
* logoff_time
,
5856 NTTIME
* kickoff_time
,
5857 NTTIME
* pass_last_set_time
,
5858 NTTIME
* pass_can_change_time
,
5859 NTTIME
* pass_must_change_time
,
5875 uint32 fields_present
,
5878 uint16 bad_password_count
,
5881 usr
->logon_time
= *logon_time
;
5882 usr
->logoff_time
= *logoff_time
;
5883 usr
->kickoff_time
= *kickoff_time
;
5884 usr
->pass_last_set_time
= *pass_last_set_time
;
5885 usr
->pass_can_change_time
= *pass_can_change_time
;
5886 usr
->pass_must_change_time
= *pass_must_change_time
;
5888 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
5889 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
5891 usr
->user_rid
= user_rid
;
5892 usr
->group_rid
= group_rid
;
5893 usr
->acb_info
= acb_info
;
5894 usr
->fields_present
= fields_present
; /* 0x00ff ffff */
5896 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5897 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5898 usr
->bad_password_count
= bad_password_count
;
5899 usr
->logon_count
= logon_count
;
5901 if (nt_time_is_zero(pass_must_change_time
)) {
5902 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5904 usr
->passmustchange
=0;
5907 ZERO_STRUCT(usr
->padding1
);
5908 ZERO_STRUCT(usr
->padding2
);
5910 copy_unistr2(&usr
->uni_user_name
, user_name
);
5911 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5913 copy_unistr2(&usr
->uni_full_name
, full_name
);
5914 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5916 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5917 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5919 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5920 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5922 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5923 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5925 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5926 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5928 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5929 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5931 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5932 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5934 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5935 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5937 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5938 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5940 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5943 /*************************************************************************
5944 init_sam_user_info21
5946 unknown_6 = 0x0000 04ec
5948 *************************************************************************/
5950 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, SAM_ACCOUNT
*pw
, DOM_SID
*domain_sid
)
5952 NTTIME logon_time
, logoff_time
, kickoff_time
,
5953 pass_last_set_time
, pass_can_change_time
,
5954 pass_must_change_time
;
5956 const char* user_name
= pdb_get_username(pw
);
5957 const char* full_name
= pdb_get_fullname(pw
);
5958 const char* home_dir
= pdb_get_homedir(pw
);
5959 const char* dir_drive
= pdb_get_dir_drive(pw
);
5960 const char* logon_script
= pdb_get_logon_script(pw
);
5961 const char* profile_path
= pdb_get_profile_path(pw
);
5962 const char* description
= pdb_get_acct_desc(pw
);
5963 const char* workstations
= pdb_get_workstations(pw
);
5964 const char* munged_dial
= pdb_get_munged_dial(pw
);
5965 DATA_BLOB munged_dial_blob
;
5968 const DOM_SID
*user_sid
;
5971 const DOM_SID
*group_sid
;
5974 munged_dial_blob
= base64_decode_data_blob(munged_dial
);
5976 munged_dial_blob
= data_blob(NULL
, 0);
5979 /* Create NTTIME structs */
5980 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
5981 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
5982 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
5983 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
5984 unix_to_nt_time (&pass_can_change_time
, pdb_get_pass_can_change_time(pw
));
5985 unix_to_nt_time (&pass_must_change_time
,pdb_get_pass_must_change_time(pw
));
5987 /* structure assignment */
5988 usr
->logon_time
= logon_time
;
5989 usr
->logoff_time
= logoff_time
;
5990 usr
->kickoff_time
= kickoff_time
;
5991 usr
->pass_last_set_time
= pass_last_set_time
;
5992 usr
->pass_can_change_time
= pass_can_change_time
;
5993 usr
->pass_must_change_time
= pass_must_change_time
;
5995 ZERO_STRUCT(usr
->nt_pwd
);
5996 ZERO_STRUCT(usr
->lm_pwd
);
5998 user_sid
= pdb_get_user_sid(pw
);
6000 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
6001 fstring user_sid_string
;
6002 fstring domain_sid_string
;
6003 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
6004 "the domain sid %s. Failing operation.\n",
6006 sid_to_string(user_sid_string
, user_sid
),
6007 sid_to_string(domain_sid_string
, domain_sid
)));
6008 data_blob_free(&munged_dial_blob
);
6009 return NT_STATUS_UNSUCCESSFUL
;
6012 group_sid
= pdb_get_group_sid(pw
);
6014 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
6015 fstring group_sid_string
;
6016 fstring domain_sid_string
;
6017 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
6018 "which conflicts with the domain sid %s. Failing operation.\n",
6020 sid_to_string(group_sid_string
, group_sid
),
6021 sid_to_string(domain_sid_string
, domain_sid
)));
6022 data_blob_free(&munged_dial_blob
);
6023 return NT_STATUS_UNSUCCESSFUL
;
6026 usr
->user_rid
= user_rid
;
6027 usr
->group_rid
= group_rid
;
6028 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
6031 Look at a user on a real NT4 PDC with usrmgr, press
6032 'ok'. Then you will see that fields_present is set to
6033 0x08f827fa. Look at the user immediately after that again,
6034 and you will see that 0x00fffff is returned. This solves
6035 the problem that you get access denied after having looked
6039 usr
->fields_present
= pdb_build_fields_present(pw
);
6041 usr
->logon_divs
= pdb_get_logon_divs(pw
);
6042 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
6043 usr
->bad_password_count
= pdb_get_bad_password_count(pw
);
6044 usr
->logon_count
= pdb_get_logon_count(pw
);
6046 if (pdb_get_pass_must_change_time(pw
) == 0) {
6047 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6049 usr
->passmustchange
=0;
6052 ZERO_STRUCT(usr
->padding1
);
6053 ZERO_STRUCT(usr
->padding2
);
6055 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_STR_TERMINATE
);
6056 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
6058 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_STR_TERMINATE
);
6059 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
6061 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_STR_TERMINATE
);
6062 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
6064 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_STR_TERMINATE
);
6065 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
6067 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_STR_TERMINATE
);
6068 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
6070 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_STR_TERMINATE
);
6071 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
6073 init_unistr2(&usr
->uni_acct_desc
, description
, UNI_STR_TERMINATE
);
6074 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
6076 init_unistr2(&usr
->uni_workstations
, workstations
, UNI_STR_TERMINATE
);
6077 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
6079 init_unistr2(&usr
->uni_unknown_str
, NULL
, UNI_STR_TERMINATE
);
6080 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
6082 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &munged_dial_blob
);
6083 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6084 data_blob_free(&munged_dial_blob
);
6086 if (pdb_get_hours(pw
)) {
6087 usr
->logon_hrs
.max_len
= 1260;
6088 usr
->logon_hrs
.offset
= 0;
6089 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
6090 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
6092 usr
->logon_hrs
.max_len
= 1260;
6093 usr
->logon_hrs
.offset
= 0;
6094 usr
->logon_hrs
.len
= 0;
6095 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
6098 return NT_STATUS_OK
;
6101 /*******************************************************************
6102 reads or writes a structure.
6103 ********************************************************************/
6105 static BOOL
sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
6106 prs_struct
*ps
, int depth
)
6111 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
6117 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
6119 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
6121 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
6123 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
6125 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
6127 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
6130 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
6132 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
6134 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
6136 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
6138 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
6140 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
6142 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
6144 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
6146 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
6148 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6151 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
6153 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
6156 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
6158 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
6160 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
6163 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
6165 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
6169 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
6172 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
6174 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
6177 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
6179 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
6181 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
6184 /* here begins pointed-to data */
6186 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
6188 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
6190 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
6192 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
6194 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
6196 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
6198 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
6200 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
6202 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
6204 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6207 /* ok, this is only guess-work (as usual) */
6208 if (usr
->ptr_logon_hrs
) {
6209 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
6216 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, SAM_ACCOUNT
*pw
)
6218 const char *munged_dial
= pdb_get_munged_dial(pw
);
6219 DATA_BLOB blob
= base64_decode_data_blob(munged_dial
);
6221 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
6222 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6223 data_blob_free(&blob
);
6226 /*******************************************************************
6227 reads or writes a structure.
6228 ********************************************************************/
6230 static BOOL
sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
6231 prs_struct
*ps
, int depth
)
6236 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
6242 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6245 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6251 /*******************************************************************
6252 inits a SAM_USERINFO_CTR structure.
6253 ********************************************************************/
6255 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
6256 uint16 switch_value
,
6257 SAM_USER_INFO_21
* usr
)
6259 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n"));
6261 ctr
->switch_value
= switch_value
;
6262 ctr
->info
.id
= NULL
;
6264 switch (switch_value
) {
6266 ctr
->info
.id16
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_16
);
6267 if (ctr
->info
.id16
== NULL
)
6268 return NT_STATUS_NO_MEMORY
;
6270 init_sam_user_info16(ctr
->info
.id16
, usr
->acb_info
);
6273 /* whoops - got this wrong. i think. or don't understand what's happening. */
6277 info
= (void *)&id11
;
6279 expire
.low
= 0xffffffff;
6280 expire
.high
= 0x7fffffff;
6282 ctr
->info
.id
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_17
);
6283 init_sam_user_info11(ctr
->info
.id17
, &expire
,
6284 "BROOKFIELDS$", /* name */
6285 0x03ef, /* user rid */
6286 0x201, /* group rid */
6287 0x0080); /* acb info */
6293 ctr
->info
.id18
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_18
);
6294 if (ctr
->info
.id18
== NULL
)
6295 return NT_STATUS_NO_MEMORY
;
6297 init_sam_user_info18(ctr
->info
.id18
, usr
->lm_pwd
, usr
->nt_pwd
);
6301 SAM_USER_INFO_21
*cusr
;
6302 cusr
= TALLOC_ZERO_P(ctx
,SAM_USER_INFO_21
);
6303 ctr
->info
.id21
= cusr
;
6304 if (ctr
->info
.id21
== NULL
)
6305 return NT_STATUS_NO_MEMORY
;
6306 memcpy(cusr
, usr
, sizeof(*usr
));
6307 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
6308 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
6312 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6313 return NT_STATUS_INVALID_INFO_CLASS
;
6316 return NT_STATUS_OK
;
6319 /*******************************************************************
6320 inits a SAM_USERINFO_CTR structure.
6321 ********************************************************************/
6323 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, DATA_BLOB
*sess_key
,
6324 uint16 switch_value
, void *info
)
6326 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6328 ctr
->switch_value
= switch_value
;
6329 ctr
->info
.id
= info
;
6331 switch (switch_value
) {
6333 SamOEMhashBlob(ctr
->info
.id24
->pass
, 516, sess_key
);
6334 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6335 dump_data(100, (char *)ctr
->info
.id24
->pass
, 516);
6338 SamOEMhashBlob(ctr
->info
.id23
->pass
, 516, sess_key
);
6339 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6340 dump_data(100, (char *)ctr
->info
.id23
->pass
, 516);
6345 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value
));
6349 /*******************************************************************
6350 reads or writes a structure.
6351 ********************************************************************/
6353 static BOOL
samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
6354 prs_struct
*ps
, int depth
)
6357 SAM_USERINFO_CTR
*ctr
;
6359 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
6362 if (UNMARSHALLING(ps
)) {
6363 ctr
= PRS_ALLOC_MEM(ps
,SAM_USERINFO_CTR
,1);
6371 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6373 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
6380 switch (ctr
->switch_value
) {
6382 if (UNMARSHALLING(ps
))
6383 ctr
->info
.id7
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_7
,1);
6384 if (ctr
->info
.id7
== NULL
) {
6385 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6388 ret
= sam_io_user_info7("", ctr
->info
.id7
, ps
, depth
);
6391 if (UNMARSHALLING(ps
))
6392 ctr
->info
.id9
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_9
,1);
6393 if (ctr
->info
.id9
== NULL
) {
6394 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6397 ret
= sam_io_user_info9("", ctr
->info
.id9
, ps
, depth
);
6400 if (UNMARSHALLING(ps
))
6401 ctr
->info
.id16
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_16
,1);
6402 if (ctr
->info
.id16
== NULL
) {
6403 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6406 ret
= sam_io_user_info16("", ctr
->info
.id16
, ps
, depth
);
6409 if (UNMARSHALLING(ps
))
6410 ctr
->info
.id17
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_17
,1);
6412 if (ctr
->info
.id17
== NULL
) {
6413 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6416 ret
= sam_io_user_info17("", ctr
->info
.id17
, ps
, depth
);
6419 if (UNMARSHALLING(ps
))
6420 ctr
->info
.id18
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_18
,1);
6422 if (ctr
->info
.id18
== NULL
) {
6423 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6426 ret
= sam_io_user_info18("", ctr
->info
.id18
, ps
, depth
);
6429 if (UNMARSHALLING(ps
))
6430 ctr
->info
.id20
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_20
,1);
6432 if (ctr
->info
.id20
== NULL
) {
6433 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6436 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
6439 if (UNMARSHALLING(ps
))
6440 ctr
->info
.id21
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_21
,1);
6442 if (ctr
->info
.id21
== NULL
) {
6443 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6446 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
6449 if (UNMARSHALLING(ps
))
6450 ctr
->info
.id23
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_23
,1);
6452 if (ctr
->info
.id23
== NULL
) {
6453 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6456 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
6459 if (UNMARSHALLING(ps
))
6460 ctr
->info
.id24
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_24
,1);
6462 if (ctr
->info
.id24
== NULL
) {
6463 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6466 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
6469 if (UNMARSHALLING(ps
))
6470 ctr
->info
.id25
= PRS_ALLOC_MEM(ps
,SAM_USER_INFO_25
,1);
6472 if (ctr
->info
.id25
== NULL
) {
6473 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6476 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
6479 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
6487 /*******************************************************************
6488 inits a SAMR_R_QUERY_USERINFO structure.
6489 ********************************************************************/
6491 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
6492 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
6494 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6499 if (NT_STATUS_IS_OK(status
)) {
6504 r_u
->status
= status
; /* return status */
6507 /*******************************************************************
6508 reads or writes a structure.
6509 ********************************************************************/
6511 BOOL
samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
6512 prs_struct
*ps
, int depth
)
6517 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
6523 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
6526 if (r_u
->ptr
!= 0) {
6527 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
6533 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6539 /*******************************************************************
6540 inits a SAMR_Q_SET_USERINFO structure.
6541 ********************************************************************/
6543 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
6544 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6545 uint16 switch_value
, void *info
)
6547 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6550 q_u
->switch_value
= switch_value
;
6551 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
6554 /*******************************************************************
6555 reads or writes a structure.
6556 ********************************************************************/
6558 BOOL
samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
6559 prs_struct
*ps
, int depth
)
6564 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
6570 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
6572 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6574 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6580 /*******************************************************************
6581 inits a SAMR_R_SET_USERINFO structure.
6582 ********************************************************************/
6584 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
6586 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6588 r_u
->status
= status
; /* return status */
6591 /*******************************************************************
6592 reads or writes a structure.
6593 ********************************************************************/
6595 BOOL
samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
6596 prs_struct
*ps
, int depth
)
6601 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
6607 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6613 /*******************************************************************
6614 inits a SAMR_Q_SET_USERINFO2 structure.
6615 ********************************************************************/
6617 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
6618 const POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6619 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
6621 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6624 q_u
->switch_value
= switch_value
;
6627 if (q_u
->ctr
!= NULL
)
6628 q_u
->ctr
->switch_value
= switch_value
;
6630 switch (switch_value
) {
6632 SamOEMhashBlob(ctr
->info
.id18
->lm_pwd
, 16, sess_key
);
6633 SamOEMhashBlob(ctr
->info
.id18
->nt_pwd
, 16, sess_key
);
6634 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6635 dump_data(100, (char *)ctr
->info
.id18
->lm_pwd
, 16);
6636 dump_data(100, (char *)ctr
->info
.id18
->nt_pwd
, 16);
6641 /*******************************************************************
6642 reads or writes a structure.
6643 ********************************************************************/
6645 BOOL
samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
6646 prs_struct
*ps
, int depth
)
6651 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
6657 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
6660 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6662 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6668 /*******************************************************************
6669 inits a SAMR_R_SET_USERINFO2 structure.
6670 ********************************************************************/
6672 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
6674 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6676 r_u
->status
= status
; /* return status */
6679 /*******************************************************************
6680 reads or writes a structure.
6681 ********************************************************************/
6683 BOOL
samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
6684 prs_struct
*ps
, int depth
)
6689 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
6695 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6701 /*******************************************************************
6702 inits a SAMR_Q_CONNECT structure.
6703 ********************************************************************/
6705 void init_samr_q_connect(SAMR_Q_CONNECT
* q_u
,
6706 char *srv_name
, uint32 access_mask
)
6708 DEBUG(5, ("init_samr_q_connect\n"));
6710 /* make PDC server name \\server */
6711 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6712 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6714 /* example values: 0x0000 0002 */
6715 q_u
->access_mask
= access_mask
;
6718 /*******************************************************************
6719 reads or writes a structure.
6720 ********************************************************************/
6722 BOOL
samr_io_q_connect(const char *desc
, SAMR_Q_CONNECT
* q_u
,
6723 prs_struct
*ps
, int depth
)
6728 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
6734 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6736 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6741 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6747 /*******************************************************************
6748 reads or writes a structure.
6749 ********************************************************************/
6751 BOOL
samr_io_r_connect(const char *desc
, SAMR_R_CONNECT
* r_u
,
6752 prs_struct
*ps
, int depth
)
6757 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
6763 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6766 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6772 /*******************************************************************
6773 inits a SAMR_Q_CONNECT4 structure.
6774 ********************************************************************/
6776 void init_samr_q_connect4(SAMR_Q_CONNECT4
* q_u
,
6777 char *srv_name
, uint32 access_mask
)
6779 DEBUG(5, ("init_samr_q_connect4\n"));
6781 /* make PDC server name \\server */
6782 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6783 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6785 /* Only value we've seen, possibly an address type ? */
6788 /* example values: 0x0000 0002 */
6789 q_u
->access_mask
= access_mask
;
6792 /*******************************************************************
6793 reads or writes a structure.
6794 ********************************************************************/
6796 BOOL
samr_io_q_connect4(const char *desc
, SAMR_Q_CONNECT4
* q_u
,
6797 prs_struct
*ps
, int depth
)
6802 prs_debug(ps
, depth
, desc
, "samr_io_q_connect4");
6808 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6810 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6815 if(!prs_uint32("unk_0", ps
, depth
, &q_u
->unk_0
))
6817 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6823 /*******************************************************************
6824 reads or writes a structure.
6825 ********************************************************************/
6827 BOOL
samr_io_r_connect4(const char *desc
, SAMR_R_CONNECT4
* r_u
,
6828 prs_struct
*ps
, int depth
)
6833 prs_debug(ps
, depth
, desc
, "samr_io_r_connect4");
6839 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6842 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6848 /*******************************************************************
6849 inits a SAMR_Q_CONNECT5 structure.
6850 ********************************************************************/
6852 void init_samr_q_connect5(SAMR_Q_CONNECT5
* q_u
,
6853 char *srv_name
, uint32 access_mask
)
6855 DEBUG(5, ("init_samr_q_connect5\n"));
6857 /* make PDC server name \\server */
6858 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6859 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6861 /* example values: 0x0000 0002 */
6862 q_u
->access_mask
= access_mask
;
6865 q_u
->info1_unk1
= 3;
6866 q_u
->info1_unk2
= 0;
6869 /*******************************************************************
6870 inits a SAMR_R_CONNECT5 structure.
6871 ********************************************************************/
6873 void init_samr_r_connect5(SAMR_R_CONNECT5
* r_u
, POLICY_HND
*pol
, NTSTATUS status
)
6875 DEBUG(5, ("init_samr_q_connect5\n"));
6878 r_u
->info1_unk1
= 3;
6879 r_u
->info1_unk2
= 0;
6881 r_u
->connect_pol
= *pol
;
6882 r_u
->status
= status
;
6885 /*******************************************************************
6886 reads or writes a structure.
6887 ********************************************************************/
6889 BOOL
samr_io_q_connect5(const char *desc
, SAMR_Q_CONNECT5
* q_u
,
6890 prs_struct
*ps
, int depth
)
6895 prs_debug(ps
, depth
, desc
, "samr_io_q_connect5");
6901 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6903 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6908 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6911 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6913 if(!prs_uint32("level", ps
, depth
, &q_u
->level
))
6916 if(!prs_uint32("info1_unk1", ps
, depth
, &q_u
->info1_unk1
))
6918 if(!prs_uint32("info1_unk2", ps
, depth
, &q_u
->info1_unk2
))
6924 /*******************************************************************
6925 reads or writes a structure.
6926 ********************************************************************/
6928 BOOL
samr_io_r_connect5(const char *desc
, SAMR_R_CONNECT5
* r_u
,
6929 prs_struct
*ps
, int depth
)
6934 prs_debug(ps
, depth
, desc
, "samr_io_r_connect5");
6940 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
6942 if(!prs_uint32("level", ps
, depth
, &r_u
->level
))
6944 if(!prs_uint32("info1_unk1", ps
, depth
, &r_u
->info1_unk1
))
6946 if(!prs_uint32("info1_unk2", ps
, depth
, &r_u
->info1_unk2
))
6949 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6952 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6958 /*******************************************************************
6959 inits a SAMR_Q_CONNECT_ANON structure.
6960 ********************************************************************/
6962 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
* q_u
)
6964 DEBUG(5, ("init_samr_q_connect_anon\n"));
6967 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
6968 q_u
->unknown_1
= 0x01;
6969 q_u
->access_mask
= 0x20;
6972 /*******************************************************************
6973 reads or writes a structure.
6974 ********************************************************************/
6976 BOOL
samr_io_q_connect_anon(const char *desc
, SAMR_Q_CONNECT_ANON
* q_u
,
6977 prs_struct
*ps
, int depth
)
6982 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
6988 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
6990 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
6992 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
6994 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
7000 /*******************************************************************
7001 reads or writes a structure.
7002 ********************************************************************/
7004 BOOL
samr_io_r_connect_anon(const char *desc
, SAMR_R_CONNECT_ANON
* r_u
,
7005 prs_struct
*ps
, int depth
)
7010 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
7016 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
7019 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7025 /*******************************************************************
7026 inits a SAMR_Q_GET_DOM_PWINFO structure.
7027 ********************************************************************/
7029 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO
* q_u
,
7032 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
7035 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_FLAGS_NONE
);
7036 init_uni_hdr(&q_u
->hdr_srv_name
, &q_u
->uni_srv_name
);
7039 /*******************************************************************
7040 reads or writes a structure.
7041 ********************************************************************/
7043 BOOL
samr_io_q_get_dom_pwinfo(const char *desc
, SAMR_Q_GET_DOM_PWINFO
* q_u
,
7044 prs_struct
*ps
, int depth
)
7049 prs_debug(ps
, depth
, desc
, "samr_io_q_get_dom_pwinfo");
7055 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
7057 if (q_u
->ptr
!= 0) {
7058 if(!smb_io_unihdr("", &q_u
->hdr_srv_name
, ps
, depth
))
7060 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
7067 /*******************************************************************
7068 reads or writes a structure.
7069 ********************************************************************/
7071 BOOL
samr_io_r_get_dom_pwinfo(const char *desc
, SAMR_R_GET_DOM_PWINFO
* r_u
,
7072 prs_struct
*ps
, int depth
)
7077 prs_debug(ps
, depth
, desc
, "samr_io_r_get_dom_pwinfo");
7083 if(!prs_uint16("min_pwd_length", ps
, depth
, &r_u
->min_pwd_length
))
7087 if(!prs_uint32("password_properties", ps
, depth
, &r_u
->password_properties
))
7090 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7096 /*******************************************************************
7097 make a SAMR_ENC_PASSWD structure.
7098 ********************************************************************/
7100 void init_enc_passwd(SAMR_ENC_PASSWD
* pwd
, const char pass
[512])
7108 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
7112 /*******************************************************************
7113 reads or writes a SAMR_ENC_PASSWD structure.
7114 ********************************************************************/
7116 BOOL
samr_io_enc_passwd(const char *desc
, SAMR_ENC_PASSWD
* pwd
,
7117 prs_struct
*ps
, int depth
)
7122 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
7128 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
7131 if (pwd
->ptr
!= 0) {
7132 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
7139 /*******************************************************************
7140 inits a SAMR_ENC_HASH structure.
7141 ********************************************************************/
7143 void init_enc_hash(SAMR_ENC_HASH
* hsh
, const uchar hash
[16])
7151 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
7155 /*******************************************************************
7156 reads or writes a SAMR_ENC_HASH structure.
7157 ********************************************************************/
7159 BOOL
samr_io_enc_hash(const char *desc
, SAMR_ENC_HASH
* hsh
,
7160 prs_struct
*ps
, int depth
)
7165 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
7171 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
7173 if (hsh
->ptr
!= 0) {
7174 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
,sizeof(hsh
->hash
)))
7181 /*******************************************************************
7182 inits a SAMR_Q_CHGPASSWD_USER structure.
7183 ********************************************************************/
7185 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
* q_u
,
7186 const char *dest_host
, const char *user_name
,
7187 const uchar nt_newpass
[516],
7188 const uchar nt_oldhash
[16],
7189 const uchar lm_newpass
[516],
7190 const uchar lm_oldhash
[16])
7192 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7195 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7196 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7198 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7199 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7201 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7202 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7204 q_u
->unknown
= 0x01;
7206 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7207 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7210 /*******************************************************************
7211 reads or writes a structure.
7212 ********************************************************************/
7214 BOOL
samr_io_q_chgpasswd_user(const char *desc
, SAMR_Q_CHGPASSWD_USER
* q_u
,
7215 prs_struct
*ps
, int depth
)
7220 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
7226 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7229 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7231 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7236 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7238 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7241 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7243 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7246 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7249 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7251 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7257 /*******************************************************************
7258 inits a SAMR_R_CHGPASSWD_USER structure.
7259 ********************************************************************/
7261 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
* r_u
, NTSTATUS status
)
7263 DEBUG(5, ("init_r_chgpasswd_user\n"));
7265 r_u
->status
= status
;
7268 /*******************************************************************
7269 reads or writes a structure.
7270 ********************************************************************/
7272 BOOL
samr_io_r_chgpasswd_user(const char *desc
, SAMR_R_CHGPASSWD_USER
* r_u
,
7273 prs_struct
*ps
, int depth
)
7278 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
7284 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7290 /*******************************************************************
7291 inits a SAMR_Q_CHGPASSWD3 structure.
7292 ********************************************************************/
7294 void init_samr_q_chgpasswd3(SAMR_Q_CHGPASSWD3
* q_u
,
7295 const char *dest_host
, const char *user_name
,
7296 const uchar nt_newpass
[516],
7297 const uchar nt_oldhash
[16],
7298 const uchar lm_newpass
[516],
7299 const uchar lm_oldhash
[16])
7301 DEBUG(5, ("init_samr_q_chgpasswd3\n"));
7304 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7305 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7307 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7308 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7310 init_enc_passwd(&q_u
->nt_newpass
, (const char *)nt_newpass
);
7311 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7313 q_u
->lm_change
= 0x01;
7315 init_enc_passwd(&q_u
->lm_newpass
, (const char *)lm_newpass
);
7316 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7318 init_enc_passwd(&q_u
->password3
, NULL
);
7321 /*******************************************************************
7322 reads or writes a structure.
7323 ********************************************************************/
7325 BOOL
samr_io_q_chgpasswd3(const char *desc
, SAMR_Q_CHGPASSWD3
* q_u
,
7326 prs_struct
*ps
, int depth
)
7331 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd3");
7337 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7340 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7342 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7347 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7349 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7352 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7354 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7357 if(!prs_uint32("lm_change", ps
, depth
, &q_u
->lm_change
))
7360 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7362 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7365 if(!samr_io_enc_passwd("password3", &q_u
->password3
, ps
, depth
))
7371 /*******************************************************************
7372 inits a SAMR_R_CHGPASSWD3 structure.
7373 ********************************************************************/
7375 void init_samr_r_chgpasswd3(SAMR_R_CHGPASSWD3
* r_u
, NTSTATUS status
)
7377 DEBUG(5, ("init_r_chgpasswd3\n"));
7379 r_u
->status
= status
;
7382 /*******************************************************************
7383 Reads or writes an SAMR_CHANGE_REJECT structure.
7384 ********************************************************************/
7386 BOOL
samr_io_change_reject(const char *desc
, SAMR_CHANGE_REJECT
*reject
, prs_struct
*ps
, int depth
)
7391 prs_debug(ps
, depth
, desc
, "samr_io_change_reject");
7397 if(UNMARSHALLING(ps
))
7398 ZERO_STRUCTP(reject
);
7400 if (!prs_uint32("reject_reason", ps
, depth
, &reject
->reject_reason
))
7403 if (!prs_uint32("unknown1", ps
, depth
, &reject
->unknown1
))
7406 if (!prs_uint32("unknown2", ps
, depth
, &reject
->unknown2
))
7412 /*******************************************************************
7413 reads or writes a structure.
7414 ********************************************************************/
7416 BOOL
samr_io_r_chgpasswd3(const char *desc
, SAMR_R_CHGPASSWD3
* r_u
,
7417 prs_struct
*ps
, int depth
)
7419 uint32 ptr_info
, ptr_reject
;
7424 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd3");
7430 if(!prs_uint32("ptr_info", ps
, depth
, &ptr_info
))
7435 /* SAM_UNK_INFO_1 */
7436 if(!sam_io_unk_info1("info", &r_u
->info
, ps
, depth
))
7440 if(!prs_uint32("ptr_reject", ps
, depth
, &ptr_reject
))
7445 /* SAMR_CHANGE_REJECT */
7446 if(!samr_io_change_reject("reject", &r_u
->reject
, ps
, depth
))
7450 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7456 /*******************************************************************
7457 reads or writes a structure.
7458 ********************************************************************/
7460 void init_samr_q_query_domain_info2(SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7461 POLICY_HND
*domain_pol
, uint16 switch_value
)
7463 DEBUG(5, ("init_samr_q_query_domain_info2\n"));
7465 q_u
->domain_pol
= *domain_pol
;
7466 q_u
->switch_value
= switch_value
;
7469 /*******************************************************************
7470 reads or writes a structure.
7471 ********************************************************************/
7473 BOOL
samr_io_q_query_domain_info2(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO2
*q_u
,
7474 prs_struct
*ps
, int depth
)
7479 prs_debug(ps
, depth
, desc
, "samr_io_q_query_domain_info2");
7485 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7488 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7494 /*******************************************************************
7495 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7496 ********************************************************************/
7498 void init_samr_r_samr_query_domain_info2(SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7499 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
7502 DEBUG(5, ("init_samr_r_samr_query_domain_info2\n"));
7505 r_u
->switch_value
= 0;
7506 r_u
->status
= status
; /* return status */
7508 if (NT_STATUS_IS_OK(status
)) {
7509 r_u
->switch_value
= switch_value
;
7515 /*******************************************************************
7516 reads or writes a structure.
7517 ********************************************************************/
7519 BOOL
samr_io_r_samr_query_domain_info2(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO2
* r_u
,
7520 prs_struct
*ps
, int depth
)
7525 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_query_domain_info2");
7531 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
7534 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
7535 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
7540 switch (r_u
->switch_value
) {
7542 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
7546 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
7550 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
7554 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
7558 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
7562 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
7566 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
7570 DEBUG(0, ("samr_io_r_samr_query_domain_info2: unknown switch level 0x%x\n",
7571 r_u
->switch_value
));
7572 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
7580 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7587 /*******************************************************************
7588 reads or writes a structure.
7589 ********************************************************************/
7591 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7592 POLICY_HND
*domain_pol
, uint16 switch_value
, SAM_UNK_CTR
*ctr
)
7594 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7596 q_u
->domain_pol
= *domain_pol
;
7597 q_u
->switch_value0
= switch_value
;
7599 q_u
->switch_value
= switch_value
;
7604 /*******************************************************************
7605 reads or writes a structure.
7606 ********************************************************************/
7608 BOOL
samr_io_q_set_domain_info(const char *desc
, SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7609 prs_struct
*ps
, int depth
)
7614 prs_debug(ps
, depth
, desc
, "samr_io_q_set_domain_info");
7620 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7623 if(!prs_uint16("switch_value0", ps
, depth
, &q_u
->switch_value0
))
7626 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7632 if (UNMARSHALLING(ps
)) {
7633 if ((q_u
->ctr
= PRS_ALLOC_MEM(ps
, SAM_UNK_CTR
, 1)) == NULL
)
7637 switch (q_u
->switch_value
) {
7640 if(!sam_io_unk_info12("unk_inf12", &q_u
->ctr
->info
.inf12
, ps
, depth
))
7644 if(!sam_io_unk_info7("unk_inf7",&q_u
->ctr
->info
.inf7
, ps
,depth
))
7648 if(!sam_io_unk_info6("unk_inf6",&q_u
->ctr
->info
.inf6
, ps
,depth
))
7652 if(!sam_io_unk_info5("unk_inf5",&q_u
->ctr
->info
.inf5
, ps
,depth
))
7656 if(!sam_io_unk_info3("unk_inf3",&q_u
->ctr
->info
.inf3
, ps
,depth
))
7660 if(!sam_io_unk_info2("unk_inf2",&q_u
->ctr
->info
.inf2
, ps
,depth
))
7664 if(!sam_io_unk_info1("unk_inf1",&q_u
->ctr
->info
.inf1
, ps
,depth
))
7668 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7669 q_u
->switch_value
));
7676 /*******************************************************************
7677 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7678 ********************************************************************/
7680 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO
* r_u
, NTSTATUS status
)
7682 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7684 r_u
->status
= status
; /* return status */
7687 /*******************************************************************
7688 reads or writes a structure.
7689 ********************************************************************/
7691 BOOL
samr_io_r_set_domain_info(const char *desc
, SAMR_R_SET_DOMAIN_INFO
* r_u
,
7692 prs_struct
*ps
, int depth
)
7697 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7703 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))