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.
28 #include "rpc_parse.h"
32 #define DBGC_CLASS DBGC_RPC_PARSE
34 /*******************************************************************
35 inits a SAMR_Q_CLOSE_HND structure.
36 ********************************************************************/
38 void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND
* q_c
, POLICY_HND
*hnd
)
40 DEBUG(5, ("init_samr_q_close_hnd\n"));
45 /*******************************************************************
46 reads or writes a structure.
47 ********************************************************************/
49 BOOL
samr_io_q_close_hnd(const char *desc
, SAMR_Q_CLOSE_HND
* q_u
,
50 prs_struct
*ps
, int depth
)
55 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
61 return smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
);
64 /*******************************************************************
65 reads or writes a structure.
66 ********************************************************************/
68 BOOL
samr_io_r_close_hnd(const char *desc
, SAMR_R_CLOSE_HND
* r_u
,
69 prs_struct
*ps
, int depth
)
74 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
80 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
83 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
89 /*******************************************************************
90 inits a SAMR_Q_LOOKUP_DOMAIN structure.
91 ********************************************************************/
93 void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN
* q_u
,
94 POLICY_HND
*pol
, char *dom_name
)
96 DEBUG(5, ("init_samr_q_lookup_domain\n"));
98 q_u
->connect_pol
= *pol
;
100 init_unistr2(&q_u
->uni_domain
, dom_name
, UNI_FLAGS_NONE
);
101 init_uni_hdr(&q_u
->hdr_domain
, &q_u
->uni_domain
);
104 /*******************************************************************
105 reads or writes a structure.
106 ********************************************************************/
107 BOOL
samr_io_q_lookup_domain(const char *desc
, SAMR_Q_LOOKUP_DOMAIN
* q_u
,
108 prs_struct
*ps
, int depth
)
113 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_domain");
119 if(!smb_io_pol_hnd("connect_pol", &q_u
->connect_pol
, ps
, depth
))
122 if(!smb_io_unihdr("hdr_domain", &q_u
->hdr_domain
, ps
, depth
))
125 if(!smb_io_unistr2("uni_domain", &q_u
->uni_domain
, q_u
->hdr_domain
.buffer
, ps
, depth
))
131 /*******************************************************************
132 inits a SAMR_R_LOOKUP_DOMAIN structure.
133 ********************************************************************/
135 void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN
* r_u
,
136 DOM_SID
*dom_sid
, NTSTATUS status
)
138 DEBUG(5, ("init_samr_r_lookup_domain\n"));
140 r_u
->status
= status
;
142 if (NT_STATUS_IS_OK(status
)) {
144 init_dom_sid2(&r_u
->dom_sid
, dom_sid
);
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
152 BOOL
samr_io_r_lookup_domain(const char *desc
, SAMR_R_LOOKUP_DOMAIN
* r_u
,
153 prs_struct
*ps
, int depth
)
158 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_domain");
164 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr_sid
))
167 if (r_u
->ptr_sid
!= 0) {
168 if(!smb_io_dom_sid2("sid", &r_u
->dom_sid
, ps
, depth
))
174 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
180 /*******************************************************************
181 reads or writes a structure.
182 ********************************************************************/
184 void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
, POLICY_HND
*dom_pol
, DOM_SID
*sid
)
186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n"));
188 q_u
->dom_pol
= *dom_pol
;
189 init_dom_sid2(&q_u
->sid
, sid
);
192 /*******************************************************************
193 reads or writes a structure.
194 ********************************************************************/
196 BOOL
samr_io_q_remove_sid_foreign_domain(const char *desc
, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN
* q_u
,
197 prs_struct
*ps
, int depth
)
202 prs_debug(ps
, depth
, desc
, "samr_io_q_remove_sid_foreign_domain");
208 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
211 if(!smb_io_dom_sid2("sid", &q_u
->sid
, ps
, depth
))
220 /*******************************************************************
221 reads or writes a structure.
222 ********************************************************************/
224 BOOL
samr_io_r_remove_sid_foreign_domain(const char *desc
, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN
* r_u
,
225 prs_struct
*ps
, int depth
)
230 prs_debug(ps
, depth
, desc
, "samr_io_r_remove_sid_foreign_domain");
236 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
242 /*******************************************************************
243 reads or writes a structure.
244 ********************************************************************/
246 void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
* q_u
,
247 POLICY_HND
*pol
, uint32 flags
,
250 DEBUG(5, ("samr_init_samr_q_open_domain\n"));
254 init_dom_sid2(&q_u
->dom_sid
, sid
);
257 /*******************************************************************
258 reads or writes a structure.
259 ********************************************************************/
261 BOOL
samr_io_q_open_domain(const char *desc
, SAMR_Q_OPEN_DOMAIN
* q_u
,
262 prs_struct
*ps
, int depth
)
267 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
273 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
276 if(!prs_uint32("flags", ps
, depth
, &q_u
->flags
))
279 if(!smb_io_dom_sid2("sid", &q_u
->dom_sid
, ps
, depth
))
285 /*******************************************************************
286 reads or writes a structure.
287 ********************************************************************/
289 BOOL
samr_io_r_open_domain(const char *desc
, SAMR_R_OPEN_DOMAIN
* r_u
,
290 prs_struct
*ps
, int depth
)
295 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
301 if(!smb_io_pol_hnd("domain_pol", &r_u
->domain_pol
, ps
, depth
))
304 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
310 /*******************************************************************
311 reads or writes a structure.
312 ********************************************************************/
314 void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
315 POLICY_HND
*user_pol
)
317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n"));
319 q_u
->user_pol
= *user_pol
;
322 /*******************************************************************
323 reads or writes a structure.
324 ********************************************************************/
326 BOOL
samr_io_q_get_usrdom_pwinfo(const char *desc
, SAMR_Q_GET_USRDOM_PWINFO
* q_u
,
327 prs_struct
*ps
, int depth
)
332 prs_debug(ps
, depth
, desc
, "samr_io_q_get_usrdom_pwinfo");
338 return smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
);
341 /*******************************************************************
343 ********************************************************************/
345 void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO
*r_u
, NTSTATUS status
)
347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n"));
349 r_u
->unknown_0
= 0x0000;
353 * r_u->unknown_1 = 0x0015;
356 r_u
->unknown_1
= 0x01D1;
357 r_u
->unknown_1
= 0x0015;
359 r_u
->unknown_2
= 0x00000000;
361 r_u
->status
= status
;
364 /*******************************************************************
365 reads or writes a structure.
366 ********************************************************************/
368 BOOL
samr_io_r_get_usrdom_pwinfo(const char *desc
, SAMR_R_GET_USRDOM_PWINFO
* r_u
,
369 prs_struct
*ps
, int depth
)
374 prs_debug(ps
, depth
, desc
, "samr_io_r_get_usrdom_pwinfo");
380 if(!prs_uint16("unknown_0", ps
, depth
, &r_u
->unknown_0
))
382 if(!prs_uint16("unknown_1", ps
, depth
, &r_u
->unknown_1
))
384 if(!prs_uint32("unknown_2", ps
, depth
, &r_u
->unknown_2
))
386 if(!prs_ntstatus("status ", ps
, depth
, &r_u
->status
))
393 /*******************************************************************
394 reads or writes a structure.
395 ********************************************************************/
397 BOOL
samr_io_q_set_sec_obj(const char *desc
, SAMR_Q_SET_SEC_OBJ
* q_u
,
398 prs_struct
*ps
, int depth
)
403 prs_debug(ps
, depth
, desc
, "samr_io_q_set_sec_obj");
409 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
412 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
415 if(!sec_io_desc_buf("sec_desc", &q_u
->buf
, ps
, depth
))
422 /*******************************************************************
423 reads or writes a structure.
424 ********************************************************************/
426 void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ
* q_u
,
427 POLICY_HND
*user_pol
, uint32 sec_info
)
429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n"));
431 q_u
->user_pol
= *user_pol
;
432 q_u
->sec_info
= sec_info
;
436 /*******************************************************************
437 reads or writes a structure.
438 ********************************************************************/
440 BOOL
samr_io_q_query_sec_obj(const char *desc
, SAMR_Q_QUERY_SEC_OBJ
* q_u
,
441 prs_struct
*ps
, int depth
)
446 prs_debug(ps
, depth
, desc
, "samr_io_q_query_sec_obj");
452 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
455 if(!prs_uint32("sec_info", ps
, depth
, &q_u
->sec_info
))
461 /*******************************************************************
462 reads or writes a structure.
463 ********************************************************************/
465 void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
466 POLICY_HND
*domain_pol
, uint16 switch_value
)
468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n"));
470 q_u
->domain_pol
= *domain_pol
;
471 q_u
->switch_value
= switch_value
;
474 /*******************************************************************
475 reads or writes a structure.
476 ********************************************************************/
478 BOOL
samr_io_q_query_dom_info(const char *desc
, SAMR_Q_QUERY_DOMAIN_INFO
* q_u
,
479 prs_struct
*ps
, int depth
)
484 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dom_info");
490 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
493 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
500 /*******************************************************************
502 ********************************************************************/
504 void init_unk_info3(SAM_UNK_INFO_3
*u_3
, NTTIME nt_logout
)
506 u_3
->logout
.low
= nt_logout
.low
;
507 u_3
->logout
.high
= nt_logout
.high
;
510 /*******************************************************************
511 reads or writes a structure.
512 ********************************************************************/
514 static BOOL
sam_io_unk_info3(const char *desc
, SAM_UNK_INFO_3
* u_3
,
515 prs_struct
*ps
, int depth
)
520 prs_debug(ps
, depth
, desc
, "sam_io_unk_info3");
523 if(!smb_io_time("logout", &u_3
->logout
, ps
, depth
))
529 /*******************************************************************
531 ********************************************************************/
533 void init_unk_info6(SAM_UNK_INFO_6
* u_6
)
535 u_6
->unknown_0
= 0x00000000;
537 memset(u_6
->padding
, 0, sizeof(u_6
->padding
)); /* 12 bytes zeros */
540 /*******************************************************************
541 reads or writes a structure.
542 ********************************************************************/
544 static BOOL
sam_io_unk_info6(const char *desc
, SAM_UNK_INFO_6
* u_6
,
545 prs_struct
*ps
, int depth
)
550 prs_debug(ps
, depth
, desc
, "sam_io_unk_info6");
553 if(!prs_uint32("unknown_0", ps
, depth
, &u_6
->unknown_0
)) /* 0x0000 0000 */
555 if(!prs_uint32("ptr_0", ps
, depth
, &u_6
->ptr_0
)) /* pointer to unknown structure */
557 if(!prs_uint8s(False
, "padding", ps
, depth
, u_6
->padding
, sizeof(u_6
->padding
))) /* 12 bytes zeros */
563 /*******************************************************************
565 ********************************************************************/
567 void init_unk_info7(SAM_UNK_INFO_7
* u_7
)
569 u_7
->unknown_0
= 0x0003;
572 /*******************************************************************
573 reads or writes a structure.
574 ********************************************************************/
576 static BOOL
sam_io_unk_info7(const char *desc
, SAM_UNK_INFO_7
* u_7
,
577 prs_struct
*ps
, int depth
)
582 prs_debug(ps
, depth
, desc
, "sam_io_unk_info7");
585 if(!prs_uint16("unknown_0", ps
, depth
, &u_7
->unknown_0
)) /* 0x0003 */
591 /*******************************************************************
593 ********************************************************************/
595 void init_unk_info12(SAM_UNK_INFO_12
* u_12
, NTTIME nt_lock_duration
, NTTIME nt_reset_time
, uint16 lockout
)
597 u_12
->duration
.low
= nt_lock_duration
.low
;
598 u_12
->duration
.high
= nt_lock_duration
.high
;
599 u_12
->reset_count
.low
= nt_reset_time
.low
;
600 u_12
->reset_count
.high
= nt_reset_time
.high
;
602 u_12
->bad_attempt_lockout
= lockout
;
605 /*******************************************************************
606 reads or writes a structure.
607 ********************************************************************/
609 static BOOL
sam_io_unk_info12(const char *desc
, SAM_UNK_INFO_12
* u_12
,
610 prs_struct
*ps
, int depth
)
615 prs_debug(ps
, depth
, desc
, "sam_io_unk_info12");
618 if(!smb_io_time("duration", &u_12
->duration
, ps
, depth
))
620 if(!smb_io_time("reset_count", &u_12
->reset_count
, ps
, depth
))
622 if(!prs_uint16("bad_attempt_lockout", ps
, depth
, &u_12
->bad_attempt_lockout
))
628 /*******************************************************************
630 ********************************************************************/
632 void init_unk_info5(SAM_UNK_INFO_5
* u_5
,const char *server
)
634 init_unistr2(&u_5
->uni_server
, server
, UNI_FLAGS_NONE
);
635 init_uni_hdr(&u_5
->hdr_server
, &u_5
->uni_server
);
638 /*******************************************************************
639 reads or writes a structure.
640 ********************************************************************/
642 static BOOL
sam_io_unk_info5(const char *desc
, SAM_UNK_INFO_5
* u_5
,
643 prs_struct
*ps
, int depth
)
648 prs_debug(ps
, depth
, desc
, "sam_io_unk_info5");
651 if(!smb_io_unihdr("hdr_server", &u_5
->hdr_server
, ps
, depth
))
654 if(!smb_io_unistr2("uni_server", &u_5
->uni_server
, u_5
->hdr_server
.buffer
, ps
, depth
))
660 /*******************************************************************
662 ********************************************************************/
664 void init_unk_info2(SAM_UNK_INFO_2
* u_2
,
665 const char *domain
, const char *server
,
666 uint32 seq_num
, uint32 num_users
, uint32 num_groups
, uint32 num_alias
)
668 u_2
->unknown_0
= 0x00000000;
669 u_2
->unknown_1
= 0x80000000;
670 u_2
->unknown_2
= 0x00000000;
674 u_2
->seq_num
= seq_num
;
675 u_2
->unknown_3
= 0x00000000;
677 u_2
->unknown_4
= 0x00000001;
678 u_2
->unknown_5
= 0x00000003;
679 u_2
->unknown_6
= 0x00000001;
680 u_2
->num_domain_usrs
= num_users
;
681 u_2
->num_domain_grps
= num_groups
;
682 u_2
->num_local_grps
= num_alias
;
684 memset(u_2
->padding
, 0, sizeof(u_2
->padding
)); /* 12 bytes zeros */
686 init_unistr2(&u_2
->uni_domain
, domain
, UNI_FLAGS_NONE
);
687 init_uni_hdr(&u_2
->hdr_domain
, &u_2
->uni_domain
);
688 init_unistr2(&u_2
->uni_server
, server
, UNI_FLAGS_NONE
);
689 init_uni_hdr(&u_2
->hdr_server
, &u_2
->uni_server
);
692 /*******************************************************************
693 reads or writes a structure.
694 ********************************************************************/
696 static BOOL
sam_io_unk_info2(const char *desc
, SAM_UNK_INFO_2
* u_2
,
697 prs_struct
*ps
, int depth
)
702 prs_debug(ps
, depth
, desc
, "sam_io_unk_info2");
705 if(!prs_uint32("unknown_0", ps
, depth
, &u_2
->unknown_0
)) /* 0x0000 0000 */
707 if(!prs_uint32("unknown_1", ps
, depth
, &u_2
->unknown_1
)) /* 0x8000 0000 */
709 if(!prs_uint32("unknown_2", ps
, depth
, &u_2
->unknown_2
)) /* 0x0000 0000 */
712 if(!prs_uint32("ptr_0", ps
, depth
, &u_2
->ptr_0
))
714 if(!smb_io_unihdr("hdr_domain", &u_2
->hdr_domain
, ps
, depth
))
716 if(!smb_io_unihdr("hdr_server", &u_2
->hdr_server
, ps
, depth
))
719 /* put all the data in here, at the moment, including what the above
720 pointer is referring to
723 if(!prs_uint32("seq_num ", ps
, depth
, &u_2
->seq_num
)) /* 0x0000 0099 or 0x1000 0000 */
725 if(!prs_uint32("unknown_3 ", ps
, depth
, &u_2
->unknown_3
)) /* 0x0000 0000 */
728 if(!prs_uint32("unknown_4 ", ps
, depth
, &u_2
->unknown_4
)) /* 0x0000 0001 */
730 if(!prs_uint32("unknown_5 ", ps
, depth
, &u_2
->unknown_5
)) /* 0x0000 0003 */
732 if(!prs_uint32("unknown_6 ", ps
, depth
, &u_2
->unknown_6
)) /* 0x0000 0001 */
734 if(!prs_uint32("num_domain_usrs ", ps
, depth
, &u_2
->num_domain_usrs
))
736 if(!prs_uint32("num_domain_grps", ps
, depth
, &u_2
->num_domain_grps
))
738 if(!prs_uint32("num_local_grps", ps
, depth
, &u_2
->num_local_grps
))
742 /* this was originally marked as 'padding'. It isn't
743 padding, it is some sort of optional 12 byte
744 structure. When it is present it contains zeros
746 if(!prs_uint8s(False
, "unknown", ps
, depth
, u_2
->padding
,sizeof(u_2
->padding
)))
750 if(!smb_io_unistr2("uni_domain", &u_2
->uni_domain
, u_2
->hdr_domain
.buffer
, ps
, depth
))
752 if(!smb_io_unistr2("uni_server", &u_2
->uni_server
, u_2
->hdr_server
.buffer
, ps
, depth
))
758 /*******************************************************************
760 ********************************************************************/
762 void init_unk_info1(SAM_UNK_INFO_1
*u_1
, uint16 min_pass_len
, uint16 pass_hist
,
763 uint32 flag
, NTTIME nt_expire
, NTTIME nt_min_age
)
765 u_1
->min_length_password
= min_pass_len
;
766 u_1
->password_history
= pass_hist
;
769 /* password never expire */
770 u_1
->expire
.high
= nt_expire
.high
;
771 u_1
->expire
.low
= nt_expire
.low
;
773 /* can change the password now */
774 u_1
->min_passwordage
.high
= nt_min_age
.high
;
775 u_1
->min_passwordage
.low
= nt_min_age
.low
;
779 /*******************************************************************
780 reads or writes a structure.
781 ********************************************************************/
783 static BOOL
sam_io_unk_info1(const char *desc
, SAM_UNK_INFO_1
* u_1
,
784 prs_struct
*ps
, int depth
)
789 prs_debug(ps
, depth
, desc
, "sam_io_unk_info1");
792 if(!prs_uint16("min_length_password", ps
, depth
, &u_1
->min_length_password
))
794 if(!prs_uint16("password_history", ps
, depth
, &u_1
->password_history
))
796 if(!prs_uint32("flag", ps
, depth
, &u_1
->flag
))
798 if(!smb_io_time("expire", &u_1
->expire
, ps
, depth
))
800 if(!smb_io_time("min_passwordage", &u_1
->min_passwordage
, ps
, depth
))
806 /*******************************************************************
807 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
808 ********************************************************************/
810 void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
811 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
814 DEBUG(5, ("init_samr_r_query_dom_info\n"));
817 r_u
->switch_value
= 0;
818 r_u
->status
= status
; /* return status */
820 if (NT_STATUS_IS_OK(status
)) {
821 r_u
->switch_value
= switch_value
;
827 /*******************************************************************
828 reads or writes a structure.
829 ********************************************************************/
831 BOOL
samr_io_r_query_dom_info(const char *desc
, SAMR_R_QUERY_DOMAIN_INFO
* r_u
,
832 prs_struct
*ps
, int depth
)
837 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dom_info");
843 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
846 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
847 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
852 switch (r_u
->switch_value
) {
854 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
858 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
862 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
866 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
870 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
874 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
878 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
882 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n",
884 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
892 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
898 /*******************************************************************
899 reads or writes a SAMR_R_SET_SEC_OBJ structure.
900 ********************************************************************/
902 BOOL
samr_io_r_set_sec_obj(const char *desc
, SAMR_R_SET_SEC_OBJ
* r_u
,
903 prs_struct
*ps
, int depth
)
908 prs_debug(ps
, depth
, desc
, "samr_io_r_set_sec_obj");
914 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
920 /*******************************************************************
921 reads or writes a SAMR_R_QUERY_SEC_OBJ structure.
922 ********************************************************************/
924 BOOL
samr_io_r_query_sec_obj(const char *desc
, SAMR_R_QUERY_SEC_OBJ
* r_u
,
925 prs_struct
*ps
, int depth
)
930 prs_debug(ps
, depth
, desc
, "samr_io_r_query_sec_obj");
936 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
939 if(!sec_io_desc_buf("sec", &r_u
->buf
, ps
, depth
))
943 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
949 /*******************************************************************
950 reads or writes a SAM_STR1 structure.
951 ********************************************************************/
953 static BOOL
sam_io_sam_str1(const char *desc
, SAM_STR1
* sam
, uint32 acct_buf
,
954 uint32 name_buf
, uint32 desc_buf
,
955 prs_struct
*ps
, int depth
)
960 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
965 if (!smb_io_unistr2("name", &sam
->uni_acct_name
, acct_buf
, ps
, depth
))
968 if (!smb_io_unistr2("desc", &sam
->uni_acct_desc
, desc_buf
, ps
, depth
))
971 if (!smb_io_unistr2("full", &sam
->uni_full_name
, name_buf
, ps
, depth
))
977 /*******************************************************************
978 inits a SAM_ENTRY1 structure.
979 ********************************************************************/
981 static void init_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
982 UNISTR2
*sam_name
, UNISTR2
*sam_full
,
983 UNISTR2
*sam_desc
, uint32 rid_user
,
986 DEBUG(5, ("init_sam_entry1\n"));
990 sam
->user_idx
= user_idx
;
991 sam
->rid_user
= rid_user
;
992 sam
->acb_info
= acb_info
;
994 init_uni_hdr(&sam
->hdr_acct_name
, sam_name
);
995 init_uni_hdr(&sam
->hdr_user_name
, sam_full
);
996 init_uni_hdr(&sam
->hdr_user_desc
, sam_desc
);
999 /*******************************************************************
1000 reads or writes a SAM_ENTRY1 structure.
1001 ********************************************************************/
1003 static BOOL
sam_io_sam_entry1(const char *desc
, SAM_ENTRY1
* sam
,
1004 prs_struct
*ps
, int depth
)
1009 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
1015 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1018 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1020 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1026 if (!smb_io_unihdr("hdr_acct_name", &sam
->hdr_acct_name
, ps
, depth
))
1028 if (!smb_io_unihdr("hdr_user_desc", &sam
->hdr_user_desc
, ps
, depth
))
1030 if (!smb_io_unihdr("hdr_user_name", &sam
->hdr_user_name
, ps
, depth
))
1036 /*******************************************************************
1037 reads or writes a SAM_STR2 structure.
1038 ********************************************************************/
1040 static BOOL
sam_io_sam_str2(const char *desc
, SAM_STR2
* sam
, uint32 acct_buf
,
1041 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1046 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
1052 if(!smb_io_unistr2("uni_srv_name", &sam
->uni_srv_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1054 if(!smb_io_unistr2("uni_srv_desc", &sam
->uni_srv_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1060 /*******************************************************************
1061 inits a SAM_ENTRY2 structure.
1062 ********************************************************************/
1063 static void init_sam_entry2(SAM_ENTRY2
* sam
, uint32 user_idx
,
1064 UNISTR2
*sam_name
, UNISTR2
*sam_desc
,
1065 uint32 rid_user
, uint16 acb_info
)
1067 DEBUG(5, ("init_sam_entry2\n"));
1069 sam
->user_idx
= user_idx
;
1070 sam
->rid_user
= rid_user
;
1071 sam
->acb_info
= acb_info
;
1073 init_uni_hdr(&sam
->hdr_srv_name
, sam_name
);
1074 init_uni_hdr(&sam
->hdr_srv_desc
, sam_desc
);
1077 /*******************************************************************
1078 reads or writes a SAM_ENTRY2 structure.
1079 ********************************************************************/
1081 static BOOL
sam_io_sam_entry2(const char *desc
, SAM_ENTRY2
* sam
,
1082 prs_struct
*ps
, int depth
)
1087 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
1093 if(!prs_uint32("user_idx ", ps
, depth
, &sam
->user_idx
))
1096 if(!prs_uint32("rid_user ", ps
, depth
, &sam
->rid_user
))
1098 if(!prs_uint16("acb_info ", ps
, depth
, &sam
->acb_info
))
1104 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_name
, ps
, depth
)) /* account name unicode string header */
1106 if(!smb_io_unihdr("unihdr", &sam
->hdr_srv_desc
, ps
, depth
)) /* account name unicode string header */
1112 /*******************************************************************
1113 reads or writes a SAM_STR3 structure.
1114 ********************************************************************/
1116 static BOOL
sam_io_sam_str3(const char *desc
, SAM_STR3
* sam
, uint32 acct_buf
,
1117 uint32 desc_buf
, prs_struct
*ps
, int depth
)
1122 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
1128 if(!smb_io_unistr2("uni_grp_name", &sam
->uni_grp_name
, acct_buf
, ps
, depth
)) /* account name unicode string */
1130 if(!smb_io_unistr2("uni_grp_desc", &sam
->uni_grp_desc
, desc_buf
, ps
, depth
)) /* account desc unicode string */
1136 /*******************************************************************
1137 inits a SAM_ENTRY3 structure.
1138 ********************************************************************/
1140 static void init_sam_entry3(SAM_ENTRY3
* sam
, uint32 grp_idx
,
1141 UNISTR2
*grp_name
, UNISTR2
*grp_desc
,
1144 DEBUG(5, ("init_sam_entry3\n"));
1146 sam
->grp_idx
= grp_idx
;
1147 sam
->rid_grp
= rid_grp
;
1148 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
1150 init_uni_hdr(&sam
->hdr_grp_name
, grp_name
);
1151 init_uni_hdr(&sam
->hdr_grp_desc
, grp_desc
);
1154 /*******************************************************************
1155 reads or writes a SAM_ENTRY3 structure.
1156 ********************************************************************/
1158 static BOOL
sam_io_sam_entry3(const char *desc
, SAM_ENTRY3
* sam
,
1159 prs_struct
*ps
, int depth
)
1164 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
1170 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1173 if(!prs_uint32("rid_grp", ps
, depth
, &sam
->rid_grp
))
1175 if(!prs_uint32("attr ", ps
, depth
, &sam
->attr
))
1178 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_name
, ps
, depth
)) /* account name unicode string header */
1180 if(!smb_io_unihdr("unihdr", &sam
->hdr_grp_desc
, ps
, depth
)) /* account name unicode string header */
1186 /*******************************************************************
1187 inits a SAM_ENTRY4 structure.
1188 ********************************************************************/
1190 static void init_sam_entry4(SAM_ENTRY4
* sam
, uint32 user_idx
,
1191 uint32 len_acct_name
)
1193 DEBUG(5, ("init_sam_entry4\n"));
1195 sam
->user_idx
= user_idx
;
1196 init_str_hdr(&sam
->hdr_acct_name
, len_acct_name
+1, len_acct_name
, len_acct_name
!= 0);
1199 /*******************************************************************
1200 reads or writes a SAM_ENTRY4 structure.
1201 ********************************************************************/
1203 static BOOL
sam_io_sam_entry4(const char *desc
, SAM_ENTRY4
* sam
,
1204 prs_struct
*ps
, int depth
)
1209 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry4");
1215 if(!prs_uint32("user_idx", ps
, depth
, &sam
->user_idx
))
1217 if(!smb_io_strhdr("strhdr", &sam
->hdr_acct_name
, ps
, depth
))
1223 /*******************************************************************
1224 inits a SAM_ENTRY5 structure.
1225 ********************************************************************/
1227 static void init_sam_entry5(SAM_ENTRY5
* sam
, uint32 grp_idx
,
1228 uint32 len_grp_name
)
1230 DEBUG(5, ("init_sam_entry5\n"));
1232 sam
->grp_idx
= grp_idx
;
1233 init_str_hdr(&sam
->hdr_grp_name
, len_grp_name
, len_grp_name
,
1237 /*******************************************************************
1238 reads or writes a SAM_ENTRY5 structure.
1239 ********************************************************************/
1241 static BOOL
sam_io_sam_entry5(const char *desc
, SAM_ENTRY5
* sam
,
1242 prs_struct
*ps
, int depth
)
1247 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry5");
1253 if(!prs_uint32("grp_idx", ps
, depth
, &sam
->grp_idx
))
1255 if(!smb_io_strhdr("strhdr", &sam
->hdr_grp_name
, ps
, depth
))
1261 /*******************************************************************
1262 inits a SAM_ENTRY structure.
1263 ********************************************************************/
1265 void init_sam_entry(SAM_ENTRY
*sam
, UNISTR2
*uni2
, uint32 rid
)
1267 DEBUG(10, ("init_sam_entry: %d\n", rid
));
1270 init_uni_hdr(&sam
->hdr_name
, uni2
);
1273 /*******************************************************************
1274 reads or writes a SAM_ENTRY structure.
1275 ********************************************************************/
1277 static BOOL
sam_io_sam_entry(const char *desc
, SAM_ENTRY
* sam
,
1278 prs_struct
*ps
, int depth
)
1283 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
1288 if(!prs_uint32("rid", ps
, depth
, &sam
->rid
))
1290 if(!smb_io_unihdr("unihdr", &sam
->hdr_name
, ps
, depth
)) /* account name unicode string header */
1296 /*******************************************************************
1297 inits a SAMR_Q_ENUM_DOM_USERS structure.
1298 ********************************************************************/
1300 void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
* q_e
, POLICY_HND
*pol
,
1302 uint16 acb_mask
, uint16 unk_1
, uint32 size
)
1304 DEBUG(5, ("init_samr_q_enum_dom_users\n"));
1308 q_e
->start_idx
= start_idx
; /* zero indicates lots */
1309 q_e
->acb_mask
= acb_mask
;
1310 q_e
->unknown_1
= unk_1
;
1311 q_e
->max_size
= size
;
1314 /*******************************************************************
1315 reads or writes a structure.
1316 ********************************************************************/
1318 BOOL
samr_io_q_enum_dom_users(const char *desc
, SAMR_Q_ENUM_DOM_USERS
* q_e
,
1319 prs_struct
*ps
, int depth
)
1324 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
1330 if(!smb_io_pol_hnd("domain_pol", &q_e
->pol
, ps
, depth
))
1333 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
1335 if(!prs_uint16("acb_mask ", ps
, depth
, &q_e
->acb_mask
))
1337 if(!prs_uint16("unknown_1", ps
, depth
, &q_e
->unknown_1
))
1340 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1347 /*******************************************************************
1348 inits a SAMR_R_ENUM_DOM_USERS structure.
1349 ********************************************************************/
1351 void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
* r_u
,
1352 uint32 next_idx
, uint32 num_sam_entries
)
1354 DEBUG(5, ("init_samr_r_enum_dom_users\n"));
1356 r_u
->next_idx
= next_idx
;
1358 if (num_sam_entries
!= 0) {
1359 r_u
->ptr_entries1
= 1;
1360 r_u
->ptr_entries2
= 1;
1361 r_u
->num_entries2
= num_sam_entries
;
1362 r_u
->num_entries3
= num_sam_entries
;
1364 r_u
->num_entries4
= num_sam_entries
;
1366 r_u
->ptr_entries1
= 0;
1367 r_u
->num_entries2
= num_sam_entries
;
1368 r_u
->ptr_entries2
= 1;
1372 /*******************************************************************
1373 reads or writes a structure.
1374 ********************************************************************/
1376 BOOL
samr_io_r_enum_dom_users(const char *desc
, SAMR_R_ENUM_DOM_USERS
* r_u
,
1377 prs_struct
*ps
, int depth
)
1384 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
1390 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
1392 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
1395 if (r_u
->ptr_entries1
!= 0) {
1396 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
1398 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
1400 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
1403 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
!= 0)) {
1404 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
1405 r_u
->uni_acct_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
1408 if ((r_u
->sam
== NULL
|| r_u
->uni_acct_name
== NULL
) && r_u
->num_entries2
!= 0) {
1409 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n"));
1410 r_u
->num_entries4
= 0;
1411 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
1415 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1416 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
1420 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
1421 if(!smb_io_unistr2("", &r_u
->uni_acct_name
[i
],r_u
->sam
[i
].hdr_name
.buffer
, ps
,depth
))
1430 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
1432 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
1438 /*******************************************************************
1439 inits a SAMR_Q_QUERY_DISPINFO structure.
1440 ********************************************************************/
1442 void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
* q_e
, POLICY_HND
*pol
,
1443 uint16 switch_level
, uint32 start_idx
,
1444 uint32 max_entries
, uint32 max_size
)
1446 DEBUG(5, ("init_samr_q_query_dispinfo\n"));
1448 q_e
->domain_pol
= *pol
;
1450 q_e
->switch_level
= switch_level
;
1452 q_e
->start_idx
= start_idx
;
1453 q_e
->max_entries
= max_entries
;
1454 q_e
->max_size
= max_size
;
1457 /*******************************************************************
1458 reads or writes a structure.
1459 ********************************************************************/
1461 BOOL
samr_io_q_query_dispinfo(const char *desc
, SAMR_Q_QUERY_DISPINFO
* q_e
,
1462 prs_struct
*ps
, int depth
)
1467 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
1473 if(!smb_io_pol_hnd("domain_pol", &q_e
->domain_pol
, ps
, depth
))
1476 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
1481 if(!prs_uint32("start_idx ", ps
, depth
, &q_e
->start_idx
))
1483 if(!prs_uint32("max_entries ", ps
, depth
, &q_e
->max_entries
))
1485 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
1491 /*******************************************************************
1492 inits a SAM_DISPINFO_1 structure.
1493 ********************************************************************/
1495 NTSTATUS
init_sam_dispinfo_1(TALLOC_CTX
*ctx
, SAM_DISPINFO_1
*sam
, uint32 num_entries
,
1496 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
,
1497 DOM_SID
*domain_sid
)
1501 SAM_ACCOUNT
*pwd
= NULL
;
1504 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries
));
1507 return NT_STATUS_OK
;
1509 sam
->sam
=(SAM_ENTRY1
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY1
));
1511 return NT_STATUS_NO_MEMORY
;
1513 sam
->str
=(SAM_STR1
*)talloc(ctx
, num_entries
*sizeof(SAM_STR1
));
1515 return NT_STATUS_NO_MEMORY
;
1517 ZERO_STRUCTP(sam
->sam
);
1518 ZERO_STRUCTP(sam
->str
);
1520 for (i
= 0; i
< num_entries
; i
++) {
1521 const char *username
;
1522 const char *fullname
;
1523 const char *acct_desc
;
1525 const DOM_SID
*user_sid
;
1526 fstring user_sid_string
, domain_sid_string
;
1528 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i
));
1530 pwd
=&disp_user_info
[i
+start_idx
];
1532 username
= pdb_get_username(pwd
);
1533 fullname
= pdb_get_fullname(pwd
);
1534 acct_desc
= pdb_get_acct_desc(pwd
);
1545 user_sid
= pdb_get_user_sid(pwd
);
1547 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
1548 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with "
1549 "the domain sid %s. Failing operation.\n",
1551 sid_to_string(user_sid_string
, user_sid
),
1552 sid_to_string(domain_sid_string
, domain_sid
)));
1553 return NT_STATUS_UNSUCCESSFUL
;
1556 init_unistr2(&sam
->str
[i
].uni_acct_name
, pdb_get_username(pwd
), UNI_FLAGS_NONE
);
1557 init_unistr2(&sam
->str
[i
].uni_full_name
, pdb_get_fullname(pwd
), UNI_FLAGS_NONE
);
1558 init_unistr2(&sam
->str
[i
].uni_acct_desc
, pdb_get_acct_desc(pwd
), UNI_FLAGS_NONE
);
1560 init_sam_entry1(&sam
->sam
[i
], start_idx
+ i
+ 1,
1561 &sam
->str
[i
].uni_acct_name
, &sam
->str
[i
].uni_full_name
, &sam
->str
[i
].uni_acct_desc
,
1562 user_rid
, pdb_get_acct_ctrl(pwd
));
1566 return NT_STATUS_OK
;
1569 /*******************************************************************
1570 reads or writes a structure.
1571 ********************************************************************/
1573 static BOOL
sam_io_sam_dispinfo_1(const char *desc
, SAM_DISPINFO_1
* sam
,
1575 prs_struct
*ps
, int depth
)
1579 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_1");
1585 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1587 if ((sam
->sam
= (SAM_ENTRY1
*)
1588 prs_alloc_mem(ps
, sizeof(SAM_ENTRY1
) *
1589 num_entries
)) == NULL
) {
1590 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));
1594 if ((sam
->str
= (SAM_STR1
*)
1595 prs_alloc_mem(ps
, sizeof(SAM_STR1
) *
1596 num_entries
)) == NULL
) {
1597 DEBUG(0, ("out of memory allocating SAM_STR1\n"));
1602 for (i
= 0; i
< num_entries
; i
++) {
1603 if(!sam_io_sam_entry1("", &sam
->sam
[i
], ps
, depth
))
1607 for (i
= 0; i
< num_entries
; i
++) {
1608 if(!sam_io_sam_str1("", &sam
->str
[i
],
1609 sam
->sam
[i
].hdr_acct_name
.buffer
,
1610 sam
->sam
[i
].hdr_user_name
.buffer
,
1611 sam
->sam
[i
].hdr_user_desc
.buffer
, ps
, depth
))
1618 /*******************************************************************
1619 inits a SAM_DISPINFO_2 structure.
1620 ********************************************************************/
1622 NTSTATUS
init_sam_dispinfo_2(TALLOC_CTX
*ctx
, SAM_DISPINFO_2
*sam
, uint32 num_entries
,
1623 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
,
1624 DOM_SID
*domain_sid
)
1628 SAM_ACCOUNT
*pwd
= NULL
;
1631 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries
));
1634 return NT_STATUS_OK
;
1636 if (!(sam
->sam
=(SAM_ENTRY2
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY2
))))
1637 return NT_STATUS_NO_MEMORY
;
1639 if (!(sam
->str
=(SAM_STR2
*)talloc(ctx
, num_entries
*sizeof(SAM_STR2
))))
1640 return NT_STATUS_NO_MEMORY
;
1642 ZERO_STRUCTP(sam
->sam
);
1643 ZERO_STRUCTP(sam
->str
);
1645 for (i
= 0; i
< num_entries
; i
++) {
1647 const DOM_SID
*user_sid
;
1648 const char *username
;
1649 const char *acct_desc
;
1650 fstring user_sid_string
, domain_sid_string
;
1652 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1653 pwd
=&disp_user_info
[i
+start_idx
];
1655 username
= pdb_get_username(pwd
);
1656 acct_desc
= pdb_get_acct_desc(pwd
);
1657 user_sid
= pdb_get_user_sid(pwd
);
1659 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
1660 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with "
1661 "the domain sid %s. Failing operation.\n",
1663 sid_to_string(user_sid_string
, user_sid
),
1664 sid_to_string(domain_sid_string
, domain_sid
)));
1665 return NT_STATUS_UNSUCCESSFUL
;
1668 init_unistr2(&sam
->str
[i
].uni_srv_name
, username
, UNI_FLAGS_NONE
);
1669 init_unistr2(&sam
->str
[i
].uni_srv_desc
, pdb_get_acct_desc(pwd
), UNI_FLAGS_NONE
);
1671 init_sam_entry2(&sam
->sam
[i
], start_idx
+ i
+ 1,
1672 &sam
->str
[i
].uni_srv_name
, &sam
->str
[i
].uni_srv_desc
,
1673 user_rid
, pdb_get_acct_ctrl(pwd
));
1676 return NT_STATUS_OK
;
1679 /*******************************************************************
1680 reads or writes a structure.
1681 ********************************************************************/
1683 static BOOL
sam_io_sam_dispinfo_2(const char *desc
, SAM_DISPINFO_2
* sam
,
1685 prs_struct
*ps
, int depth
)
1692 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_2");
1698 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1700 if ((sam
->sam
= (SAM_ENTRY2
*)
1701 prs_alloc_mem(ps
, sizeof(SAM_ENTRY2
) *
1702 num_entries
)) == NULL
) {
1703 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));
1707 if ((sam
->str
= (SAM_STR2
*)
1708 prs_alloc_mem(ps
, sizeof(SAM_STR2
) *
1709 num_entries
)) == NULL
) {
1710 DEBUG(0, ("out of memory allocating SAM_STR2\n"));
1715 for (i
= 0; i
< num_entries
; i
++) {
1716 if(!sam_io_sam_entry2("", &sam
->sam
[i
], ps
, depth
))
1720 for (i
= 0; i
< num_entries
; i
++) {
1721 if(!sam_io_sam_str2("", &sam
->str
[i
],
1722 sam
->sam
[i
].hdr_srv_name
.buffer
,
1723 sam
->sam
[i
].hdr_srv_desc
.buffer
, ps
, depth
))
1730 /*******************************************************************
1731 inits a SAM_DISPINFO_3 structure.
1732 ********************************************************************/
1734 NTSTATUS
init_sam_dispinfo_3(TALLOC_CTX
*ctx
, SAM_DISPINFO_3
*sam
, uint32 num_entries
,
1735 uint32 start_idx
, DOMAIN_GRP
*disp_group_info
)
1741 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries
));
1744 return NT_STATUS_OK
;
1746 if (!(sam
->sam
=(SAM_ENTRY3
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY3
))))
1747 return NT_STATUS_NO_MEMORY
;
1749 if (!(sam
->str
=(SAM_STR3
*)talloc(ctx
, num_entries
*sizeof(SAM_STR3
))))
1750 return NT_STATUS_NO_MEMORY
;
1752 ZERO_STRUCTP(sam
->sam
);
1753 ZERO_STRUCTP(sam
->str
);
1755 for (i
= 0; i
< num_entries
; i
++) {
1756 DOMAIN_GRP
*grp
= &disp_group_info
[i
+start_idx
];
1758 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i
));
1760 init_unistr2(&sam
->str
[i
].uni_grp_name
, grp
->name
, UNI_FLAGS_NONE
);
1761 init_unistr2(&sam
->str
[i
].uni_grp_desc
, grp
->comment
, UNI_FLAGS_NONE
);
1763 init_sam_entry3(&sam
->sam
[i
], start_idx
+ i
+ 1, &sam
->str
[i
].uni_grp_name
,
1764 &sam
->str
[i
].uni_grp_desc
, grp
->rid
);
1767 return NT_STATUS_OK
;
1770 /*******************************************************************
1771 reads or writes a structure.
1772 ********************************************************************/
1774 static BOOL
sam_io_sam_dispinfo_3(const char *desc
, SAM_DISPINFO_3
* sam
,
1776 prs_struct
*ps
, int depth
)
1783 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_3");
1789 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1791 if ((sam
->sam
= (SAM_ENTRY3
*)
1792 prs_alloc_mem(ps
, sizeof(SAM_ENTRY3
) *
1793 num_entries
)) == NULL
) {
1794 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));
1798 if ((sam
->str
= (SAM_STR3
*)
1799 prs_alloc_mem(ps
, sizeof(SAM_STR3
) *
1800 num_entries
)) == NULL
) {
1801 DEBUG(0, ("out of memory allocating SAM_STR3\n"));
1806 for (i
= 0; i
< num_entries
; i
++) {
1807 if(!sam_io_sam_entry3("", &sam
->sam
[i
], ps
, depth
))
1811 for (i
= 0; i
< num_entries
; i
++) {
1812 if(!sam_io_sam_str3("", &sam
->str
[i
],
1813 sam
->sam
[i
].hdr_grp_name
.buffer
,
1814 sam
->sam
[i
].hdr_grp_desc
.buffer
, ps
, depth
))
1821 /*******************************************************************
1822 inits a SAM_DISPINFO_4 structure.
1823 ********************************************************************/
1825 NTSTATUS
init_sam_dispinfo_4(TALLOC_CTX
*ctx
, SAM_DISPINFO_4
*sam
, uint32 num_entries
,
1826 uint32 start_idx
, SAM_ACCOUNT
*disp_user_info
)
1828 uint32 len_sam_name
;
1831 SAM_ACCOUNT
*pwd
= NULL
;
1834 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries
));
1837 return NT_STATUS_OK
;
1839 if (!(sam
->sam
=(SAM_ENTRY4
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY4
))))
1840 return NT_STATUS_NO_MEMORY
;
1842 if (!(sam
->str
=(SAM_STR4
*)talloc(ctx
, num_entries
*sizeof(SAM_STR4
))))
1843 return NT_STATUS_NO_MEMORY
;
1845 ZERO_STRUCTP(sam
->sam
);
1846 ZERO_STRUCTP(sam
->str
);
1848 for (i
= 0; i
< num_entries
; i
++) {
1849 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i
));
1850 pwd
=&disp_user_info
[i
+start_idx
];
1852 len_sam_name
= strlen(pdb_get_username(pwd
));
1854 init_sam_entry4(&sam
->sam
[i
], start_idx
+ i
+ 1, len_sam_name
);
1856 init_string2(&sam
->str
[i
].acct_name
, pdb_get_username(pwd
), len_sam_name
+1, len_sam_name
);
1859 return NT_STATUS_OK
;
1862 /*******************************************************************
1863 reads or writes a structure.
1864 ********************************************************************/
1866 static BOOL
sam_io_sam_dispinfo_4(const char *desc
, SAM_DISPINFO_4
* sam
,
1868 prs_struct
*ps
, int depth
)
1875 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_4");
1881 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1883 if ((sam
->sam
= (SAM_ENTRY4
*)
1884 prs_alloc_mem(ps
, sizeof(SAM_ENTRY4
) *
1885 num_entries
)) == NULL
) {
1886 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));
1890 if ((sam
->str
= (SAM_STR4
*)
1891 prs_alloc_mem(ps
, sizeof(SAM_STR4
) *
1892 num_entries
)) == NULL
) {
1893 DEBUG(0, ("out of memory allocating SAM_STR4\n"));
1898 for (i
= 0; i
< num_entries
; i
++) {
1899 if(!sam_io_sam_entry4("", &sam
->sam
[i
], ps
, depth
))
1903 for (i
= 0; i
< num_entries
; i
++) {
1904 if(!smb_io_string2("acct_name", &sam
->str
[i
].acct_name
,
1905 sam
->sam
[i
].hdr_acct_name
.buffer
, ps
, depth
))
1912 /*******************************************************************
1913 inits a SAM_DISPINFO_5 structure.
1914 ********************************************************************/
1916 NTSTATUS
init_sam_dispinfo_5(TALLOC_CTX
*ctx
, SAM_DISPINFO_5
*sam
, uint32 num_entries
,
1917 uint32 start_idx
, DOMAIN_GRP
*disp_group_info
)
1919 uint32 len_sam_name
;
1924 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries
));
1927 return NT_STATUS_OK
;
1929 if (!(sam
->sam
=(SAM_ENTRY5
*)talloc(ctx
, num_entries
*sizeof(SAM_ENTRY5
))))
1930 return NT_STATUS_NO_MEMORY
;
1932 if (!(sam
->str
=(SAM_STR5
*)talloc(ctx
, num_entries
*sizeof(SAM_STR5
))))
1933 return NT_STATUS_NO_MEMORY
;
1935 ZERO_STRUCTP(sam
->sam
);
1936 ZERO_STRUCTP(sam
->str
);
1938 for (i
= 0; i
< num_entries
; i
++) {
1939 DOMAIN_GRP
*grp
= &disp_group_info
[i
+start_idx
];
1941 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i
));
1943 len_sam_name
= strlen(grp
->name
);
1945 init_sam_entry5(&sam
->sam
[i
], start_idx
+ i
+ 1, len_sam_name
);
1946 init_string2(&sam
->str
[i
].grp_name
, grp
->name
, len_sam_name
+1, len_sam_name
);
1949 return NT_STATUS_OK
;
1952 /*******************************************************************
1953 reads or writes a structure.
1954 ********************************************************************/
1956 static BOOL
sam_io_sam_dispinfo_5(const char *desc
, SAM_DISPINFO_5
* sam
,
1958 prs_struct
*ps
, int depth
)
1965 prs_debug(ps
, depth
, desc
, "sam_io_sam_dispinfo_5");
1971 if (UNMARSHALLING(ps
) && num_entries
> 0) {
1973 if ((sam
->sam
= (SAM_ENTRY5
*)
1974 prs_alloc_mem(ps
, sizeof(SAM_ENTRY5
) *
1975 num_entries
)) == NULL
) {
1976 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));
1980 if ((sam
->str
= (SAM_STR5
*)
1981 prs_alloc_mem(ps
, sizeof(SAM_STR5
) *
1982 num_entries
)) == NULL
) {
1983 DEBUG(0, ("out of memory allocating SAM_STR5\n"));
1988 for (i
= 0; i
< num_entries
; i
++) {
1989 if(!sam_io_sam_entry5("", &sam
->sam
[i
], ps
, depth
))
1993 for (i
= 0; i
< num_entries
; i
++) {
1994 if(!smb_io_string2("grp_name", &sam
->str
[i
].grp_name
,
1995 sam
->sam
[i
].hdr_grp_name
.buffer
, ps
, depth
))
2002 /*******************************************************************
2003 inits a SAMR_R_QUERY_DISPINFO structure.
2004 ********************************************************************/
2006 void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
* r_u
,
2007 uint32 num_entries
, uint32 total_size
, uint32 data_size
,
2008 uint16 switch_level
, SAM_DISPINFO_CTR
* ctr
,
2011 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level
));
2013 r_u
->total_size
= total_size
;
2015 r_u
->data_size
= data_size
;
2017 r_u
->switch_level
= switch_level
;
2018 r_u
->num_entries
= num_entries
;
2021 r_u
->ptr_entries
= 0;
2023 r_u
->ptr_entries
= 1;
2025 r_u
->num_entries2
= num_entries
;
2028 r_u
->status
= status
;
2031 /*******************************************************************
2032 reads or writes a structure.
2033 ********************************************************************/
2035 BOOL
samr_io_r_query_dispinfo(const char *desc
, SAMR_R_QUERY_DISPINFO
* r_u
,
2036 prs_struct
*ps
, int depth
)
2041 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
2047 if(!prs_uint32("total_size ", ps
, depth
, &r_u
->total_size
))
2049 if(!prs_uint32("data_size ", ps
, depth
, &r_u
->data_size
))
2051 if(!prs_uint16("switch_level", ps
, depth
, &r_u
->switch_level
))
2056 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2058 if(!prs_uint32("ptr_entries ", ps
, depth
, &r_u
->ptr_entries
))
2061 if (r_u
->ptr_entries
==0) {
2064 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2070 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
2073 switch (r_u
->switch_level
) {
2075 if(!sam_io_sam_dispinfo_1("users", r_u
->ctr
->sam
.info1
,
2076 r_u
->num_entries
, ps
, depth
))
2080 if(!sam_io_sam_dispinfo_2("servers", r_u
->ctr
->sam
.info2
,
2081 r_u
->num_entries
, ps
, depth
))
2085 if(!sam_io_sam_dispinfo_3("groups", r_u
->ctr
->sam
.info3
,
2086 r_u
->num_entries
, ps
, depth
))
2090 if(!sam_io_sam_dispinfo_4("user list",
2091 r_u
->ctr
->sam
.info4
,
2092 r_u
->num_entries
, ps
, depth
))
2096 if(!sam_io_sam_dispinfo_5("group list",
2097 r_u
->ctr
->sam
.info5
,
2098 r_u
->num_entries
, ps
, depth
))
2102 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n"));
2108 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2114 /*******************************************************************
2115 inits a SAMR_Q_OPEN_GROUP structure.
2116 ********************************************************************/
2118 void init_samr_q_open_group(SAMR_Q_OPEN_GROUP
* q_c
,
2120 uint32 access_mask
, uint32 rid
)
2122 DEBUG(5, ("init_samr_q_open_group\n"));
2124 q_c
->domain_pol
= *hnd
;
2125 q_c
->access_mask
= access_mask
;
2126 q_c
->rid_group
= rid
;
2129 /*******************************************************************
2130 reads or writes a structure.
2131 ********************************************************************/
2133 BOOL
samr_io_q_open_group(const char *desc
, SAMR_Q_OPEN_GROUP
* q_u
,
2134 prs_struct
*ps
, int depth
)
2139 prs_debug(ps
, depth
, desc
, "samr_io_q_open_group");
2145 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
2148 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
2150 if(!prs_uint32("rid_group", ps
, depth
, &q_u
->rid_group
))
2156 /*******************************************************************
2157 reads or writes a structure.
2158 ********************************************************************/
2160 BOOL
samr_io_r_open_group(const char *desc
, SAMR_R_OPEN_GROUP
* r_u
,
2161 prs_struct
*ps
, int depth
)
2166 prs_debug(ps
, depth
, desc
, "samr_io_r_open_group");
2172 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2175 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2181 /*******************************************************************
2182 inits a GROUP_INFO1 structure.
2183 ********************************************************************/
2185 void init_samr_group_info1(GROUP_INFO1
* gr1
,
2186 char *acct_name
, char *acct_desc
,
2189 DEBUG(5, ("init_samr_group_info1\n"));
2191 gr1
->unknown_1
= 0x3;
2192 gr1
->num_members
= num_members
;
2194 init_unistr2(&gr1
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
2195 init_uni_hdr(&gr1
->hdr_acct_name
, &gr1
->uni_acct_name
);
2196 init_unistr2(&gr1
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2197 init_uni_hdr(&gr1
->hdr_acct_desc
, &gr1
->uni_acct_desc
);
2200 /*******************************************************************
2201 reads or writes a structure.
2202 ********************************************************************/
2204 BOOL
samr_io_group_info1(const char *desc
, GROUP_INFO1
* gr1
,
2205 prs_struct
*ps
, int depth
)
2210 prs_debug(ps
, depth
, desc
, "samr_io_group_info1");
2216 if(!smb_io_unihdr("hdr_acct_name", &gr1
->hdr_acct_name
, ps
, depth
))
2219 if(!prs_uint32("unknown_1", ps
, depth
, &gr1
->unknown_1
))
2221 if(!prs_uint32("num_members", ps
, depth
, &gr1
->num_members
))
2224 if(!smb_io_unihdr("hdr_acct_desc", &gr1
->hdr_acct_desc
, ps
, depth
))
2227 if(!smb_io_unistr2("uni_acct_name", &gr1
->uni_acct_name
,
2228 gr1
->hdr_acct_name
.buffer
, ps
, depth
))
2231 if(!smb_io_unistr2("uni_acct_desc", &gr1
->uni_acct_desc
,
2232 gr1
->hdr_acct_desc
.buffer
, ps
, depth
))
2238 /*******************************************************************
2239 inits a GROUP_INFO3 structure.
2240 ********************************************************************/
2242 void init_samr_group_info3(GROUP_INFO3
*gr3
)
2244 DEBUG(5, ("init_samr_group_info3\n"));
2246 gr3
->unknown_1
= 0x3;
2249 /*******************************************************************
2250 reads or writes a structure.
2251 ********************************************************************/
2253 BOOL
samr_io_group_info3(const char *desc
, GROUP_INFO3
*gr3
, prs_struct
*ps
, int depth
)
2258 prs_debug(ps
, depth
, desc
, "samr_io_group_info3");
2264 if(!prs_uint32("unknown_1", ps
, depth
, &gr3
->unknown_1
))
2270 /*******************************************************************
2271 inits a GROUP_INFO4 structure.
2272 ********************************************************************/
2274 void init_samr_group_info4(GROUP_INFO4
* gr4
, const char *acct_desc
)
2276 DEBUG(5, ("init_samr_group_info4\n"));
2279 init_unistr2(&gr4
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2280 init_uni_hdr(&gr4
->hdr_acct_desc
, &gr4
->uni_acct_desc
);
2283 /*******************************************************************
2284 reads or writes a structure.
2285 ********************************************************************/
2287 BOOL
samr_io_group_info4(const char *desc
, GROUP_INFO4
* gr4
,
2288 prs_struct
*ps
, int depth
)
2293 prs_debug(ps
, depth
, desc
, "samr_io_group_info4");
2296 if(!prs_uint16("hdr_level", ps
, depth
, &gr4
->level
))
2298 if(!smb_io_unihdr("hdr_acct_desc", &gr4
->hdr_acct_desc
, ps
, depth
))
2300 if(!smb_io_unistr2("uni_acct_desc", &gr4
->uni_acct_desc
,
2301 gr4
->hdr_acct_desc
.buffer
, ps
, depth
))
2307 /*******************************************************************
2308 reads or writes a structure.
2309 ********************************************************************/
2311 static BOOL
samr_group_info_ctr(const char *desc
, GROUP_INFO_CTR
**ctr
,
2312 prs_struct
*ps
, int depth
)
2314 if (UNMARSHALLING(ps
))
2315 *ctr
= (GROUP_INFO_CTR
*)prs_alloc_mem(ps
,sizeof(GROUP_INFO_CTR
));
2320 prs_debug(ps
, depth
, desc
, "samr_group_info_ctr");
2323 if(!prs_uint16("switch_value1", ps
, depth
, &(*ctr
)->switch_value1
))
2326 switch ((*ctr
)->switch_value1
) {
2328 if(!samr_io_group_info1("group_info1", &(*ctr
)->group
.info1
, ps
, depth
))
2332 if(!samr_io_group_info3("group_info3", &(*ctr
)->group
.info3
, ps
, depth
))
2336 if(!samr_io_group_info4("group_info4", &(*ctr
)->group
.info4
, ps
, depth
))
2340 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n"));
2347 /*******************************************************************
2348 inits a SAMR_Q_CREATE_DOM_GROUP structure.
2349 ********************************************************************/
2351 void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2352 POLICY_HND
*pol
, const char *acct_desc
,
2355 DEBUG(5, ("init_samr_q_create_dom_group\n"));
2359 init_unistr2(&q_e
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
2360 init_uni_hdr(&q_e
->hdr_acct_desc
, &q_e
->uni_acct_desc
);
2362 q_e
->access_mask
= access_mask
;
2365 /*******************************************************************
2366 reads or writes a structure.
2367 ********************************************************************/
2369 BOOL
samr_io_q_create_dom_group(const char *desc
, SAMR_Q_CREATE_DOM_GROUP
* q_e
,
2370 prs_struct
*ps
, int depth
)
2375 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_group");
2381 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2384 if(!smb_io_unihdr("hdr_acct_desc", &q_e
->hdr_acct_desc
, ps
, depth
))
2386 if(!smb_io_unistr2("uni_acct_desc", &q_e
->uni_acct_desc
,
2387 q_e
->hdr_acct_desc
.buffer
, ps
, depth
))
2392 if(!prs_uint32("access", ps
, depth
, &q_e
->access_mask
))
2398 /*******************************************************************
2399 reads or writes a structure.
2400 ********************************************************************/
2402 BOOL
samr_io_r_create_dom_group(const char *desc
, SAMR_R_CREATE_DOM_GROUP
* r_u
,
2403 prs_struct
*ps
, int depth
)
2408 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_group");
2414 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2417 if(!prs_uint32("rid ", ps
, depth
, &r_u
->rid
))
2419 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2425 /*******************************************************************
2426 inits a SAMR_Q_DELETE_DOM_GROUP structure.
2427 ********************************************************************/
2429 void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP
* q_c
,
2432 DEBUG(5, ("init_samr_q_delete_dom_group\n"));
2434 q_c
->group_pol
= *hnd
;
2437 /*******************************************************************
2438 reads or writes a structure.
2439 ********************************************************************/
2441 BOOL
samr_io_q_delete_dom_group(const char *desc
, SAMR_Q_DELETE_DOM_GROUP
* q_u
,
2442 prs_struct
*ps
, int depth
)
2447 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_group");
2453 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2459 /*******************************************************************
2460 reads or writes a structure.
2461 ********************************************************************/
2463 BOOL
samr_io_r_delete_dom_group(const char *desc
, SAMR_R_DELETE_DOM_GROUP
* r_u
,
2464 prs_struct
*ps
, int depth
)
2469 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_group");
2475 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
2478 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2484 /*******************************************************************
2485 inits a SAMR_Q_DEL_GROUPMEM structure.
2486 ********************************************************************/
2488 void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM
* q_e
,
2489 POLICY_HND
*pol
, uint32 rid
)
2491 DEBUG(5, ("init_samr_q_del_groupmem\n"));
2497 /*******************************************************************
2498 reads or writes a structure.
2499 ********************************************************************/
2501 BOOL
samr_io_q_del_groupmem(const char *desc
, SAMR_Q_DEL_GROUPMEM
* q_e
,
2502 prs_struct
*ps
, int depth
)
2507 prs_debug(ps
, depth
, desc
, "samr_io_q_del_groupmem");
2513 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2516 if(!prs_uint32("rid", ps
, depth
, &q_e
->rid
))
2522 /*******************************************************************
2523 inits a SAMR_R_DEL_GROUPMEM structure.
2524 ********************************************************************/
2526 void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2529 DEBUG(5, ("init_samr_r_del_groupmem\n"));
2531 r_u
->status
= status
;
2534 /*******************************************************************
2535 reads or writes a structure.
2536 ********************************************************************/
2538 BOOL
samr_io_r_del_groupmem(const char *desc
, SAMR_R_DEL_GROUPMEM
* r_u
,
2539 prs_struct
*ps
, int depth
)
2544 prs_debug(ps
, depth
, desc
, "samr_io_r_del_groupmem");
2550 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2556 /*******************************************************************
2557 inits a SAMR_Q_ADD_GROUPMEM structure.
2558 ********************************************************************/
2560 void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM
* q_e
,
2561 POLICY_HND
*pol
, uint32 rid
)
2563 DEBUG(5, ("init_samr_q_add_groupmem\n"));
2567 q_e
->unknown
= 0x0005;
2570 /*******************************************************************
2571 reads or writes a structure.
2572 ********************************************************************/
2574 BOOL
samr_io_q_add_groupmem(const char *desc
, SAMR_Q_ADD_GROUPMEM
* q_e
,
2575 prs_struct
*ps
, int depth
)
2580 prs_debug(ps
, depth
, desc
, "samr_io_q_add_groupmem");
2586 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2589 if(!prs_uint32("rid ", ps
, depth
, &q_e
->rid
))
2591 if(!prs_uint32("unknown", ps
, depth
, &q_e
->unknown
))
2597 /*******************************************************************
2598 inits a SAMR_R_ADD_GROUPMEM structure.
2599 ********************************************************************/
2601 void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM
* r_u
, POLICY_HND
*pol
,
2604 DEBUG(5, ("init_samr_r_add_groupmem\n"));
2606 r_u
->status
= status
;
2609 /*******************************************************************
2610 reads or writes a structure.
2611 ********************************************************************/
2613 BOOL
samr_io_r_add_groupmem(const char *desc
, SAMR_R_ADD_GROUPMEM
* r_u
,
2614 prs_struct
*ps
, int depth
)
2619 prs_debug(ps
, depth
, desc
, "samr_io_r_add_groupmem");
2625 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2631 /*******************************************************************
2632 inits a SAMR_Q_SET_GROUPINFO structure.
2633 ********************************************************************/
2635 void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO
* q_e
,
2636 POLICY_HND
*pol
, GROUP_INFO_CTR
* ctr
)
2638 DEBUG(5, ("init_samr_q_set_groupinfo\n"));
2644 /*******************************************************************
2645 reads or writes a structure.
2646 ********************************************************************/
2648 BOOL
samr_io_q_set_groupinfo(const char *desc
, SAMR_Q_SET_GROUPINFO
* q_e
,
2649 prs_struct
*ps
, int depth
)
2654 prs_debug(ps
, depth
, desc
, "samr_io_q_set_groupinfo");
2660 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2663 if(!samr_group_info_ctr("ctr", &q_e
->ctr
, ps
, depth
))
2669 /*******************************************************************
2670 inits a SAMR_R_SET_GROUPINFO structure.
2671 ********************************************************************/
2673 void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO
* r_u
, NTSTATUS status
)
2675 DEBUG(5, ("init_samr_r_set_groupinfo\n"));
2677 r_u
->status
= status
;
2680 /*******************************************************************
2681 reads or writes a structure.
2682 ********************************************************************/
2684 BOOL
samr_io_r_set_groupinfo(const char *desc
, SAMR_R_SET_GROUPINFO
* r_u
,
2685 prs_struct
*ps
, int depth
)
2690 prs_debug(ps
, depth
, desc
, "samr_io_r_set_groupinfo");
2696 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2702 /*******************************************************************
2703 inits a SAMR_Q_QUERY_GROUPINFO structure.
2704 ********************************************************************/
2706 void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO
* q_e
,
2707 POLICY_HND
*pol
, uint16 switch_level
)
2709 DEBUG(5, ("init_samr_q_query_groupinfo\n"));
2713 q_e
->switch_level
= switch_level
;
2716 /*******************************************************************
2717 reads or writes a structure.
2718 ********************************************************************/
2720 BOOL
samr_io_q_query_groupinfo(const char *desc
, SAMR_Q_QUERY_GROUPINFO
* q_e
,
2721 prs_struct
*ps
, int depth
)
2726 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupinfo");
2732 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
2735 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
2741 /*******************************************************************
2742 inits a SAMR_R_QUERY_GROUPINFO structure.
2743 ********************************************************************/
2745 void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO
* r_u
,
2746 GROUP_INFO_CTR
* ctr
, NTSTATUS status
)
2748 DEBUG(5, ("init_samr_r_query_groupinfo\n"));
2750 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
2752 r_u
->status
= status
;
2755 /*******************************************************************
2756 reads or writes a structure.
2757 ********************************************************************/
2759 BOOL
samr_io_r_query_groupinfo(const char *desc
, SAMR_R_QUERY_GROUPINFO
* r_u
,
2760 prs_struct
*ps
, int depth
)
2765 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupinfo");
2771 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2774 if (r_u
->ptr
!= 0) {
2775 if(!samr_group_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
2781 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2787 /*******************************************************************
2788 inits a SAMR_Q_QUERY_GROUPMEM structure.
2789 ********************************************************************/
2791 void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM
* q_c
, POLICY_HND
*hnd
)
2793 DEBUG(5, ("init_samr_q_query_groupmem\n"));
2795 q_c
->group_pol
= *hnd
;
2798 /*******************************************************************
2799 reads or writes a structure.
2800 ********************************************************************/
2802 BOOL
samr_io_q_query_groupmem(const char *desc
, SAMR_Q_QUERY_GROUPMEM
* q_u
,
2803 prs_struct
*ps
, int depth
)
2808 prs_debug(ps
, depth
, desc
, "samr_io_q_query_groupmem");
2814 if(!smb_io_pol_hnd("group_pol", &q_u
->group_pol
, ps
, depth
))
2820 /*******************************************************************
2821 inits a SAMR_R_QUERY_GROUPMEM structure.
2822 ********************************************************************/
2824 void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM
* r_u
,
2825 uint32 num_entries
, uint32
*rid
,
2826 uint32
*attr
, NTSTATUS status
)
2828 DEBUG(5, ("init_samr_r_query_groupmem\n"));
2830 if (NT_STATUS_IS_OK(status
)) {
2832 r_u
->num_entries
= num_entries
;
2834 r_u
->ptr_attrs
= attr
!= NULL
? 1 : 0;
2835 r_u
->ptr_rids
= rid
!= NULL
? 1 : 0;
2837 r_u
->num_rids
= num_entries
;
2840 r_u
->num_attrs
= num_entries
;
2844 r_u
->num_entries
= 0;
2847 r_u
->status
= status
;
2850 /*******************************************************************
2851 reads or writes a structure.
2852 ********************************************************************/
2854 BOOL
samr_io_r_query_groupmem(const char *desc
, SAMR_R_QUERY_GROUPMEM
* r_u
,
2855 prs_struct
*ps
, int depth
)
2862 if (UNMARSHALLING(ps
))
2865 prs_debug(ps
, depth
, desc
, "samr_io_r_query_groupmem");
2871 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
2873 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
2876 if (r_u
->ptr
!= 0) {
2877 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
2879 if(!prs_uint32("ptr_attrs", ps
, depth
, &r_u
->ptr_attrs
))
2882 if (r_u
->ptr_rids
!= 0) {
2883 if(!prs_uint32("num_rids", ps
, depth
, &r_u
->num_rids
))
2885 if (UNMARSHALLING(ps
) && r_u
->num_rids
!= 0) {
2886 r_u
->rid
= (uint32
*)prs_alloc_mem(ps
,sizeof(r_u
->rid
[0])*r_u
->num_rids
);
2887 if (r_u
->rid
== NULL
)
2891 for (i
= 0; i
< r_u
->num_rids
; i
++) {
2892 if(!prs_uint32("", ps
, depth
, &r_u
->rid
[i
]))
2897 if (r_u
->ptr_attrs
!= 0) {
2898 if(!prs_uint32("num_attrs", ps
, depth
, &r_u
->num_attrs
))
2901 if (UNMARSHALLING(ps
) && r_u
->num_attrs
!= 0) {
2902 r_u
->attr
= (uint32
*)prs_alloc_mem(ps
,sizeof(r_u
->attr
[0])*r_u
->num_attrs
);
2903 if (r_u
->attr
== NULL
)
2907 for (i
= 0; i
< r_u
->num_attrs
; i
++) {
2908 if(!prs_uint32("", ps
, depth
, &r_u
->attr
[i
]))
2914 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
2920 /*******************************************************************
2921 inits a SAMR_Q_QUERY_USERGROUPS structure.
2922 ********************************************************************/
2924 void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
* q_u
,
2927 DEBUG(5, ("init_samr_q_query_usergroups\n"));
2932 /*******************************************************************
2933 reads or writes a structure.
2934 ********************************************************************/
2936 BOOL
samr_io_q_query_usergroups(const char *desc
, SAMR_Q_QUERY_USERGROUPS
* q_u
,
2937 prs_struct
*ps
, int depth
)
2942 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
2948 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
2954 /*******************************************************************
2955 inits a SAMR_R_QUERY_USERGROUPS structure.
2956 ********************************************************************/
2958 void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
* r_u
,
2959 uint32 num_gids
, DOM_GID
* gid
,
2962 DEBUG(5, ("init_samr_r_query_usergroups\n"));
2964 if (NT_STATUS_IS_OK(status
)) {
2966 r_u
->num_entries
= num_gids
;
2967 r_u
->ptr_1
= (num_gids
!= 0) ? 1 : 0;
2968 r_u
->num_entries2
= num_gids
;
2973 r_u
->num_entries
= 0;
2978 r_u
->status
= status
;
2981 /*******************************************************************
2982 reads or writes a structure.
2983 ********************************************************************/
2985 BOOL
samr_io_gids(const char *desc
, uint32
*num_gids
, DOM_GID
** gid
,
2986 prs_struct
*ps
, int depth
)
2992 prs_debug(ps
, depth
, desc
, "samr_io_gids");
2998 if(!prs_uint32("num_gids", ps
, depth
, num_gids
))
3001 if ((*num_gids
) != 0) {
3002 if (UNMARSHALLING(ps
)) {
3003 (*gid
) = (DOM_GID
*)prs_alloc_mem(ps
,sizeof(DOM_GID
)*(*num_gids
));
3006 if ((*gid
) == NULL
) {
3010 for (i
= 0; i
< (*num_gids
); i
++) {
3011 if(!smb_io_gid("gids", &(*gid
)[i
], ps
, depth
))
3019 /*******************************************************************
3020 reads or writes a structure.
3021 ********************************************************************/
3023 BOOL
samr_io_r_query_usergroups(const char *desc
, SAMR_R_QUERY_USERGROUPS
* r_u
,
3024 prs_struct
*ps
, int depth
)
3029 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
3035 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
3038 if (r_u
->ptr_0
!= 0) {
3039 if(!prs_uint32("num_entries ", ps
, depth
, &r_u
->num_entries
))
3041 if(!prs_uint32("ptr_1 ", ps
, depth
, &r_u
->ptr_1
))
3044 if (r_u
->num_entries
!= 0 && r_u
->ptr_1
!= 0) {
3045 if(!samr_io_gids("gids", &r_u
->num_entries2
, &r_u
->gid
, ps
, depth
))
3052 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3058 /*******************************************************************
3059 inits a SAMR_Q_ENUM_DOMAINS structure.
3060 ********************************************************************/
3062 void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS
* q_e
,
3064 uint32 start_idx
, uint32 size
)
3066 DEBUG(5, ("init_samr_q_enum_domains\n"));
3070 q_e
->start_idx
= start_idx
;
3071 q_e
->max_size
= size
;
3074 /*******************************************************************
3075 reads or writes a structure.
3076 ********************************************************************/
3078 BOOL
samr_io_q_enum_domains(const char *desc
, SAMR_Q_ENUM_DOMAINS
* q_e
,
3079 prs_struct
*ps
, int depth
)
3084 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_domains");
3090 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3093 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3095 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3101 /*******************************************************************
3102 inits a SAMR_R_ENUM_DOMAINS structure.
3103 ********************************************************************/
3105 void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS
* r_u
,
3106 uint32 next_idx
, uint32 num_sam_entries
)
3108 DEBUG(5, ("init_samr_r_enum_domains\n"));
3110 r_u
->next_idx
= next_idx
;
3112 if (num_sam_entries
!= 0) {
3113 r_u
->ptr_entries1
= 1;
3114 r_u
->ptr_entries2
= 1;
3115 r_u
->num_entries2
= num_sam_entries
;
3116 r_u
->num_entries3
= num_sam_entries
;
3118 r_u
->num_entries4
= num_sam_entries
;
3120 r_u
->ptr_entries1
= 0;
3121 r_u
->num_entries2
= num_sam_entries
;
3122 r_u
->ptr_entries2
= 1;
3126 /*******************************************************************
3127 reads or writes a structure.
3128 ********************************************************************/
3130 BOOL
samr_io_r_enum_domains(const char *desc
, SAMR_R_ENUM_DOMAINS
* r_u
,
3131 prs_struct
*ps
, int depth
)
3138 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_domains");
3144 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3146 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3149 if (r_u
->ptr_entries1
!= 0) {
3150 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3152 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3154 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3157 if (UNMARSHALLING(ps
)) {
3158 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3159 r_u
->uni_dom_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3162 if ((r_u
->sam
== NULL
|| r_u
->uni_dom_name
== NULL
) && r_u
->num_entries2
!= 0) {
3163 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n"));
3164 r_u
->num_entries4
= 0;
3165 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3169 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3171 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3172 if(!sam_io_sam_entry(tmp
, &r_u
->sam
[i
], ps
, depth
))
3176 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3178 slprintf(tmp
, sizeof(tmp
) - 1, "dom[%d]", i
);
3179 if(!smb_io_unistr2(tmp
, &r_u
->uni_dom_name
[i
],
3180 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3189 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3191 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3197 /*******************************************************************
3198 inits a SAMR_Q_ENUM_DOM_GROUPS structure.
3199 ********************************************************************/
3201 void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3203 uint32 start_idx
, uint32 size
)
3205 DEBUG(5, ("init_samr_q_enum_dom_groups\n"));
3209 q_e
->start_idx
= start_idx
;
3210 q_e
->max_size
= size
;
3213 /*******************************************************************
3214 reads or writes a structure.
3215 ********************************************************************/
3217 BOOL
samr_io_q_enum_dom_groups(const char *desc
, SAMR_Q_ENUM_DOM_GROUPS
* q_e
,
3218 prs_struct
*ps
, int depth
)
3223 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
3229 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3232 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3234 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3240 /*******************************************************************
3241 inits a SAMR_R_ENUM_DOM_GROUPS structure.
3242 ********************************************************************/
3244 void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3245 uint32 next_idx
, uint32 num_sam_entries
)
3247 DEBUG(5, ("init_samr_r_enum_dom_groups\n"));
3249 r_u
->next_idx
= next_idx
;
3251 if (num_sam_entries
!= 0) {
3252 r_u
->ptr_entries1
= 1;
3253 r_u
->ptr_entries2
= 1;
3254 r_u
->num_entries2
= num_sam_entries
;
3255 r_u
->num_entries3
= num_sam_entries
;
3257 r_u
->num_entries4
= num_sam_entries
;
3259 r_u
->ptr_entries1
= 0;
3260 r_u
->num_entries2
= num_sam_entries
;
3261 r_u
->ptr_entries2
= 1;
3265 /*******************************************************************
3266 reads or writes a structure.
3267 ********************************************************************/
3269 BOOL
samr_io_r_enum_dom_groups(const char *desc
, SAMR_R_ENUM_DOM_GROUPS
* r_u
,
3270 prs_struct
*ps
, int depth
)
3277 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
3283 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3285 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3288 if (r_u
->ptr_entries1
!= 0) {
3289 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3291 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3293 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3296 if (UNMARSHALLING(ps
)) {
3297 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3298 r_u
->uni_grp_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3301 if ((r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
) && r_u
->num_entries2
!= 0) {
3303 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n"));
3304 r_u
->num_entries4
= 0;
3305 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3309 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3310 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3314 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3315 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3316 r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
))
3323 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3325 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3331 /*******************************************************************
3332 inits a SAMR_Q_ENUM_DOM_ALIASES structure.
3333 ********************************************************************/
3335 void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3336 POLICY_HND
*pol
, uint32 start_idx
,
3339 DEBUG(5, ("init_samr_q_enum_dom_aliases\n"));
3343 q_e
->start_idx
= start_idx
;
3344 q_e
->max_size
= size
;
3348 /*******************************************************************
3349 reads or writes a structure.
3350 ********************************************************************/
3352 BOOL
samr_io_q_enum_dom_aliases(const char *desc
, SAMR_Q_ENUM_DOM_ALIASES
* q_e
,
3353 prs_struct
*ps
, int depth
)
3358 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
3364 if(!smb_io_pol_hnd("pol", &q_e
->pol
, ps
, depth
))
3367 if(!prs_uint32("start_idx", ps
, depth
, &q_e
->start_idx
))
3369 if(!prs_uint32("max_size ", ps
, depth
, &q_e
->max_size
))
3375 /*******************************************************************
3376 inits a SAMR_R_ENUM_DOM_ALIASES structure.
3377 ********************************************************************/
3379 void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
, uint32 next_idx
, uint32 num_sam_entries
)
3381 DEBUG(5, ("init_samr_r_enum_dom_aliases\n"));
3383 r_u
->next_idx
= next_idx
;
3385 if (num_sam_entries
!= 0) {
3386 r_u
->ptr_entries1
= 1;
3387 r_u
->ptr_entries2
= 1;
3388 r_u
->num_entries2
= num_sam_entries
;
3389 r_u
->num_entries3
= num_sam_entries
;
3391 r_u
->num_entries4
= num_sam_entries
;
3393 r_u
->ptr_entries1
= 0;
3394 r_u
->num_entries2
= num_sam_entries
;
3395 r_u
->ptr_entries2
= 1;
3399 /*******************************************************************
3400 reads or writes a structure.
3401 ********************************************************************/
3403 BOOL
samr_io_r_enum_dom_aliases(const char *desc
, SAMR_R_ENUM_DOM_ALIASES
* r_u
,
3404 prs_struct
*ps
, int depth
)
3411 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
3417 if(!prs_uint32("next_idx ", ps
, depth
, &r_u
->next_idx
))
3419 if(!prs_uint32("ptr_entries1", ps
, depth
, &r_u
->ptr_entries1
))
3422 if (r_u
->ptr_entries1
!= 0) {
3423 if(!prs_uint32("num_entries2", ps
, depth
, &r_u
->num_entries2
))
3425 if(!prs_uint32("ptr_entries2", ps
, depth
, &r_u
->ptr_entries2
))
3427 if(!prs_uint32("num_entries3", ps
, depth
, &r_u
->num_entries3
))
3430 if (UNMARSHALLING(ps
) && (r_u
->num_entries2
> 0)) {
3431 r_u
->sam
= (SAM_ENTRY
*)prs_alloc_mem(ps
,sizeof(SAM_ENTRY
)*r_u
->num_entries2
);
3432 r_u
->uni_grp_name
= (UNISTR2
*)prs_alloc_mem(ps
,sizeof(UNISTR2
)*r_u
->num_entries2
);
3435 if (r_u
->num_entries2
!= 0 &&
3436 (r_u
->sam
== NULL
|| r_u
->uni_grp_name
== NULL
)) {
3437 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n"));
3438 r_u
->num_entries4
= 0;
3439 r_u
->status
= NT_STATUS_MEMORY_NOT_ALLOCATED
;
3443 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3444 if(!sam_io_sam_entry("", &r_u
->sam
[i
], ps
, depth
))
3448 for (i
= 0; i
< r_u
->num_entries2
; i
++) {
3449 if(!smb_io_unistr2("", &r_u
->uni_grp_name
[i
],
3450 r_u
->sam
[i
].hdr_name
.buffer
, ps
,
3458 if(!prs_uint32("num_entries4", ps
, depth
, &r_u
->num_entries4
))
3460 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3466 /*******************************************************************
3467 inits a ALIAS_INFO1 structure.
3468 ********************************************************************/
3470 void init_samr_alias_info1(ALIAS_INFO1
* al1
, char *acct_name
, uint32 num_member
, char *acct_desc
)
3472 DEBUG(5, ("init_samr_alias_info1\n"));
3474 init_unistr2(&al1
->uni_acct_name
, acct_name
, UNI_FLAGS_NONE
);
3475 init_uni_hdr(&al1
->hdr_acct_name
, &al1
->uni_acct_name
);
3477 al1
->num_member
=num_member
;
3479 init_unistr2(&al1
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
3480 init_uni_hdr(&al1
->hdr_acct_desc
, &al1
->uni_acct_name
);
3483 /*******************************************************************
3484 reads or writes a structure.
3485 ********************************************************************/
3487 BOOL
samr_io_alias_info1(const char *desc
, ALIAS_INFO1
* al1
,
3488 prs_struct
*ps
, int depth
)
3493 prs_debug(ps
, depth
, desc
, "samr_io_alias_info1");
3499 if(!smb_io_unihdr("hdr_acct_name", &al1
->hdr_acct_name
, ps
, depth
))
3501 if(!prs_uint32("num_member", ps
, depth
, &al1
->num_member
))
3503 if(!smb_io_unihdr("hdr_acct_desc", &al1
->hdr_acct_desc
, ps
, depth
))
3506 if(!smb_io_unistr2("uni_acct_name", &al1
->uni_acct_name
,
3507 al1
->hdr_acct_name
.buffer
, ps
, depth
))
3513 if(!smb_io_unistr2("uni_acct_desc", &al1
->uni_acct_desc
,
3514 al1
->hdr_acct_desc
.buffer
, ps
, depth
))
3520 /*******************************************************************
3521 inits a ALIAS_INFO3 structure.
3522 ********************************************************************/
3524 void init_samr_alias_info3(ALIAS_INFO3
* al3
, const char *acct_desc
)
3526 DEBUG(5, ("init_samr_alias_info3\n"));
3528 init_unistr2(&al3
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
3529 init_uni_hdr(&al3
->hdr_acct_desc
, &al3
->uni_acct_desc
);
3532 /*******************************************************************
3533 reads or writes a structure.
3534 ********************************************************************/
3536 BOOL
samr_io_alias_info3(const char *desc
, ALIAS_INFO3
* al3
,
3537 prs_struct
*ps
, int depth
)
3542 prs_debug(ps
, depth
, desc
, "samr_io_alias_info3");
3548 if(!smb_io_unihdr("hdr_acct_desc", &al3
->hdr_acct_desc
, ps
, depth
))
3550 if(!smb_io_unistr2("uni_acct_desc", &al3
->uni_acct_desc
,
3551 al3
->hdr_acct_desc
.buffer
, ps
, depth
))
3557 /*******************************************************************
3558 reads or writes a structure.
3559 ********************************************************************/
3561 BOOL
samr_alias_info_ctr(const char *desc
, ALIAS_INFO_CTR
* ctr
,
3562 prs_struct
*ps
, int depth
)
3567 prs_debug(ps
, depth
, desc
, "samr_alias_info_ctr");
3570 if(!prs_uint16("switch_value1", ps
, depth
, &ctr
->switch_value1
))
3572 if(!prs_uint16("switch_value2", ps
, depth
, &ctr
->switch_value2
))
3575 switch (ctr
->switch_value1
) {
3577 if(!samr_io_alias_info1("alias_info1", &ctr
->alias
.info1
, ps
, depth
))
3581 if(!samr_io_alias_info3("alias_info3", &ctr
->alias
.info3
, ps
, depth
))
3585 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n"));
3592 /*******************************************************************
3593 inits a SAMR_Q_QUERY_ALIASINFO structure.
3594 ********************************************************************/
3596 void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
* q_e
,
3597 POLICY_HND
*pol
, uint16 switch_level
)
3599 DEBUG(5, ("init_samr_q_query_aliasinfo\n"));
3602 q_e
->switch_level
= switch_level
;
3605 /*******************************************************************
3606 reads or writes a structure.
3607 ********************************************************************/
3609 BOOL
samr_io_q_query_aliasinfo(const char *desc
, SAMR_Q_QUERY_ALIASINFO
* q_e
,
3610 prs_struct
*ps
, int depth
)
3615 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
3621 if(!smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
))
3624 if(!prs_uint16("switch_level", ps
, depth
, &q_e
->switch_level
))
3630 /*******************************************************************
3631 inits a SAMR_R_QUERY_ALIASINFO structure.
3632 ********************************************************************/
3634 void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
* r_u
,
3635 ALIAS_INFO_CTR
* ctr
, NTSTATUS status
)
3637 DEBUG(5, ("init_samr_r_query_aliasinfo\n"));
3639 r_u
->ptr
= (NT_STATUS_IS_OK(status
) && ctr
!= NULL
) ? 1 : 0;
3641 r_u
->status
= status
;
3644 /*******************************************************************
3645 reads or writes a structure.
3646 ********************************************************************/
3648 BOOL
samr_io_r_query_aliasinfo(const char *desc
, SAMR_R_QUERY_ALIASINFO
* r_u
,
3649 prs_struct
*ps
, int depth
)
3654 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
3660 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
3663 if (r_u
->ptr
!= 0) {
3664 if(!samr_alias_info_ctr("ctr", &r_u
->ctr
, ps
, depth
))
3670 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3676 /*******************************************************************
3677 inits a SAMR_Q_SET_ALIASINFO structure.
3678 ********************************************************************/
3680 void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO
* q_u
,
3681 POLICY_HND
*hnd
, ALIAS_INFO_CTR
* ctr
)
3683 DEBUG(5, ("init_samr_q_set_aliasinfo\n"));
3685 q_u
->alias_pol
= *hnd
;
3689 /*******************************************************************
3690 reads or writes a structure.
3691 ********************************************************************/
3693 BOOL
samr_io_q_set_aliasinfo(const char *desc
, SAMR_Q_SET_ALIASINFO
* q_u
,
3694 prs_struct
*ps
, int depth
)
3699 prs_debug(ps
, depth
, desc
, "samr_io_q_set_aliasinfo");
3705 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
3707 if(!samr_alias_info_ctr("ctr", &q_u
->ctr
, ps
, depth
))
3713 /*******************************************************************
3714 reads or writes a structure.
3715 ********************************************************************/
3717 BOOL
samr_io_r_set_aliasinfo(const char *desc
, SAMR_R_SET_ALIASINFO
* r_u
,
3718 prs_struct
*ps
, int depth
)
3723 prs_debug(ps
, depth
, desc
, "samr_io_r_set_aliasinfo");
3728 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3734 /*******************************************************************
3735 inits a SAMR_Q_QUERY_USERALIASES structure.
3736 ********************************************************************/
3738 void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES
* q_u
,
3741 uint32
*ptr_sid
, DOM_SID2
* sid
)
3743 DEBUG(5, ("init_samr_q_query_useraliases\n"));
3747 q_u
->num_sids1
= num_sids
;
3749 q_u
->num_sids2
= num_sids
;
3751 q_u
->ptr_sid
= ptr_sid
;
3755 /*******************************************************************
3756 reads or writes a SAMR_Q_QUERY_USERALIASES structure.
3757 ********************************************************************/
3759 BOOL
samr_io_q_query_useraliases(const char *desc
, SAMR_Q_QUERY_USERALIASES
* q_u
,
3760 prs_struct
*ps
, int depth
)
3768 prs_debug(ps
, depth
, desc
, "samr_io_q_query_useraliases");
3774 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
3777 if(!prs_uint32("num_sids1", ps
, depth
, &q_u
->num_sids1
))
3779 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
3785 if(!prs_uint32("num_sids2", ps
, depth
, &q_u
->num_sids2
))
3788 if (UNMARSHALLING(ps
) && (q_u
->num_sids2
!= 0)) {
3789 q_u
->ptr_sid
= (uint32
*)prs_alloc_mem(ps
,sizeof(q_u
->ptr_sid
[0])*q_u
->num_sids2
);
3790 if (q_u
->ptr_sid
== NULL
)
3793 q_u
->sid
= (DOM_SID2
*)prs_alloc_mem(ps
, sizeof(q_u
->sid
[0]) * q_u
->num_sids2
);
3794 if (q_u
->sid
== NULL
)
3798 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3799 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
3800 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->ptr_sid
[i
]))
3804 for (i
= 0; i
< q_u
->num_sids2
; i
++) {
3805 if (q_u
->ptr_sid
[i
] != 0) {
3806 slprintf(tmp
, sizeof(tmp
) - 1, "sid[%02d]", i
);
3807 if(!smb_io_dom_sid2(tmp
, &q_u
->sid
[i
], ps
, depth
))
3815 /*******************************************************************
3816 inits a SAMR_R_QUERY_USERALIASES structure.
3817 ********************************************************************/
3819 void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES
* r_u
,
3820 uint32 num_rids
, uint32
*rid
,
3823 DEBUG(5, ("init_samr_r_query_useraliases\n"));
3825 if (NT_STATUS_IS_OK(status
)) {
3826 r_u
->num_entries
= num_rids
;
3828 r_u
->num_entries2
= num_rids
;
3832 r_u
->num_entries
= 0;
3834 r_u
->num_entries2
= 0;
3837 r_u
->status
= status
;
3840 /*******************************************************************
3841 reads or writes a structure.
3842 ********************************************************************/
3844 BOOL
samr_io_rids(const char *desc
, uint32
*num_rids
, uint32
**rid
,
3845 prs_struct
*ps
, int depth
)
3852 prs_debug(ps
, depth
, desc
, "samr_io_rids");
3858 if(!prs_uint32("num_rids", ps
, depth
, num_rids
))
3861 if ((*num_rids
) != 0) {
3862 if (UNMARSHALLING(ps
)) {
3864 (*rid
) = (uint32
*)prs_alloc_mem(ps
,sizeof(uint32
)*(*num_rids
));
3869 for (i
= 0; i
< (*num_rids
); i
++) {
3870 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d]", i
);
3871 if(!prs_uint32(tmp
, ps
, depth
, &((*rid
)[i
])))
3879 /*******************************************************************
3880 reads or writes a structure.
3881 ********************************************************************/
3883 BOOL
samr_io_r_query_useraliases(const char *desc
, SAMR_R_QUERY_USERALIASES
* r_u
,
3884 prs_struct
*ps
, int depth
)
3889 prs_debug(ps
, depth
, desc
, "samr_io_r_query_useraliases");
3895 if(!prs_uint32("num_entries", ps
, depth
, &r_u
->num_entries
))
3897 if(!prs_uint32("ptr ", ps
, depth
, &r_u
->ptr
))
3900 if (r_u
->ptr
!= 0) {
3901 if(!samr_io_rids("rids", &r_u
->num_entries2
, &r_u
->rid
, ps
, depth
))
3907 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3913 /*******************************************************************
3914 inits a SAMR_Q_OPEN_ALIAS structure.
3915 ********************************************************************/
3917 void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
* q_u
, POLICY_HND
*pol
,
3918 uint32 access_mask
, uint32 rid
)
3920 DEBUG(5, ("init_samr_q_open_alias\n"));
3922 q_u
->dom_pol
= *pol
;
3923 q_u
->access_mask
= access_mask
;
3924 q_u
->rid_alias
= rid
;
3927 /*******************************************************************
3928 reads or writes a structure.
3929 ********************************************************************/
3931 BOOL
samr_io_q_open_alias(const char *desc
, SAMR_Q_OPEN_ALIAS
* q_u
,
3932 prs_struct
*ps
, int depth
)
3937 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
3943 if(!smb_io_pol_hnd("domain_pol", &q_u
->dom_pol
, ps
, depth
))
3946 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
3948 if(!prs_uint32("rid_alias", ps
, depth
, &q_u
->rid_alias
))
3954 /*******************************************************************
3955 reads or writes a structure.
3956 ********************************************************************/
3958 BOOL
samr_io_r_open_alias(const char *desc
, SAMR_R_OPEN_ALIAS
* r_u
,
3959 prs_struct
*ps
, int depth
)
3964 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
3970 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
3973 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
3979 /*******************************************************************
3980 inits a SAMR_Q_LOOKUP_RIDS structure.
3981 ********************************************************************/
3983 void init_samr_q_lookup_rids(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_RIDS
* q_u
,
3984 POLICY_HND
*pol
, uint32 flags
,
3985 uint32 num_rids
, uint32
*rid
)
3987 DEBUG(5, ("init_samr_q_lookup_rids\n"));
3991 q_u
->num_rids1
= num_rids
;
3994 q_u
->num_rids2
= num_rids
;
3995 q_u
->rid
= (uint32
*)talloc_zero(ctx
, num_rids
* sizeof(q_u
->rid
[0]));
3996 if (q_u
->rid
== NULL
) {
4000 memcpy(q_u
->rid
, rid
, num_rids
* sizeof(q_u
->rid
[0]));
4004 /*******************************************************************
4005 reads or writes a structure.
4006 ********************************************************************/
4008 BOOL
samr_io_q_lookup_rids(const char *desc
, SAMR_Q_LOOKUP_RIDS
* q_u
,
4009 prs_struct
*ps
, int depth
)
4017 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_rids");
4020 if (UNMARSHALLING(ps
))
4026 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4029 if(!prs_uint32("num_rids1", ps
, depth
, &q_u
->num_rids1
))
4031 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4033 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4035 if(!prs_uint32("num_rids2", ps
, depth
, &q_u
->num_rids2
))
4038 if (UNMARSHALLING(ps
) && (q_u
->num_rids2
!= 0)) {
4039 q_u
->rid
= (uint32
*)prs_alloc_mem(ps
, sizeof(q_u
->rid
[0])*q_u
->num_rids2
);
4040 if (q_u
->rid
== NULL
)
4044 for (i
= 0; i
< q_u
->num_rids2
; i
++) {
4045 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4046 if(!prs_uint32(tmp
, ps
, depth
, &q_u
->rid
[i
]))
4053 /*******************************************************************
4054 inits a SAMR_R_LOOKUP_RIDS structure.
4055 ********************************************************************/
4057 void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS
* r_u
,
4058 uint32 num_names
, UNIHDR
* hdr_name
,
4059 UNISTR2
*uni_name
, uint32
*type
)
4061 DEBUG(5, ("init_samr_r_lookup_rids\n"));
4063 r_u
->hdr_name
= NULL
;
4064 r_u
->uni_name
= NULL
;
4067 if (num_names
!= 0) {
4068 r_u
->num_names1
= num_names
;
4070 r_u
->num_names2
= num_names
;
4072 r_u
->num_types1
= num_names
;
4074 r_u
->num_types2
= num_names
;
4076 r_u
->hdr_name
= hdr_name
;
4077 r_u
->uni_name
= uni_name
;
4080 r_u
->num_names1
= num_names
;
4082 r_u
->num_names2
= num_names
;
4084 r_u
->num_types1
= num_names
;
4086 r_u
->num_types2
= num_names
;
4090 /*******************************************************************
4091 reads or writes a structure.
4092 ********************************************************************/
4094 BOOL
samr_io_r_lookup_rids(const char *desc
, SAMR_R_LOOKUP_RIDS
* r_u
,
4095 prs_struct
*ps
, int depth
)
4102 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_rids");
4108 if(!prs_uint32("num_names1", ps
, depth
, &r_u
->num_names1
))
4110 if(!prs_uint32("ptr_names ", ps
, depth
, &r_u
->ptr_names
))
4113 if (r_u
->ptr_names
!= 0) {
4115 if(!prs_uint32("num_names2", ps
, depth
, &r_u
->num_names2
))
4119 if (UNMARSHALLING(ps
) && (r_u
->num_names2
!= 0)) {
4120 r_u
->hdr_name
= (UNIHDR
*) prs_alloc_mem(ps
, r_u
->num_names2
* sizeof(r_u
->hdr_name
[0]));
4121 if (r_u
->hdr_name
== NULL
)
4124 r_u
->uni_name
= (UNISTR2
*)prs_alloc_mem(ps
, r_u
->num_names2
* sizeof(r_u
->uni_name
[0]));
4125 if (r_u
->uni_name
== NULL
)
4129 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4130 slprintf(tmp
, sizeof(tmp
) - 1, "hdr[%02d] ", i
);
4131 if(!smb_io_unihdr("", &r_u
->hdr_name
[i
], ps
, depth
))
4134 for (i
= 0; i
< r_u
->num_names2
; i
++) {
4135 slprintf(tmp
, sizeof(tmp
) - 1, "str[%02d] ", i
);
4136 if(!smb_io_unistr2("", &r_u
->uni_name
[i
], r_u
->hdr_name
[i
].buffer
, ps
, depth
))
4144 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4146 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4149 if (r_u
->ptr_types
!= 0) {
4151 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4154 if (UNMARSHALLING(ps
) && (r_u
->num_types2
!= 0)) {
4155 r_u
->type
= (uint32
*)prs_alloc_mem(ps
, r_u
->num_types2
* sizeof(r_u
->type
[0]));
4156 if (r_u
->type
== NULL
)
4160 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4161 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4162 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->type
[i
]))
4167 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4173 /*******************************************************************
4174 inits a SAMR_Q_OPEN_ALIAS structure.
4175 ********************************************************************/
4177 void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_u
, POLICY_HND
*hnd
)
4179 DEBUG(5, ("init_samr_q_delete_alias\n"));
4181 q_u
->alias_pol
= *hnd
;
4184 /*******************************************************************
4185 reads or writes a structure.
4186 ********************************************************************/
4188 BOOL
samr_io_q_delete_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4189 prs_struct
*ps
, int depth
)
4194 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_alias");
4200 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4206 /*******************************************************************
4207 reads or writes a structure.
4208 ********************************************************************/
4210 BOOL
samr_io_r_delete_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4211 prs_struct
*ps
, int depth
)
4216 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_alias");
4222 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4224 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4230 /*******************************************************************
4231 inits a SAMR_Q_CREATE_DOM_ALIAS structure.
4232 ********************************************************************/
4234 void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4235 POLICY_HND
*hnd
, const char *acct_desc
)
4237 DEBUG(5, ("init_samr_q_create_dom_alias\n"));
4239 q_u
->dom_pol
= *hnd
;
4241 init_unistr2(&q_u
->uni_acct_desc
, acct_desc
, UNI_FLAGS_NONE
);
4242 init_uni_hdr(&q_u
->hdr_acct_desc
, &q_u
->uni_acct_desc
);
4244 q_u
->access_mask
= MAXIMUM_ALLOWED_ACCESS
;
4247 /*******************************************************************
4248 reads or writes a structure.
4249 ********************************************************************/
4251 BOOL
samr_io_q_create_dom_alias(const char *desc
, SAMR_Q_CREATE_DOM_ALIAS
* q_u
,
4252 prs_struct
*ps
, int depth
)
4257 prs_debug(ps
, depth
, desc
, "samr_io_q_create_dom_alias");
4263 if(!smb_io_pol_hnd("dom_pol", &q_u
->dom_pol
, ps
, depth
))
4266 if(!smb_io_unihdr("hdr_acct_desc", &q_u
->hdr_acct_desc
, ps
, depth
))
4268 if(!smb_io_unistr2("uni_acct_desc", &q_u
->uni_acct_desc
,
4269 q_u
->hdr_acct_desc
.buffer
, ps
, depth
))
4274 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4280 /*******************************************************************
4281 reads or writes a structure.
4282 ********************************************************************/
4284 BOOL
samr_io_r_create_dom_alias(const char *desc
, SAMR_R_CREATE_DOM_ALIAS
* r_u
,
4285 prs_struct
*ps
, int depth
)
4290 prs_debug(ps
, depth
, desc
, "samr_io_r_create_dom_alias");
4296 if(!smb_io_pol_hnd("alias_pol", &r_u
->alias_pol
, ps
, depth
))
4299 if(!prs_uint32("rid", ps
, depth
, &r_u
->rid
))
4302 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4308 /*******************************************************************
4309 inits a SAMR_Q_ADD_ALIASMEM structure.
4310 ********************************************************************/
4312 void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4315 DEBUG(5, ("init_samr_q_add_aliasmem\n"));
4317 q_u
->alias_pol
= *hnd
;
4318 init_dom_sid2(&q_u
->sid
, sid
);
4321 /*******************************************************************
4322 reads or writes a structure.
4323 ********************************************************************/
4325 BOOL
samr_io_q_add_aliasmem(const char *desc
, SAMR_Q_ADD_ALIASMEM
* q_u
,
4326 prs_struct
*ps
, int depth
)
4331 prs_debug(ps
, depth
, desc
, "samr_io_q_add_aliasmem");
4337 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4339 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4345 /*******************************************************************
4346 reads or writes a structure.
4347 ********************************************************************/
4349 BOOL
samr_io_r_add_aliasmem(const char *desc
, SAMR_R_ADD_ALIASMEM
* r_u
,
4350 prs_struct
*ps
, int depth
)
4355 prs_debug(ps
, depth
, desc
, "samr_io_r_add_aliasmem");
4361 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4367 /*******************************************************************
4368 inits a SAMR_Q_DEL_ALIASMEM structure.
4369 ********************************************************************/
4371 void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM
* q_u
, POLICY_HND
*hnd
,
4374 DEBUG(5, ("init_samr_q_del_aliasmem\n"));
4376 q_u
->alias_pol
= *hnd
;
4377 init_dom_sid2(&q_u
->sid
, sid
);
4380 /*******************************************************************
4381 reads or writes a structure.
4382 ********************************************************************/
4384 BOOL
samr_io_q_del_aliasmem(const char *desc
, SAMR_Q_DEL_ALIASMEM
* q_u
,
4385 prs_struct
*ps
, int depth
)
4390 prs_debug(ps
, depth
, desc
, "samr_io_q_del_aliasmem");
4396 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4398 if(!smb_io_dom_sid2("sid ", &q_u
->sid
, ps
, depth
))
4404 /*******************************************************************
4405 reads or writes a structure.
4406 ********************************************************************/
4408 BOOL
samr_io_r_del_aliasmem(const char *desc
, SAMR_R_DEL_ALIASMEM
* r_u
,
4409 prs_struct
*ps
, int depth
)
4414 prs_debug(ps
, depth
, desc
, "samr_io_r_del_aliasmem");
4420 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4426 /*******************************************************************
4427 inits a SAMR_Q_DELETE_DOM_ALIAS structure.
4428 ********************************************************************/
4430 void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS
* q_c
,
4433 DEBUG(5, ("init_samr_q_delete_dom_alias\n"));
4435 q_c
->alias_pol
= *hnd
;
4438 /*******************************************************************
4439 reads or writes a structure.
4440 ********************************************************************/
4442 BOOL
samr_io_q_delete_dom_alias(const char *desc
, SAMR_Q_DELETE_DOM_ALIAS
* q_u
,
4443 prs_struct
*ps
, int depth
)
4448 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_alias");
4454 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4460 /*******************************************************************
4461 inits a SAMR_R_DELETE_DOM_ALIAS structure.
4462 ********************************************************************/
4464 void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4467 DEBUG(5, ("init_samr_r_delete_dom_alias\n"));
4469 r_u
->status
= status
;
4472 /*******************************************************************
4473 reads or writes a structure.
4474 ********************************************************************/
4476 BOOL
samr_io_r_delete_dom_alias(const char *desc
, SAMR_R_DELETE_DOM_ALIAS
* r_u
,
4477 prs_struct
*ps
, int depth
)
4482 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_alias");
4488 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4494 /*******************************************************************
4495 inits a SAMR_Q_QUERY_ALIASMEM structure.
4496 ********************************************************************/
4498 void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM
* q_c
,
4501 DEBUG(5, ("init_samr_q_query_aliasmem\n"));
4503 q_c
->alias_pol
= *hnd
;
4506 /*******************************************************************
4507 reads or writes a structure.
4508 ********************************************************************/
4510 BOOL
samr_io_q_query_aliasmem(const char *desc
, SAMR_Q_QUERY_ALIASMEM
* q_u
,
4511 prs_struct
*ps
, int depth
)
4516 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasmem");
4522 if(!smb_io_pol_hnd("alias_pol", &q_u
->alias_pol
, ps
, depth
))
4528 /*******************************************************************
4529 inits a SAMR_R_QUERY_ALIASMEM structure.
4530 ********************************************************************/
4532 void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM
* r_u
,
4533 uint32 num_sids
, DOM_SID2
* sid
,
4536 DEBUG(5, ("init_samr_r_query_aliasmem\n"));
4538 if (NT_STATUS_IS_OK(status
)) {
4539 r_u
->num_sids
= num_sids
;
4540 r_u
->ptr
= (num_sids
!= 0) ? 1 : 0;
4541 r_u
->num_sids1
= num_sids
;
4549 r_u
->status
= status
;
4552 /*******************************************************************
4553 reads or writes a structure.
4554 ********************************************************************/
4556 BOOL
samr_io_r_query_aliasmem(const char *desc
, SAMR_R_QUERY_ALIASMEM
* r_u
,
4557 prs_struct
*ps
, int depth
)
4564 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasmem");
4570 if(!prs_uint32("num_sids ", ps
, depth
, &r_u
->num_sids
))
4572 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
4575 if (r_u
->ptr
!= 0 && r_u
->num_sids
!= 0) {
4576 uint32
*ptr_sid
= NULL
;
4578 if(!prs_uint32("num_sids1", ps
, depth
, &r_u
->num_sids1
))
4581 ptr_sid
= talloc(ps
->mem_ctx
, sizeof(uint32
) * r_u
->num_sids1
);
4586 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4588 if(!prs_uint32("ptr_sid", ps
, depth
, &ptr_sid
[i
]))
4592 if (UNMARSHALLING(ps
)) {
4593 r_u
->sid
= talloc(ps
->mem_ctx
, r_u
->num_sids1
* sizeof(DOM_SID2
));
4596 for (i
= 0; i
< r_u
->num_sids1
; i
++) {
4597 if (ptr_sid
[i
] != 0) {
4598 if(!smb_io_dom_sid2("sid", &r_u
->sid
[i
], ps
, depth
))
4606 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4612 /*******************************************************************
4613 inits a SAMR_Q_LOOKUP_NAMES structure.
4614 ********************************************************************/
4616 NTSTATUS
init_samr_q_lookup_names(TALLOC_CTX
*ctx
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4617 POLICY_HND
*pol
, uint32 flags
,
4618 uint32 num_names
, const char **name
)
4622 DEBUG(5, ("init_samr_q_lookup_names\n"));
4626 q_u
->num_names1
= num_names
;
4629 q_u
->num_names2
= num_names
;
4631 if (!(q_u
->hdr_name
= (UNIHDR
*)talloc_zero(ctx
, num_names
* sizeof(UNIHDR
))))
4632 return NT_STATUS_NO_MEMORY
;
4634 if (!(q_u
->uni_name
= (UNISTR2
*)talloc_zero(ctx
, num_names
* sizeof(UNISTR2
))))
4635 return NT_STATUS_NO_MEMORY
;
4637 for (i
= 0; i
< num_names
; i
++) {
4638 init_unistr2(&q_u
->uni_name
[i
], name
[i
], UNI_FLAGS_NONE
); /* unicode string for machine account */
4639 init_uni_hdr(&q_u
->hdr_name
[i
], &q_u
->uni_name
[i
]); /* unicode header for user_name */
4642 return NT_STATUS_OK
;
4645 /*******************************************************************
4646 reads or writes a structure.
4647 ********************************************************************/
4649 BOOL
samr_io_q_lookup_names(const char *desc
, SAMR_Q_LOOKUP_NAMES
* q_u
,
4650 prs_struct
*ps
, int depth
)
4657 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
4660 if (UNMARSHALLING(ps
))
4666 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
4669 if(!prs_uint32("num_names1", ps
, depth
, &q_u
->num_names1
))
4671 if(!prs_uint32("flags ", ps
, depth
, &q_u
->flags
))
4673 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
4675 if(!prs_uint32("num_names2", ps
, depth
, &q_u
->num_names2
))
4678 if (UNMARSHALLING(ps
) && (q_u
->num_names2
!= 0)) {
4679 q_u
->hdr_name
= (UNIHDR
*)prs_alloc_mem(ps
, sizeof(UNIHDR
) *
4681 q_u
->uni_name
= (UNISTR2
*)prs_alloc_mem(ps
, sizeof(UNISTR2
) *
4683 if (!q_u
->hdr_name
|| !q_u
->uni_name
)
4687 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4688 if(!smb_io_unihdr("", &q_u
->hdr_name
[i
], ps
, depth
))
4692 for (i
= 0; i
< q_u
->num_names2
; i
++) {
4693 if(!smb_io_unistr2("", &q_u
->uni_name
[i
], q_u
->hdr_name
[i
].buffer
, ps
, depth
))
4700 /*******************************************************************
4701 inits a SAMR_R_LOOKUP_NAMES structure.
4702 ********************************************************************/
4704 NTSTATUS
init_samr_r_lookup_names(TALLOC_CTX
*ctx
, SAMR_R_LOOKUP_NAMES
* r_u
,
4706 uint32
*rid
, uint32
*type
,
4709 DEBUG(5, ("init_samr_r_lookup_names\n"));
4711 if (NT_STATUS_IS_OK(status
) && (num_rids
!= 0)) {
4714 r_u
->num_types1
= num_rids
;
4716 r_u
->num_types2
= num_rids
;
4718 r_u
->num_rids1
= num_rids
;
4720 r_u
->num_rids2
= num_rids
;
4722 if (!(r_u
->rids
= (uint32
*)talloc_zero(ctx
, sizeof(uint32
)*num_rids
)))
4723 return NT_STATUS_NO_MEMORY
;
4724 if (!(r_u
->types
= (uint32
*)talloc_zero(ctx
, sizeof(uint32
)*num_rids
)))
4725 return NT_STATUS_NO_MEMORY
;
4727 if (!r_u
->rids
|| !r_u
->types
)
4730 for (i
= 0; i
< num_rids
; i
++) {
4731 r_u
->rids
[i
] = rid
[i
];
4732 r_u
->types
[i
] = type
[i
];
4737 r_u
->num_types1
= 0;
4739 r_u
->num_types2
= 0;
4749 r_u
->status
= status
;
4751 return NT_STATUS_OK
;
4754 /*******************************************************************
4755 reads or writes a structure.
4756 ********************************************************************/
4758 BOOL
samr_io_r_lookup_names(const char *desc
, SAMR_R_LOOKUP_NAMES
* r_u
,
4759 prs_struct
*ps
, int depth
)
4767 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
4770 if (UNMARSHALLING(ps
))
4776 if(!prs_uint32("num_rids1", ps
, depth
, &r_u
->num_rids1
))
4778 if(!prs_uint32("ptr_rids ", ps
, depth
, &r_u
->ptr_rids
))
4781 if (r_u
->ptr_rids
!= 0) {
4782 if(!prs_uint32("num_rids2", ps
, depth
, &r_u
->num_rids2
))
4785 if (r_u
->num_rids2
!= r_u
->num_rids1
) {
4790 if (UNMARSHALLING(ps
))
4791 r_u
->rids
= (uint32
*)prs_alloc_mem(ps
, sizeof(uint32
)*r_u
->num_rids2
);
4794 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n"));
4798 for (i
= 0; i
< r_u
->num_rids2
; i
++) {
4799 slprintf(tmp
, sizeof(tmp
) - 1, "rid[%02d] ", i
);
4800 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->rids
[i
]))
4805 if(!prs_uint32("num_types1", ps
, depth
, &r_u
->num_types1
))
4807 if(!prs_uint32("ptr_types ", ps
, depth
, &r_u
->ptr_types
))
4810 if (r_u
->ptr_types
!= 0) {
4811 if(!prs_uint32("num_types2", ps
, depth
, &r_u
->num_types2
))
4814 if (r_u
->num_types2
!= r_u
->num_types1
) {
4819 if (UNMARSHALLING(ps
))
4820 r_u
->types
= (uint32
*)prs_alloc_mem(ps
, sizeof(uint32
)*r_u
->num_types2
);
4823 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n"));
4827 for (i
= 0; i
< r_u
->num_types2
; i
++) {
4828 slprintf(tmp
, sizeof(tmp
) - 1, "type[%02d] ", i
);
4829 if(!prs_uint32(tmp
, ps
, depth
, &r_u
->types
[i
]))
4834 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4840 /*******************************************************************
4841 inits a SAMR_Q_DELETE_DOM_USER structure.
4842 ********************************************************************/
4844 void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER
* q_c
,
4847 DEBUG(5, ("init_samr_q_delete_dom_user\n"));
4849 q_c
->user_pol
= *hnd
;
4852 /*******************************************************************
4853 reads or writes a structure.
4854 ********************************************************************/
4856 BOOL
samr_io_q_delete_dom_user(const char *desc
, SAMR_Q_DELETE_DOM_USER
* q_u
,
4857 prs_struct
*ps
, int depth
)
4862 prs_debug(ps
, depth
, desc
, "samr_io_q_delete_dom_user");
4868 if(!smb_io_pol_hnd("user_pol", &q_u
->user_pol
, ps
, depth
))
4874 /*******************************************************************
4875 reads or writes a structure.
4876 ********************************************************************/
4878 BOOL
samr_io_r_delete_dom_user(const char *desc
, SAMR_R_DELETE_DOM_USER
* r_u
,
4879 prs_struct
*ps
, int depth
)
4884 prs_debug(ps
, depth
, desc
, "samr_io_r_delete_dom_user");
4890 if(!smb_io_pol_hnd("pol", &r_u
->pol
, ps
, depth
))
4892 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4898 /*******************************************************************
4899 reads or writes a structure.
4900 ********************************************************************/
4902 void init_samr_q_open_user(SAMR_Q_OPEN_USER
* q_u
,
4904 uint32 access_mask
, uint32 rid
)
4906 DEBUG(5, ("samr_init_samr_q_open_user\n"));
4908 q_u
->domain_pol
= *pol
;
4909 q_u
->access_mask
= access_mask
;
4910 q_u
->user_rid
= rid
;
4913 /*******************************************************************
4914 reads or writes a structure.
4915 ********************************************************************/
4917 BOOL
samr_io_q_open_user(const char *desc
, SAMR_Q_OPEN_USER
* q_u
,
4918 prs_struct
*ps
, int depth
)
4923 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
4929 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
4932 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
4934 if(!prs_uint32("user_rid ", ps
, depth
, &q_u
->user_rid
))
4940 /*******************************************************************
4941 reads or writes a structure.
4942 ********************************************************************/
4944 BOOL
samr_io_r_open_user(const char *desc
, SAMR_R_OPEN_USER
* r_u
,
4945 prs_struct
*ps
, int depth
)
4950 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
4956 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
4959 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
4966 /*******************************************************************
4967 reads or writes a structure.
4968 ********************************************************************/
4970 void init_samr_q_create_user(SAMR_Q_CREATE_USER
* q_u
,
4973 uint32 acb_info
, uint32 access_mask
)
4975 DEBUG(5, ("samr_init_samr_q_create_user\n"));
4977 q_u
->domain_pol
= *pol
;
4979 init_unistr2(&q_u
->uni_name
, name
, UNI_FLAGS_NONE
);
4980 init_uni_hdr(&q_u
->hdr_name
, &q_u
->uni_name
);
4982 q_u
->acb_info
= acb_info
;
4983 q_u
->access_mask
= access_mask
;
4986 /*******************************************************************
4987 reads or writes a structure.
4988 ********************************************************************/
4990 BOOL
samr_io_q_create_user(const char *desc
, SAMR_Q_CREATE_USER
* q_u
,
4991 prs_struct
*ps
, int depth
)
4996 prs_debug(ps
, depth
, desc
, "samr_io_q_create_user");
5002 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
5005 if(!smb_io_unihdr("hdr_name", &q_u
->hdr_name
, ps
, depth
))
5007 if(!smb_io_unistr2("uni_name", &q_u
->uni_name
, q_u
->hdr_name
.buffer
, ps
, depth
))
5012 if(!prs_uint32("acb_info ", ps
, depth
, &q_u
->acb_info
))
5014 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
5020 /*******************************************************************
5021 reads or writes a structure.
5022 ********************************************************************/
5024 BOOL
samr_io_r_create_user(const char *desc
, SAMR_R_CREATE_USER
* r_u
,
5025 prs_struct
*ps
, int depth
)
5030 prs_debug(ps
, depth
, desc
, "samr_io_r_create_user");
5036 if(!smb_io_pol_hnd("user_pol", &r_u
->user_pol
, ps
, depth
))
5039 if(!prs_uint32("access_granted", ps
, depth
, &r_u
->access_granted
))
5041 if(!prs_uint32("user_rid ", ps
, depth
, &r_u
->user_rid
))
5043 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
5049 /*******************************************************************
5050 inits a SAMR_Q_QUERY_USERINFO structure.
5051 ********************************************************************/
5053 void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
* q_u
,
5054 POLICY_HND
*hnd
, uint16 switch_value
)
5056 DEBUG(5, ("init_samr_q_query_userinfo\n"));
5059 q_u
->switch_value
= switch_value
;
5062 /*******************************************************************
5063 reads or writes a structure.
5064 ********************************************************************/
5066 BOOL
samr_io_q_query_userinfo(const char *desc
, SAMR_Q_QUERY_USERINFO
* q_u
,
5067 prs_struct
*ps
, int depth
)
5072 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
5078 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
5081 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
)) /* 0x0015 or 0x0011 */
5087 /*******************************************************************
5088 reads or writes a LOGON_HRS structure.
5089 ********************************************************************/
5091 static BOOL
sam_io_logon_hrs(const char *desc
, LOGON_HRS
* hrs
,
5092 prs_struct
*ps
, int depth
)
5097 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
5103 if(!prs_uint32("len ", ps
, depth
, &hrs
->len
))
5106 if (hrs
->len
> sizeof(hrs
->hours
)) {
5107 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs
->len
));
5108 hrs
->len
= sizeof(hrs
->hours
);
5111 if(!prs_uint8s(False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
))
5117 /*******************************************************************
5118 inits a SAM_USER_INFO_12 structure.
5119 ********************************************************************/
5121 void init_sam_user_info12(SAM_USER_INFO_12
* usr
,
5122 const uint8 lm_pwd
[16], const uint8 nt_pwd
[16])
5124 DEBUG(5, ("init_sam_user_info12\n"));
5126 usr
->lm_pwd_active
=
5127 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
)) ? 1 : 0;
5128 usr
->nt_pwd_active
=
5129 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
)) ? 1 : 0;
5132 /*******************************************************************
5133 reads or writes a structure.
5134 ********************************************************************/
5136 static BOOL
sam_io_user_info12(const char *desc
, SAM_USER_INFO_12
* u
,
5137 prs_struct
*ps
, int depth
)
5142 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info12");
5148 if(!prs_uint8s(False
, "lm_pwd", ps
, depth
, u
->lm_pwd
, sizeof(u
->lm_pwd
)))
5150 if(!prs_uint8s(False
, "nt_pwd", ps
, depth
, u
->nt_pwd
, sizeof(u
->nt_pwd
)))
5153 if(!prs_uint8("lm_pwd_active", ps
, depth
, &u
->lm_pwd_active
))
5155 if(!prs_uint8("nt_pwd_active", ps
, depth
, &u
->nt_pwd_active
))
5161 /*******************************************************************
5162 inits a SAM_USER_INFO_10 structure.
5163 ********************************************************************/
5165 void init_sam_user_info10(SAM_USER_INFO_10
* usr
, uint32 acb_info
)
5167 DEBUG(5, ("init_sam_user_info10\n"));
5169 usr
->acb_info
= acb_info
;
5172 /*******************************************************************
5173 reads or writes a structure.
5174 ********************************************************************/
5176 static BOOL
sam_io_user_info10(const char *desc
, SAM_USER_INFO_10
* usr
,
5177 prs_struct
*ps
, int depth
)
5182 prs_debug(ps
, depth
, desc
, "samr_io_r_user_info10");
5188 if(!prs_uint32("acb_info", ps
, depth
, &usr
->acb_info
))
5194 /*******************************************************************
5195 inits a SAM_USER_INFO_11 structure.
5196 ********************************************************************/
5198 void init_sam_user_info11(SAM_USER_INFO_11
* usr
,
5201 uint32 rid_user
, uint32 rid_group
, uint16 acct_ctrl
)
5203 DEBUG(5, ("init_sam_user_info11\n"));
5205 memcpy(&usr
->expiry
, expiry
, sizeof(usr
->expiry
)); /* expiry time or something? */
5206 ZERO_STRUCT(usr
->padding_1
); /* 0 - padding 24 bytes */
5208 usr
->padding_2
= 0; /* 0 - padding 4 bytes */
5210 usr
->ptr_1
= 1; /* pointer */
5211 ZERO_STRUCT(usr
->padding_3
); /* 0 - padding 32 bytes */
5212 usr
->padding_4
= 0; /* 0 - padding 4 bytes */
5214 usr
->ptr_2
= 1; /* pointer */
5215 usr
->padding_5
= 0; /* 0 - padding 4 bytes */
5217 usr
->ptr_3
= 1; /* pointer */
5218 ZERO_STRUCT(usr
->padding_6
); /* 0 - padding 32 bytes */
5220 usr
->rid_user
= rid_user
;
5221 usr
->rid_group
= rid_group
;
5223 usr
->acct_ctrl
= acct_ctrl
;
5224 usr
->unknown_3
= 0x0000;
5226 usr
->unknown_4
= 0x003f; /* 0x003f - 16 bit unknown */
5227 usr
->unknown_5
= 0x003c; /* 0x003c - 16 bit unknown */
5229 ZERO_STRUCT(usr
->padding_7
); /* 0 - padding 16 bytes */
5230 usr
->padding_8
= 0; /* 0 - padding 4 bytes */
5232 init_unistr2(&usr
->uni_mach_acct
, mach_acct
, UNI_FLAGS_NONE
); /* unicode string for machine account */
5233 init_uni_hdr(&usr
->hdr_mach_acct
, &usr
->uni_mach_acct
); /* unicode header for machine account */
5236 /*******************************************************************
5237 reads or writes a structure.
5238 ********************************************************************/
5240 static BOOL
sam_io_user_info11(const char *desc
, SAM_USER_INFO_11
* usr
,
5241 prs_struct
*ps
, int depth
)
5246 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_11");
5252 if(!prs_uint8s(False
, "padding_0", ps
, depth
, usr
->padding_0
, sizeof(usr
->padding_0
)))
5255 if(!smb_io_time("time", &usr
->expiry
, ps
, depth
))
5258 if(!prs_uint8s(False
, "padding_1", ps
, depth
, usr
->padding_1
, sizeof(usr
->padding_1
)))
5261 if(!smb_io_unihdr("unihdr", &usr
->hdr_mach_acct
, ps
, depth
))
5264 if(!prs_uint32("padding_2", ps
, depth
, &usr
->padding_2
))
5267 if(!prs_uint32("ptr_1 ", ps
, depth
, &usr
->ptr_1
))
5269 if(!prs_uint8s(False
, "padding_3", ps
, depth
, usr
->padding_3
, sizeof(usr
->padding_3
)))
5272 if(!prs_uint32("padding_4", ps
, depth
, &usr
->padding_4
))
5275 if(!prs_uint32("ptr_2 ", ps
, depth
, &usr
->ptr_2
))
5277 if(!prs_uint32("padding_5", ps
, depth
, &usr
->padding_5
))
5280 if(!prs_uint32("ptr_3 ", ps
, depth
, &usr
->ptr_3
))
5282 if(!prs_uint8s(False
, "padding_6", ps
, depth
, usr
->padding_6
,sizeof(usr
->padding_6
)))
5285 if(!prs_uint32("rid_user ", ps
, depth
, &usr
->rid_user
))
5287 if(!prs_uint32("rid_group", ps
, depth
, &usr
->rid_group
))
5289 if(!prs_uint16("acct_ctrl", ps
, depth
, &usr
->acct_ctrl
))
5291 if(!prs_uint16("unknown_3", ps
, depth
, &usr
->unknown_3
))
5293 if(!prs_uint16("unknown_4", ps
, depth
, &usr
->unknown_4
))
5295 if(!prs_uint16("unknown_5", ps
, depth
, &usr
->unknown_5
))
5298 if(!prs_uint8s(False
, "padding_7", ps
, depth
, usr
->padding_7
, sizeof(usr
->padding_7
)))
5301 if(!prs_uint32("padding_8", ps
, depth
, &(usr
->padding_8
)))
5304 if(!smb_io_unistr2("unistr2", &usr
->uni_mach_acct
, True
, ps
, depth
))
5310 if(!prs_uint8s(False
, "padding_9", ps
, depth
, usr
->padding_9
, sizeof(usr
->padding_9
)))
5316 /*************************************************************************
5319 unknown_5 = 0x0001 0000
5320 unknown_6 = 0x0000 04ec
5322 *************************************************************************/
5324 void init_sam_user_info24(SAM_USER_INFO_24
* usr
, char newpass
[516], uint16 pw_len
)
5326 DEBUG(10, ("init_sam_user_info24:\n"));
5327 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5328 usr
->pw_len
= pw_len
;
5331 /*******************************************************************
5332 reads or writes a structure.
5333 ********************************************************************/
5335 static BOOL
sam_io_user_info24(const char *desc
, SAM_USER_INFO_24
* usr
,
5336 prs_struct
*ps
, int depth
)
5341 prs_debug(ps
, depth
, desc
, "sam_io_user_info24");
5347 if(!prs_uint8s(False
, "password", ps
, depth
, usr
->pass
,
5351 if (MARSHALLING(ps
) && (usr
->pw_len
!= 0)) {
5352 if (!prs_uint16("pw_len", ps
, depth
, &usr
->pw_len
))
5361 /*************************************************************************
5362 init_sam_user_info23
5364 unknown_6 = 0x0000 04ec
5366 *************************************************************************/
5368 void init_sam_user_info23W(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5369 NTTIME
* logoff_time
, /* all zeros */
5370 NTTIME
* kickoff_time
, /* all zeros */
5371 NTTIME
* pass_last_set_time
, /* all zeros */
5372 NTTIME
* pass_can_change_time
, /* all zeros */
5373 NTTIME
* pass_must_change_time
, /* all zeros */
5384 uint32 user_rid
, /* 0x0000 0000 */
5387 uint32 fields_present
,
5390 uint16 bad_password_count
,
5392 char newpass
[516], uint32 unknown_6
)
5394 usr
->logon_time
= *logon_time
; /* all zeros */
5395 usr
->logoff_time
= *logoff_time
; /* all zeros */
5396 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5397 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5398 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5399 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5401 ZERO_STRUCT(usr
->nt_pwd
);
5402 ZERO_STRUCT(usr
->lm_pwd
);
5404 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5405 usr
->group_rid
= group_rid
;
5406 usr
->acb_info
= acb_info
;
5407 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5409 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5410 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5412 if (nt_time_is_zero(pass_must_change_time
)) {
5413 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5415 usr
->passmustchange
=0;
5418 ZERO_STRUCT(usr
->padding1
);
5419 ZERO_STRUCT(usr
->padding2
);
5421 usr
->bad_password_count
= bad_password_count
;
5422 usr
->logon_count
= logon_count
;
5424 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5426 copy_unistr2(&usr
->uni_user_name
, user_name
);
5427 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5429 copy_unistr2(&usr
->uni_full_name
, full_name
);
5430 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5432 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5433 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5435 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5436 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5438 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5439 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5441 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5442 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5444 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5445 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5447 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5448 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5450 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5451 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5453 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5454 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5456 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5459 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5462 /*************************************************************************
5463 init_sam_user_info23
5465 unknown_6 = 0x0000 04ec
5467 *************************************************************************/
5469 void init_sam_user_info23A(SAM_USER_INFO_23
* usr
, NTTIME
* logon_time
, /* all zeros */
5470 NTTIME
* logoff_time
, /* all zeros */
5471 NTTIME
* kickoff_time
, /* all zeros */
5472 NTTIME
* pass_last_set_time
, /* all zeros */
5473 NTTIME
* pass_can_change_time
, /* all zeros */
5474 NTTIME
* pass_must_change_time
, /* all zeros */
5475 char *user_name
, /* NULL */
5477 char *home_dir
, char *dir_drive
, char *log_scr
,
5478 char *prof_path
, const char *desc
, char *wkstas
,
5479 char *unk_str
, char *mung_dial
, uint32 user_rid
, /* 0x0000 0000 */
5480 uint32 group_rid
, uint32 acb_info
,
5481 uint32 fields_present
, uint16 logon_divs
,
5482 LOGON_HRS
* hrs
, uint16 bad_password_count
, uint16 logon_count
,
5483 char newpass
[516], uint32 unknown_6
)
5485 DATA_BLOB blob
= base64_decode_data_blob(mung_dial
);
5487 usr
->logon_time
= *logon_time
; /* all zeros */
5488 usr
->logoff_time
= *logoff_time
; /* all zeros */
5489 usr
->kickoff_time
= *kickoff_time
; /* all zeros */
5490 usr
->pass_last_set_time
= *pass_last_set_time
; /* all zeros */
5491 usr
->pass_can_change_time
= *pass_can_change_time
; /* all zeros */
5492 usr
->pass_must_change_time
= *pass_must_change_time
; /* all zeros */
5494 ZERO_STRUCT(usr
->nt_pwd
);
5495 ZERO_STRUCT(usr
->lm_pwd
);
5497 usr
->user_rid
= user_rid
; /* 0x0000 0000 */
5498 usr
->group_rid
= group_rid
;
5499 usr
->acb_info
= acb_info
;
5500 usr
->fields_present
= fields_present
; /* 09f8 27fa */
5502 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5503 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5505 if (nt_time_is_zero(pass_must_change_time
)) {
5506 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5508 usr
->passmustchange
=0;
5511 ZERO_STRUCT(usr
->padding1
);
5512 ZERO_STRUCT(usr
->padding2
);
5514 usr
->bad_password_count
= bad_password_count
;
5515 usr
->logon_count
= logon_count
;
5517 memcpy(usr
->pass
, newpass
, sizeof(usr
->pass
));
5519 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
5520 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5522 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
5523 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5525 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
5526 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5528 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
5529 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5531 init_unistr2(&usr
->uni_logon_script
, log_scr
, UNI_FLAGS_NONE
);
5532 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5534 init_unistr2(&usr
->uni_profile_path
, prof_path
, UNI_FLAGS_NONE
);
5535 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5537 init_unistr2(&usr
->uni_acct_desc
, desc
, UNI_FLAGS_NONE
);
5538 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5540 init_unistr2(&usr
->uni_workstations
, wkstas
, UNI_FLAGS_NONE
);
5541 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5543 init_unistr2(&usr
->uni_unknown_str
, unk_str
, UNI_FLAGS_NONE
);
5544 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5546 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
5547 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5549 data_blob_free(&blob
);
5551 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5554 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5557 /*******************************************************************
5558 reads or writes a structure.
5559 ********************************************************************/
5561 static BOOL
sam_io_user_info23(const char *desc
, SAM_USER_INFO_23
* usr
,
5562 prs_struct
*ps
, int depth
)
5567 prs_debug(ps
, depth
, desc
, "sam_io_user_info23");
5573 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5575 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5577 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5579 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5581 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5583 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5586 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5588 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5590 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5592 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5594 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5596 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5598 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5600 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5602 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5604 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5607 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5609 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5612 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5614 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5616 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5619 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
5621 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
5625 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
5628 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
5630 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
5633 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
5635 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
5637 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
5641 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5644 /* here begins pointed-to data */
5646 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5649 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5652 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5655 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5658 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5661 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5664 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5667 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5670 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5673 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5676 /* ok, this is only guess-work (as usual) */
5677 if (usr
->ptr_logon_hrs
) {
5678 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
5680 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
5682 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5684 } else if (UNMARSHALLING(ps
)) {
5692 /*******************************************************************
5693 reads or writes a structure.
5694 NB. This structure is *definately* incorrect. It's my best guess
5695 currently for W2K SP2. The password field is encrypted in a different
5696 way than normal... And there are definately other problems. JRA.
5697 ********************************************************************/
5699 static BOOL
sam_io_user_info25(const char *desc
, SAM_USER_INFO_25
* usr
, prs_struct
*ps
, int depth
)
5704 prs_debug(ps
, depth
, desc
, "sam_io_user_info25");
5710 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
5712 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
5714 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
5716 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
, depth
))
5718 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
, depth
))
5720 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
5723 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
5725 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
5727 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
5729 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
5731 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
5733 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
5735 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
5737 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
5739 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
5741 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
5744 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
5746 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
5749 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
5751 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
5753 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
5756 if(!prs_uint32s(False
, "unknown_6 ", ps
, depth
, usr
->unknown_6
, 6))
5759 if(!prs_uint8s(False
, "password ", ps
, depth
, usr
->pass
, sizeof(usr
->pass
)))
5762 /* here begins pointed-to data */
5764 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
5767 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
5770 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
5773 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
5776 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
5779 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
5782 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
5785 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
5788 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
5791 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
, usr
->hdr_munged_dial
.buffer
, ps
, depth
))
5794 #if 0 /* JRA - unknown... */
5795 /* ok, this is only guess-work (as usual) */
5796 if (usr
->ptr_logon_hrs
) {
5797 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
5799 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
5801 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
5803 } else if (UNMARSHALLING(ps
)) {
5813 /*************************************************************************
5814 init_sam_user_info21W
5816 unknown_6 = 0x0000 04ec
5818 *************************************************************************/
5820 void init_sam_user_info21W(SAM_USER_INFO_21
* usr
,
5821 NTTIME
* logon_time
,
5822 NTTIME
* logoff_time
,
5823 NTTIME
* kickoff_time
,
5824 NTTIME
* pass_last_set_time
,
5825 NTTIME
* pass_can_change_time
,
5826 NTTIME
* pass_must_change_time
,
5842 uint32 fields_present
,
5845 uint16 bad_password_count
,
5849 usr
->logon_time
= *logon_time
;
5850 usr
->logoff_time
= *logoff_time
;
5851 usr
->kickoff_time
= *kickoff_time
;
5852 usr
->pass_last_set_time
= *pass_last_set_time
;
5853 usr
->pass_can_change_time
= *pass_can_change_time
;
5854 usr
->pass_must_change_time
= *pass_must_change_time
;
5856 memcpy(usr
->lm_pwd
, lm_pwd
, sizeof(usr
->lm_pwd
));
5857 memcpy(usr
->nt_pwd
, nt_pwd
, sizeof(usr
->nt_pwd
));
5859 usr
->user_rid
= user_rid
;
5860 usr
->group_rid
= group_rid
;
5861 usr
->acb_info
= acb_info
;
5862 usr
->fields_present
= fields_present
; /* 0x00ff ffff */
5864 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
5865 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
5866 usr
->bad_password_count
= bad_password_count
;
5867 usr
->logon_count
= logon_count
;
5869 if (nt_time_is_zero(pass_must_change_time
)) {
5870 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
5872 usr
->passmustchange
=0;
5875 ZERO_STRUCT(usr
->padding1
);
5876 ZERO_STRUCT(usr
->padding2
);
5878 copy_unistr2(&usr
->uni_user_name
, user_name
);
5879 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
5881 copy_unistr2(&usr
->uni_full_name
, full_name
);
5882 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
5884 copy_unistr2(&usr
->uni_home_dir
, home_dir
);
5885 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
5887 copy_unistr2(&usr
->uni_dir_drive
, dir_drive
);
5888 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
5890 copy_unistr2(&usr
->uni_logon_script
, log_scr
);
5891 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
5893 copy_unistr2(&usr
->uni_profile_path
, prof_path
);
5894 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
5896 copy_unistr2(&usr
->uni_acct_desc
, desc
);
5897 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
5899 copy_unistr2(&usr
->uni_workstations
, wkstas
);
5900 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
5902 copy_unistr2(&usr
->uni_unknown_str
, unk_str
);
5903 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
5905 copy_unistr2(&usr
->uni_munged_dial
, mung_dial
);
5906 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
5908 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
5911 memcpy(&usr
->logon_hrs
, hrs
, sizeof(usr
->logon_hrs
));
5914 /*************************************************************************
5915 init_sam_user_info21
5917 unknown_6 = 0x0000 04ec
5919 *************************************************************************/
5921 NTSTATUS
init_sam_user_info21A(SAM_USER_INFO_21
*usr
, SAM_ACCOUNT
*pw
, DOM_SID
*domain_sid
)
5923 NTTIME logon_time
, logoff_time
, kickoff_time
,
5924 pass_last_set_time
, pass_can_change_time
,
5925 pass_must_change_time
;
5927 const char* user_name
= pdb_get_username(pw
);
5928 const char* full_name
= pdb_get_fullname(pw
);
5929 const char* home_dir
= pdb_get_homedir(pw
);
5930 const char* dir_drive
= pdb_get_dir_drive(pw
);
5931 const char* logon_script
= pdb_get_logon_script(pw
);
5932 const char* profile_path
= pdb_get_profile_path(pw
);
5933 const char* description
= pdb_get_acct_desc(pw
);
5934 const char* workstations
= pdb_get_workstations(pw
);
5935 const char* munged_dial
= pdb_get_munged_dial(pw
);
5936 DATA_BLOB munged_dial_blob
;
5939 const DOM_SID
*user_sid
;
5942 const DOM_SID
*group_sid
;
5945 munged_dial_blob
= base64_decode_data_blob(munged_dial
);
5947 munged_dial_blob
= data_blob(NULL
, 0);
5950 /* Create NTTIME structs */
5951 unix_to_nt_time (&logon_time
, pdb_get_logon_time(pw
));
5952 unix_to_nt_time (&logoff_time
, pdb_get_logoff_time(pw
));
5953 unix_to_nt_time (&kickoff_time
, pdb_get_kickoff_time(pw
));
5954 unix_to_nt_time (&pass_last_set_time
, pdb_get_pass_last_set_time(pw
));
5955 unix_to_nt_time (&pass_can_change_time
, pdb_get_pass_can_change_time(pw
));
5956 unix_to_nt_time (&pass_must_change_time
,pdb_get_pass_must_change_time(pw
));
5958 /* structure assignment */
5959 usr
->logon_time
= logon_time
;
5960 usr
->logoff_time
= logoff_time
;
5961 usr
->kickoff_time
= kickoff_time
;
5962 usr
->pass_last_set_time
= pass_last_set_time
;
5963 usr
->pass_can_change_time
= pass_can_change_time
;
5964 usr
->pass_must_change_time
= pass_must_change_time
;
5966 ZERO_STRUCT(usr
->nt_pwd
);
5967 ZERO_STRUCT(usr
->lm_pwd
);
5969 user_sid
= pdb_get_user_sid(pw
);
5971 if (!sid_peek_check_rid(domain_sid
, user_sid
, &user_rid
)) {
5972 fstring user_sid_string
;
5973 fstring domain_sid_string
;
5974 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with "
5975 "the domain sid %s. Failing operation.\n",
5977 sid_to_string(user_sid_string
, user_sid
),
5978 sid_to_string(domain_sid_string
, domain_sid
)));
5979 data_blob_free(&munged_dial_blob
);
5980 return NT_STATUS_UNSUCCESSFUL
;
5983 group_sid
= pdb_get_group_sid(pw
);
5985 if (!sid_peek_check_rid(domain_sid
, group_sid
, &group_rid
)) {
5986 fstring group_sid_string
;
5987 fstring domain_sid_string
;
5988 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n"
5989 "which conflicts with the domain sid %s. Failing operation.\n",
5991 sid_to_string(group_sid_string
, group_sid
),
5992 sid_to_string(domain_sid_string
, domain_sid
)));
5993 data_blob_free(&munged_dial_blob
);
5994 return NT_STATUS_UNSUCCESSFUL
;
5997 usr
->user_rid
= user_rid
;
5998 usr
->group_rid
= group_rid
;
5999 usr
->acb_info
= pdb_get_acct_ctrl(pw
);
6002 Look at a user on a real NT4 PDC with usrmgr, press
6003 'ok'. Then you will see that fields_present is set to
6004 0x08f827fa. Look at the user immediately after that again,
6005 and you will see that 0x00fffff is returned. This solves
6006 the problem that you get access denied after having looked
6010 usr
->fields_present
= pdb_build_fields_present(pw
);
6012 usr
->logon_divs
= pdb_get_logon_divs(pw
);
6013 usr
->ptr_logon_hrs
= pdb_get_hours(pw
) ? 1 : 0;
6014 usr
->bad_password_count
= pdb_get_bad_password_count(pw
);
6015 usr
->logon_count
= pdb_get_logon_count(pw
);
6017 if (pdb_get_pass_must_change_time(pw
) == 0) {
6018 usr
->passmustchange
=PASS_MUST_CHANGE_AT_NEXT_LOGON
;
6020 usr
->passmustchange
=0;
6023 ZERO_STRUCT(usr
->padding1
);
6024 ZERO_STRUCT(usr
->padding2
);
6026 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_STR_TERMINATE
);
6027 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
6029 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_STR_TERMINATE
);
6030 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
6032 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_STR_TERMINATE
);
6033 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
6035 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_STR_TERMINATE
);
6036 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
6038 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_STR_TERMINATE
);
6039 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
6041 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_STR_TERMINATE
);
6042 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
6044 init_unistr2(&usr
->uni_acct_desc
, description
, UNI_STR_TERMINATE
);
6045 init_uni_hdr(&usr
->hdr_acct_desc
, &usr
->uni_acct_desc
);
6047 init_unistr2(&usr
->uni_workstations
, workstations
, UNI_STR_TERMINATE
);
6048 init_uni_hdr(&usr
->hdr_workstations
, &usr
->uni_workstations
);
6050 init_unistr2(&usr
->uni_unknown_str
, NULL
, UNI_STR_TERMINATE
);
6051 init_uni_hdr(&usr
->hdr_unknown_str
, &usr
->uni_unknown_str
);
6053 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &munged_dial_blob
);
6054 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6055 data_blob_free(&munged_dial_blob
);
6057 usr
->unknown_6
= pdb_get_unknown_6(pw
);
6060 if (pdb_get_hours(pw
)) {
6061 usr
->logon_hrs
.len
= pdb_get_hours_len(pw
);
6062 memcpy(&usr
->logon_hrs
.hours
, pdb_get_hours(pw
), MAX_HOURS_LEN
);
6064 memset(&usr
->logon_hrs
, 0xff, sizeof(usr
->logon_hrs
));
6066 return NT_STATUS_OK
;
6069 /*******************************************************************
6070 reads or writes a structure.
6071 ********************************************************************/
6073 static BOOL
sam_io_user_info21(const char *desc
, SAM_USER_INFO_21
* usr
,
6074 prs_struct
*ps
, int depth
)
6079 prs_debug(ps
, depth
, desc
, "sam_io_user_info21");
6085 if(!smb_io_time("logon_time ", &usr
->logon_time
, ps
, depth
))
6087 if(!smb_io_time("logoff_time ", &usr
->logoff_time
, ps
, depth
))
6089 if(!smb_io_time("pass_last_set_time ", &usr
->pass_last_set_time
, ps
,depth
))
6091 if(!smb_io_time("kickoff_time ", &usr
->kickoff_time
, ps
, depth
))
6093 if(!smb_io_time("pass_can_change_time ", &usr
->pass_can_change_time
, ps
,depth
))
6095 if(!smb_io_time("pass_must_change_time", &usr
->pass_must_change_time
, ps
, depth
))
6098 if(!smb_io_unihdr("hdr_user_name ", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
6100 if(!smb_io_unihdr("hdr_full_name ", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
6102 if(!smb_io_unihdr("hdr_home_dir ", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
6104 if(!smb_io_unihdr("hdr_dir_drive ", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive */
6106 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
6108 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
6110 if(!smb_io_unihdr("hdr_acct_desc ", &usr
->hdr_acct_desc
, ps
, depth
)) /* account desc */
6112 if(!smb_io_unihdr("hdr_workstations", &usr
->hdr_workstations
, ps
, depth
)) /* wkstas user can log on from */
6114 if(!smb_io_unihdr("hdr_unknown_str ", &usr
->hdr_unknown_str
, ps
, depth
)) /* unknown string */
6116 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6119 if(!prs_uint8s(False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
)))
6121 if(!prs_uint8s(False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
)))
6124 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User ID */
6126 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group ID */
6128 if(!prs_uint32("acb_info ", ps
, depth
, &usr
->acb_info
))
6131 if(!prs_uint32("fields_present ", ps
, depth
, &usr
->fields_present
))
6133 if(!prs_uint16("logon_divs ", ps
, depth
, &usr
->logon_divs
)) /* logon divisions per week */
6137 if(!prs_uint32("ptr_logon_hrs ", ps
, depth
, &usr
->ptr_logon_hrs
))
6140 if(!prs_uint16("bad_password_count ", ps
, depth
, &usr
->bad_password_count
))
6142 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
))
6145 if(!prs_uint8s(False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
)))
6147 if(!prs_uint8("passmustchange ", ps
, depth
, &usr
->passmustchange
))
6149 if(!prs_uint8("padding2 ", ps
, depth
, &usr
->padding2
))
6152 /* here begins pointed-to data */
6154 if(!smb_io_unistr2("uni_user_name ", &usr
->uni_user_name
,usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
6156 if(!smb_io_unistr2("uni_full_name ", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
6158 if(!smb_io_unistr2("uni_home_dir ", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
6160 if(!smb_io_unistr2("uni_dir_drive ", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
6162 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
6164 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
6166 if(!smb_io_unistr2("uni_acct_desc ", &usr
->uni_acct_desc
, usr
->hdr_acct_desc
.buffer
, ps
, depth
)) /* user desc unicode string */
6168 if(!smb_io_unistr2("uni_workstations", &usr
->uni_workstations
, usr
->hdr_workstations
.buffer
, ps
, depth
)) /* worksations user can log on from */
6170 if(!smb_io_unistr2("uni_unknown_str ", &usr
->uni_unknown_str
, usr
->hdr_unknown_str
.buffer
, ps
, depth
)) /* unknown string */
6172 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6175 /* ok, this is only guess-work (as usual) */
6176 if (usr
->ptr_logon_hrs
) {
6179 if(!prs_uint32("unknown_6 ", ps
, depth
, &usr
->unknown_6
))
6181 if(!prs_uint32("padding4 ", ps
, depth
, &usr
->padding4
))
6183 if(!sam_io_logon_hrs("logon_hrs", &usr
->logon_hrs
, ps
, depth
))
6185 } else if (UNMARSHALLING(ps
)) {
6193 void init_sam_user_info20A(SAM_USER_INFO_20
*usr
, SAM_ACCOUNT
*pw
)
6195 const char *munged_dial
= pdb_get_munged_dial(pw
);
6196 DATA_BLOB blob
= base64_decode_data_blob(munged_dial
);
6198 init_unistr2_from_datablob(&usr
->uni_munged_dial
, &blob
);
6199 init_uni_hdr(&usr
->hdr_munged_dial
, &usr
->uni_munged_dial
);
6200 data_blob_free(&blob
);
6203 /*******************************************************************
6204 reads or writes a structure.
6205 ********************************************************************/
6207 static BOOL
sam_io_user_info20(const char *desc
, SAM_USER_INFO_20
*usr
,
6208 prs_struct
*ps
, int depth
)
6213 prs_debug(ps
, depth
, desc
, "sam_io_user_info20");
6219 if(!smb_io_unihdr("hdr_munged_dial ", &usr
->hdr_munged_dial
, ps
, depth
)) /* wkstas user can log on from */
6222 if(!smb_io_unistr2("uni_munged_dial ", &usr
->uni_munged_dial
,usr
->hdr_munged_dial
.buffer
, ps
, depth
)) /* worksations user can log on from */
6228 /*******************************************************************
6229 inits a SAM_USERINFO_CTR structure.
6230 ********************************************************************/
6232 NTSTATUS
make_samr_userinfo_ctr_usr21(TALLOC_CTX
*ctx
, SAM_USERINFO_CTR
* ctr
,
6233 uint16 switch_value
,
6234 SAM_USER_INFO_21
* usr
)
6236 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6238 ctr
->switch_value
= switch_value
;
6239 ctr
->info
.id
= NULL
;
6241 switch (switch_value
) {
6243 ctr
->info
.id10
= (SAM_USER_INFO_10
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_10
));
6244 if (ctr
->info
.id10
== NULL
)
6245 return NT_STATUS_NO_MEMORY
;
6247 init_sam_user_info10(ctr
->info
.id10
, usr
->acb_info
);
6250 /* whoops - got this wrong. i think. or don't understand what's happening. */
6254 info
= (void *)&id11
;
6256 expire
.low
= 0xffffffff;
6257 expire
.high
= 0x7fffffff;
6259 ctr
->info
.id
= (SAM_USER_INFO_11
*) talloc_zero(ctx
,sizeof(*ctr
->info
.id11
));
6260 init_sam_user_info11(ctr
->info
.id11
, &expire
,
6261 "BROOKFIELDS$", /* name */
6262 0x03ef, /* user rid */
6263 0x201, /* group rid */
6264 0x0080); /* acb info */
6270 ctr
->info
.id12
= (SAM_USER_INFO_12
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_12
));
6271 if (ctr
->info
.id12
== NULL
)
6272 return NT_STATUS_NO_MEMORY
;
6274 init_sam_user_info12(ctr
->info
.id12
, usr
->lm_pwd
, usr
->nt_pwd
);
6278 SAM_USER_INFO_21
*cusr
;
6279 cusr
= (SAM_USER_INFO_21
*)talloc_zero(ctx
,sizeof(SAM_USER_INFO_21
));
6280 ctr
->info
.id21
= cusr
;
6281 if (ctr
->info
.id21
== NULL
)
6282 return NT_STATUS_NO_MEMORY
;
6283 memcpy(cusr
, usr
, sizeof(*usr
));
6284 memset(cusr
->lm_pwd
, 0, sizeof(cusr
->lm_pwd
));
6285 memset(cusr
->nt_pwd
, 0, sizeof(cusr
->nt_pwd
));
6289 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n"));
6290 return NT_STATUS_INVALID_INFO_CLASS
;
6293 return NT_STATUS_OK
;
6296 /*******************************************************************
6297 inits a SAM_USERINFO_CTR structure.
6298 ********************************************************************/
6300 static void init_samr_userinfo_ctr(SAM_USERINFO_CTR
* ctr
, DATA_BLOB
*sess_key
,
6301 uint16 switch_value
, void *info
)
6303 DEBUG(5, ("init_samr_userinfo_ctr\n"));
6305 ctr
->switch_value
= switch_value
;
6306 ctr
->info
.id
= info
;
6308 switch (switch_value
) {
6310 SamOEMhashBlob(ctr
->info
.id24
->pass
, 516, sess_key
);
6311 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6312 dump_data(100, (char *)ctr
->info
.id24
->pass
, 516);
6315 SamOEMhashBlob(ctr
->info
.id23
->pass
, 516, sess_key
);
6316 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6317 dump_data(100, (char *)ctr
->info
.id23
->pass
, 516);
6320 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n"));
6324 /*******************************************************************
6325 reads or writes a structure.
6326 ********************************************************************/
6328 static BOOL
samr_io_userinfo_ctr(const char *desc
, SAM_USERINFO_CTR
**ppctr
,
6329 prs_struct
*ps
, int depth
)
6332 SAM_USERINFO_CTR
*ctr
;
6334 prs_debug(ps
, depth
, desc
, "samr_io_userinfo_ctr");
6337 if (UNMARSHALLING(ps
)) {
6338 ctr
= (SAM_USERINFO_CTR
*)prs_alloc_mem(ps
,sizeof(SAM_USERINFO_CTR
));
6346 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */
6348 if(!prs_uint16("switch_value", ps
, depth
, &ctr
->switch_value
))
6355 switch (ctr
->switch_value
) {
6357 if (UNMARSHALLING(ps
))
6358 ctr
->info
.id10
= (SAM_USER_INFO_10
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_10
));
6359 if (ctr
->info
.id10
== NULL
) {
6360 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6363 ret
= sam_io_user_info10("", ctr
->info
.id10
, ps
, depth
);
6366 if (UNMARSHALLING(ps
))
6367 ctr
->info
.id11
= (SAM_USER_INFO_11
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_11
));
6369 if (ctr
->info
.id11
== NULL
) {
6370 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6373 ret
= sam_io_user_info11("", ctr
->info
.id11
, ps
, depth
);
6376 if (UNMARSHALLING(ps
))
6377 ctr
->info
.id12
= (SAM_USER_INFO_12
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_12
));
6379 if (ctr
->info
.id12
== NULL
) {
6380 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6383 ret
= sam_io_user_info12("", ctr
->info
.id12
, ps
, depth
);
6386 if (UNMARSHALLING(ps
))
6387 ctr
->info
.id20
= (SAM_USER_INFO_20
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_20
));
6389 if (ctr
->info
.id20
== NULL
) {
6390 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6393 ret
= sam_io_user_info20("", ctr
->info
.id20
, ps
, depth
);
6396 if (UNMARSHALLING(ps
))
6397 ctr
->info
.id21
= (SAM_USER_INFO_21
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_21
));
6399 if (ctr
->info
.id21
== NULL
) {
6400 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6403 ret
= sam_io_user_info21("", ctr
->info
.id21
, ps
, depth
);
6406 if (UNMARSHALLING(ps
))
6407 ctr
->info
.id23
= (SAM_USER_INFO_23
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_23
));
6409 if (ctr
->info
.id23
== NULL
) {
6410 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6413 ret
= sam_io_user_info23("", ctr
->info
.id23
, ps
, depth
);
6416 if (UNMARSHALLING(ps
))
6417 ctr
->info
.id24
= (SAM_USER_INFO_24
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_24
));
6419 if (ctr
->info
.id24
== NULL
) {
6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6423 ret
= sam_io_user_info24("", ctr
->info
.id24
, ps
, depth
);
6426 if (UNMARSHALLING(ps
))
6427 ctr
->info
.id25
= (SAM_USER_INFO_25
*)prs_alloc_mem(ps
,sizeof(SAM_USER_INFO_25
));
6429 if (ctr
->info
.id25
== NULL
) {
6430 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n"));
6433 ret
= sam_io_user_info25("", ctr
->info
.id25
, ps
, depth
);
6436 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr
->switch_value
));
6444 /*******************************************************************
6445 inits a SAMR_R_QUERY_USERINFO structure.
6446 ********************************************************************/
6448 void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
* r_u
,
6449 SAM_USERINFO_CTR
* ctr
, NTSTATUS status
)
6451 DEBUG(5, ("init_samr_r_query_userinfo\n"));
6456 if (NT_STATUS_IS_OK(status
)) {
6461 r_u
->status
= status
; /* return status */
6464 /*******************************************************************
6465 reads or writes a structure.
6466 ********************************************************************/
6468 BOOL
samr_io_r_query_userinfo(const char *desc
, SAMR_R_QUERY_USERINFO
* r_u
,
6469 prs_struct
*ps
, int depth
)
6474 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
6480 if(!prs_uint32("ptr", ps
, depth
, &r_u
->ptr
))
6483 if (r_u
->ptr
!= 0) {
6484 if(!samr_io_userinfo_ctr("ctr", &r_u
->ctr
, ps
, depth
))
6490 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6496 /*******************************************************************
6497 inits a SAMR_Q_SET_USERINFO structure.
6498 ********************************************************************/
6500 void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO
* q_u
,
6501 POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6502 uint16 switch_value
, void *info
)
6504 DEBUG(5, ("init_samr_q_set_userinfo\n"));
6507 q_u
->switch_value
= switch_value
;
6508 init_samr_userinfo_ctr(q_u
->ctr
, sess_key
, switch_value
, info
);
6511 /*******************************************************************
6512 reads or writes a structure.
6513 ********************************************************************/
6515 BOOL
samr_io_q_set_userinfo(const char *desc
, SAMR_Q_SET_USERINFO
* q_u
,
6516 prs_struct
*ps
, int depth
)
6521 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo");
6527 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
6529 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6531 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6537 /*******************************************************************
6538 inits a SAMR_R_SET_USERINFO structure.
6539 ********************************************************************/
6541 void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO
* r_u
, NTSTATUS status
)
6543 DEBUG(5, ("init_samr_r_set_userinfo\n"));
6545 r_u
->status
= status
; /* return status */
6548 /*******************************************************************
6549 reads or writes a structure.
6550 ********************************************************************/
6552 BOOL
samr_io_r_set_userinfo(const char *desc
, SAMR_R_SET_USERINFO
* r_u
,
6553 prs_struct
*ps
, int depth
)
6558 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo");
6564 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6570 /*******************************************************************
6571 inits a SAMR_Q_SET_USERINFO2 structure.
6572 ********************************************************************/
6574 void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2
* q_u
,
6575 POLICY_HND
*hnd
, DATA_BLOB
*sess_key
,
6576 uint16 switch_value
, SAM_USERINFO_CTR
* ctr
)
6578 DEBUG(5, ("init_samr_q_set_userinfo2\n"));
6581 q_u
->switch_value
= switch_value
;
6584 if (q_u
->ctr
!= NULL
)
6585 q_u
->ctr
->switch_value
= switch_value
;
6587 switch (switch_value
) {
6589 SamOEMhashBlob(ctr
->info
.id12
->lm_pwd
, 16, sess_key
);
6590 SamOEMhashBlob(ctr
->info
.id12
->nt_pwd
, 16, sess_key
);
6591 dump_data(100, (char *)sess_key
->data
, sess_key
->length
);
6592 dump_data(100, (char *)ctr
->info
.id12
->lm_pwd
, 16);
6593 dump_data(100, (char *)ctr
->info
.id12
->nt_pwd
, 16);
6598 /*******************************************************************
6599 reads or writes a structure.
6600 ********************************************************************/
6602 BOOL
samr_io_q_set_userinfo2(const char *desc
, SAMR_Q_SET_USERINFO2
* q_u
,
6603 prs_struct
*ps
, int depth
)
6608 prs_debug(ps
, depth
, desc
, "samr_io_q_set_userinfo2");
6614 if(!smb_io_pol_hnd("pol", &q_u
->pol
, ps
, depth
))
6617 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
6619 if(!samr_io_userinfo_ctr("ctr", &q_u
->ctr
, ps
, depth
))
6625 /*******************************************************************
6626 inits a SAMR_R_SET_USERINFO2 structure.
6627 ********************************************************************/
6629 void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2
* r_u
, NTSTATUS status
)
6631 DEBUG(5, ("init_samr_r_set_userinfo2\n"));
6633 r_u
->status
= status
; /* return status */
6636 /*******************************************************************
6637 reads or writes a structure.
6638 ********************************************************************/
6640 BOOL
samr_io_r_set_userinfo2(const char *desc
, SAMR_R_SET_USERINFO2
* r_u
,
6641 prs_struct
*ps
, int depth
)
6646 prs_debug(ps
, depth
, desc
, "samr_io_r_set_userinfo2");
6652 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6658 /*******************************************************************
6659 inits a SAMR_Q_CONNECT structure.
6660 ********************************************************************/
6662 void init_samr_q_connect(SAMR_Q_CONNECT
* q_u
,
6663 char *srv_name
, uint32 access_mask
)
6665 DEBUG(5, ("init_samr_q_connect\n"));
6667 /* make PDC server name \\server */
6668 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6669 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6671 /* example values: 0x0000 0002 */
6672 q_u
->access_mask
= access_mask
;
6675 /*******************************************************************
6676 reads or writes a structure.
6677 ********************************************************************/
6679 BOOL
samr_io_q_connect(const char *desc
, SAMR_Q_CONNECT
* q_u
,
6680 prs_struct
*ps
, int depth
)
6685 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
6691 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6693 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6698 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6704 /*******************************************************************
6705 reads or writes a structure.
6706 ********************************************************************/
6708 BOOL
samr_io_r_connect(const char *desc
, SAMR_R_CONNECT
* r_u
,
6709 prs_struct
*ps
, int depth
)
6714 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
6720 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6723 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6729 /*******************************************************************
6730 inits a SAMR_Q_CONNECT4 structure.
6731 ********************************************************************/
6733 void init_samr_q_connect4(SAMR_Q_CONNECT4
* q_u
,
6734 char *srv_name
, uint32 access_mask
)
6736 DEBUG(5, ("init_samr_q_connect\n"));
6738 /* make PDC server name \\server */
6739 q_u
->ptr_srv_name
= (srv_name
!= NULL
&& *srv_name
) ? 1 : 0;
6740 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
6742 /* Only value we've seen, possibly an address type ? */
6745 /* example values: 0x0000 0002 */
6746 q_u
->access_mask
= access_mask
;
6749 /*******************************************************************
6750 reads or writes a structure.
6751 ********************************************************************/
6753 BOOL
samr_io_q_connect4(const char *desc
, SAMR_Q_CONNECT4
* q_u
,
6754 prs_struct
*ps
, int depth
)
6759 prs_debug(ps
, depth
, desc
, "samr_io_q_connect4");
6765 if(!prs_uint32("ptr_srv_name", ps
, depth
, &q_u
->ptr_srv_name
))
6767 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->ptr_srv_name
, ps
, depth
))
6772 if(!prs_uint32("unk_0", ps
, depth
, &q_u
->unk_0
))
6774 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6780 /*******************************************************************
6781 reads or writes a structure.
6782 ********************************************************************/
6784 BOOL
samr_io_r_connect4(const char *desc
, SAMR_R_CONNECT4
* r_u
,
6785 prs_struct
*ps
, int depth
)
6790 prs_debug(ps
, depth
, desc
, "samr_io_r_connect4");
6796 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6799 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6805 /*******************************************************************
6806 inits a SAMR_Q_CONNECT_ANON structure.
6807 ********************************************************************/
6809 void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON
* q_u
)
6811 DEBUG(5, ("init_samr_q_connect_anon\n"));
6814 q_u
->unknown_0
= 0x5c; /* server name (?!!) */
6815 q_u
->unknown_1
= 0x01;
6816 q_u
->access_mask
= 0x20;
6819 /*******************************************************************
6820 reads or writes a structure.
6821 ********************************************************************/
6823 BOOL
samr_io_q_connect_anon(const char *desc
, SAMR_Q_CONNECT_ANON
* q_u
,
6824 prs_struct
*ps
, int depth
)
6829 prs_debug(ps
, depth
, desc
, "samr_io_q_connect_anon");
6835 if(!prs_uint32("ptr ", ps
, depth
, &q_u
->ptr
))
6837 if(!prs_uint16("unknown_0", ps
, depth
, &q_u
->unknown_0
))
6839 if(!prs_uint16("unknown_1", ps
, depth
, &q_u
->unknown_1
))
6841 if(!prs_uint32("access_mask", ps
, depth
, &q_u
->access_mask
))
6847 /*******************************************************************
6848 reads or writes a structure.
6849 ********************************************************************/
6851 BOOL
samr_io_r_connect_anon(const char *desc
, SAMR_R_CONNECT_ANON
* r_u
,
6852 prs_struct
*ps
, int depth
)
6857 prs_debug(ps
, depth
, desc
, "samr_io_r_connect_anon");
6863 if(!smb_io_pol_hnd("connect_pol", &r_u
->connect_pol
, ps
, depth
))
6866 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6872 /*******************************************************************
6873 inits a SAMR_Q_GET_DOM_PWINFO structure.
6874 ********************************************************************/
6876 void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO
* q_u
,
6879 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
6882 init_unistr2(&q_u
->uni_srv_name
, srv_name
, UNI_FLAGS_NONE
);
6883 init_uni_hdr(&q_u
->hdr_srv_name
, &q_u
->uni_srv_name
);
6886 /*******************************************************************
6887 reads or writes a structure.
6888 ********************************************************************/
6890 BOOL
samr_io_q_get_dom_pwinfo(const char *desc
, SAMR_Q_GET_DOM_PWINFO
* q_u
,
6891 prs_struct
*ps
, int depth
)
6896 prs_debug(ps
, depth
, desc
, "samr_io_q_get_dom_pwinfo");
6902 if(!prs_uint32("ptr", ps
, depth
, &q_u
->ptr
))
6904 if (q_u
->ptr
!= 0) {
6905 if(!smb_io_unihdr("", &q_u
->hdr_srv_name
, ps
, depth
))
6907 if(!smb_io_unistr2("", &q_u
->uni_srv_name
, q_u
->hdr_srv_name
.buffer
, ps
, depth
))
6914 /*******************************************************************
6915 reads or writes a structure.
6916 ********************************************************************/
6918 BOOL
samr_io_r_get_dom_pwinfo(const char *desc
, SAMR_R_GET_DOM_PWINFO
* r_u
,
6919 prs_struct
*ps
, int depth
)
6924 prs_debug(ps
, depth
, desc
, "samr_io_r_get_dom_pwinfo");
6931 * We need 16 bytes here according to tests. Don't know
6932 * what they are, but the length is important for the singing
6935 if(!prs_uint32("unk_0", ps
, depth
, &r_u
->unk_0
))
6937 if(!prs_uint32("unk_1", ps
, depth
, &r_u
->unk_1
))
6939 if(!prs_uint32("unk_2", ps
, depth
, &r_u
->unk_2
))
6942 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
6948 /*******************************************************************
6949 make a SAMR_ENC_PASSWD structure.
6950 ********************************************************************/
6952 void init_enc_passwd(SAMR_ENC_PASSWD
* pwd
, const char pass
[512])
6960 memcpy(pwd
->pass
, pass
, sizeof(pwd
->pass
));
6964 /*******************************************************************
6965 reads or writes a SAMR_ENC_PASSWD structure.
6966 ********************************************************************/
6968 BOOL
samr_io_enc_passwd(const char *desc
, SAMR_ENC_PASSWD
* pwd
,
6969 prs_struct
*ps
, int depth
)
6974 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
6980 if(!prs_uint32("ptr", ps
, depth
, &pwd
->ptr
))
6983 if (pwd
->ptr
!= 0) {
6984 if(!prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
)))
6991 /*******************************************************************
6992 inits a SAMR_ENC_HASH structure.
6993 ********************************************************************/
6995 void init_enc_hash(SAMR_ENC_HASH
* hsh
, const uchar hash
[16])
7003 memcpy(hsh
->hash
, hash
, sizeof(hsh
->hash
));
7007 /*******************************************************************
7008 reads or writes a SAMR_ENC_HASH structure.
7009 ********************************************************************/
7011 BOOL
samr_io_enc_hash(const char *desc
, SAMR_ENC_HASH
* hsh
,
7012 prs_struct
*ps
, int depth
)
7017 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
7023 if(!prs_uint32("ptr ", ps
, depth
, &hsh
->ptr
))
7025 if (hsh
->ptr
!= 0) {
7026 if(!prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
,sizeof(hsh
->hash
)))
7033 /*******************************************************************
7034 inits a SAMR_R_GET_DOM_PWINFO structure.
7035 ********************************************************************/
7037 void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER
* q_u
,
7038 const char *dest_host
, const char *user_name
,
7039 const char nt_newpass
[516],
7040 const uchar nt_oldhash
[16],
7041 const char lm_newpass
[516],
7042 const uchar lm_oldhash
[16])
7044 DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
7047 init_unistr2(&q_u
->uni_dest_host
, dest_host
, UNI_FLAGS_NONE
);
7048 init_uni_hdr(&q_u
->hdr_dest_host
, &q_u
->uni_dest_host
);
7050 init_unistr2(&q_u
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
7051 init_uni_hdr(&q_u
->hdr_user_name
, &q_u
->uni_user_name
);
7053 init_enc_passwd(&q_u
->nt_newpass
, nt_newpass
);
7054 init_enc_hash(&q_u
->nt_oldhash
, nt_oldhash
);
7056 q_u
->unknown
= 0x01;
7058 init_enc_passwd(&q_u
->lm_newpass
, lm_newpass
);
7059 init_enc_hash(&q_u
->lm_oldhash
, lm_oldhash
);
7062 /*******************************************************************
7063 reads or writes a structure.
7064 ********************************************************************/
7066 BOOL
samr_io_q_chgpasswd_user(const char *desc
, SAMR_Q_CHGPASSWD_USER
* q_u
,
7067 prs_struct
*ps
, int depth
)
7072 prs_debug(ps
, depth
, desc
, "samr_io_q_chgpasswd_user");
7078 if(!prs_uint32("ptr_0", ps
, depth
, &q_u
->ptr_0
))
7081 if(!smb_io_unihdr("", &q_u
->hdr_dest_host
, ps
, depth
))
7083 if(!smb_io_unistr2("", &q_u
->uni_dest_host
, q_u
->hdr_dest_host
.buffer
, ps
, depth
))
7088 if(!smb_io_unihdr("", &q_u
->hdr_user_name
, ps
, depth
))
7090 if(!smb_io_unistr2("", &q_u
->uni_user_name
, q_u
->hdr_user_name
.buffer
,ps
, depth
))
7093 if(!samr_io_enc_passwd("nt_newpass", &q_u
->nt_newpass
, ps
, depth
))
7095 if(!samr_io_enc_hash("nt_oldhash", &q_u
->nt_oldhash
, ps
, depth
))
7098 if(!prs_uint32("unknown", ps
, depth
, &q_u
->unknown
))
7101 if(!samr_io_enc_passwd("lm_newpass", &q_u
->lm_newpass
, ps
, depth
))
7103 if(!samr_io_enc_hash("lm_oldhash", &q_u
->lm_oldhash
, ps
, depth
))
7109 /*******************************************************************
7110 inits a SAMR_R_CHGPASSWD_USER structure.
7111 ********************************************************************/
7113 void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER
* r_u
, NTSTATUS status
)
7115 DEBUG(5, ("init_r_chgpasswd_user\n"));
7117 r_u
->status
= status
;
7120 /*******************************************************************
7121 reads or writes a structure.
7122 ********************************************************************/
7124 BOOL
samr_io_r_chgpasswd_user(const char *desc
, SAMR_R_CHGPASSWD_USER
* r_u
,
7125 prs_struct
*ps
, int depth
)
7130 prs_debug(ps
, depth
, desc
, "samr_io_r_chgpasswd_user");
7136 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7142 /*******************************************************************
7143 reads or writes a structure.
7144 ********************************************************************/
7146 void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E
*q_u
,
7147 POLICY_HND
*domain_pol
, uint16 switch_value
)
7149 DEBUG(5, ("init_samr_q_unknown_2e\n"));
7151 q_u
->domain_pol
= *domain_pol
;
7152 q_u
->switch_value
= switch_value
;
7155 /*******************************************************************
7156 reads or writes a structure.
7157 ********************************************************************/
7159 BOOL
samr_io_q_unknown_2e(const char *desc
, SAMR_Q_UNKNOWN_2E
*q_u
,
7160 prs_struct
*ps
, int depth
)
7165 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_2e");
7171 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7174 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7180 /*******************************************************************
7181 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7182 ********************************************************************/
7184 void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E
* r_u
,
7185 uint16 switch_value
, SAM_UNK_CTR
* ctr
,
7188 DEBUG(5, ("init_samr_r_samr_unknown_2e\n"));
7191 r_u
->switch_value
= 0;
7192 r_u
->status
= status
; /* return status */
7194 if (NT_STATUS_IS_OK(status
)) {
7195 r_u
->switch_value
= switch_value
;
7201 /*******************************************************************
7202 reads or writes a structure.
7203 ********************************************************************/
7205 BOOL
samr_io_r_samr_unknown_2e(const char *desc
, SAMR_R_UNKNOWN_2E
* r_u
,
7206 prs_struct
*ps
, int depth
)
7211 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7217 if(!prs_uint32("ptr_0 ", ps
, depth
, &r_u
->ptr_0
))
7220 if (r_u
->ptr_0
!= 0 && r_u
->ctr
!= NULL
) {
7221 if(!prs_uint16("switch_value", ps
, depth
, &r_u
->switch_value
))
7226 switch (r_u
->switch_value
) {
7228 if(!sam_io_unk_info12("unk_inf12", &r_u
->ctr
->info
.inf12
, ps
, depth
))
7232 if(!sam_io_unk_info7("unk_inf7",&r_u
->ctr
->info
.inf7
, ps
,depth
))
7236 if(!sam_io_unk_info6("unk_inf6",&r_u
->ctr
->info
.inf6
, ps
,depth
))
7240 if(!sam_io_unk_info5("unk_inf5",&r_u
->ctr
->info
.inf5
, ps
,depth
))
7244 if(!sam_io_unk_info3("unk_inf3",&r_u
->ctr
->info
.inf3
, ps
,depth
))
7248 if(!sam_io_unk_info2("unk_inf2",&r_u
->ctr
->info
.inf2
, ps
,depth
))
7252 if(!sam_io_unk_info1("unk_inf1",&r_u
->ctr
->info
.inf1
, ps
,depth
))
7256 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7257 r_u
->switch_value
));
7258 r_u
->status
= NT_STATUS_INVALID_INFO_CLASS
;
7266 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))
7273 /*******************************************************************
7274 reads or writes a structure.
7275 ********************************************************************/
7277 void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7278 POLICY_HND
*domain_pol
, uint16 switch_value
, SAM_UNK_CTR
*ctr
)
7280 DEBUG(5, ("init_samr_q_set_domain_info\n"));
7282 q_u
->domain_pol
= *domain_pol
;
7283 q_u
->switch_value0
= switch_value
;
7285 q_u
->switch_value
= switch_value
;
7290 /*******************************************************************
7291 reads or writes a structure.
7292 ********************************************************************/
7294 BOOL
samr_io_q_set_domain_info(const char *desc
, SAMR_Q_SET_DOMAIN_INFO
*q_u
,
7295 prs_struct
*ps
, int depth
)
7300 prs_debug(ps
, depth
, desc
, "samr_io_q_set_domain_info");
7306 if(!smb_io_pol_hnd("domain_pol", &q_u
->domain_pol
, ps
, depth
))
7309 if(!prs_uint16("switch_value0", ps
, depth
, &q_u
->switch_value0
))
7312 if(!prs_uint16("switch_value", ps
, depth
, &q_u
->switch_value
))
7318 if ((q_u
->ctr
= (SAM_UNK_CTR
*)prs_alloc_mem(ps
, sizeof(SAM_UNK_CTR
))) == NULL
)
7321 switch (q_u
->switch_value
) {
7324 if(!sam_io_unk_info12("unk_inf12", &q_u
->ctr
->info
.inf12
, ps
, depth
))
7328 if(!sam_io_unk_info7("unk_inf7",&q_u
->ctr
->info
.inf7
, ps
,depth
))
7332 if(!sam_io_unk_info6("unk_inf6",&q_u
->ctr
->info
.inf6
, ps
,depth
))
7336 if(!sam_io_unk_info5("unk_inf5",&q_u
->ctr
->info
.inf5
, ps
,depth
))
7340 if(!sam_io_unk_info3("unk_inf3",&q_u
->ctr
->info
.inf3
, ps
,depth
))
7344 if(!sam_io_unk_info2("unk_inf2",&q_u
->ctr
->info
.inf2
, ps
,depth
))
7348 if(!sam_io_unk_info1("unk_inf1",&q_u
->ctr
->info
.inf1
, ps
,depth
))
7352 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n",
7353 q_u
->switch_value
));
7360 /*******************************************************************
7361 inits a SAMR_R_QUERY_DOMAIN_INFO structure.
7362 ********************************************************************/
7364 void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO
* r_u
, NTSTATUS status
)
7366 DEBUG(5, ("init_samr_r_set_domain_info\n"));
7368 r_u
->status
= status
; /* return status */
7371 /*******************************************************************
7372 reads or writes a structure.
7373 ********************************************************************/
7375 BOOL
samr_io_r_set_domain_info(const char *desc
, SAMR_R_SET_DOMAIN_INFO
* r_u
,
7376 prs_struct
*ps
, int depth
)
7381 prs_debug(ps
, depth
, desc
, "samr_io_r_samr_unknown_2e");
7387 if(!prs_ntstatus("status", ps
, depth
, &r_u
->status
))