2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL
;
30 /*******************************************************************
31 makes a SAMR_Q_CLOSE_HND structure.
32 ********************************************************************/
33 void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND
*q_c
, POLICY_HND
*hnd
)
35 if (q_c
== NULL
|| hnd
== NULL
) return;
37 DEBUG(5,("make_samr_q_close_hnd\n"));
39 memcpy(&(q_c
->pol
), hnd
, sizeof(q_c
->pol
));
42 /*******************************************************************
43 reads or writes a structure.
44 ********************************************************************/
45 void samr_io_q_close_hnd(char *desc
, SAMR_Q_CLOSE_HND
*q_u
, prs_struct
*ps
, int depth
)
47 if (q_u
== NULL
) return;
49 prs_debug(ps
, depth
, desc
, "samr_io_q_close_hnd");
54 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
58 /*******************************************************************
59 reads or writes a structure.
60 ********************************************************************/
61 void samr_io_r_close_hnd(char *desc
, SAMR_R_CLOSE_HND
*r_u
, prs_struct
*ps
, int depth
)
63 if (r_u
== NULL
) return;
65 prs_debug(ps
, depth
, desc
, "samr_io_r_close_hnd");
70 smb_io_pol_hnd("pol", &(r_u
->pol
), ps
, depth
);
73 prs_uint32("status", ps
, depth
, &(r_u
->status
));
77 /*******************************************************************
78 reads or writes a structure.
79 ********************************************************************/
80 void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN
*q_u
,
81 POLICY_HND
*connect_pol
, uint32 rid
,
84 if (q_u
== NULL
) return;
86 DEBUG(5,("samr_make_q_open_domain\n"));
88 memcpy(&q_u
->connect_pol
, connect_pol
, sizeof(q_u
->connect_pol
));
90 make_dom_sid2(&(q_u
->dom_sid
), sid
);
93 /*******************************************************************
94 reads or writes a structure.
95 ********************************************************************/
96 void samr_io_q_open_domain(char *desc
, SAMR_Q_OPEN_DOMAIN
*q_u
, prs_struct
*ps
, int depth
)
98 if (q_u
== NULL
) return;
100 prs_debug(ps
, depth
, desc
, "samr_io_q_open_domain");
105 smb_io_pol_hnd("connect_pol", &(q_u
->connect_pol
), ps
, depth
);
108 prs_uint32("rid", ps
, depth
, &(q_u
->rid
));
110 smb_io_dom_sid2("sid", &(q_u
->dom_sid
), ps
, depth
);
115 /*******************************************************************
116 reads or writes a structure.
117 ********************************************************************/
118 void samr_io_r_open_domain(char *desc
, SAMR_R_OPEN_DOMAIN
*r_u
, prs_struct
*ps
, int depth
)
120 if (r_u
== NULL
) return;
122 prs_debug(ps
, depth
, desc
, "samr_io_r_open_domain");
127 smb_io_pol_hnd("domain_pol", &(r_u
->domain_pol
), ps
, depth
);
130 prs_uint32("status", ps
, depth
, &(r_u
->status
));
133 /*******************************************************************
134 reads or writes a structure.
135 ********************************************************************/
136 void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3
*q_u
,
137 POLICY_HND
*user_pol
, uint16 switch_value
)
139 if (q_u
== NULL
) return;
141 DEBUG(5,("samr_make_q_unknown_3\n"));
143 memcpy(&q_u
->user_pol
, user_pol
, sizeof(q_u
->user_pol
));
144 q_u
->switch_value
= switch_value
;
148 /*******************************************************************
149 reads or writes a structure.
150 ********************************************************************/
151 void samr_io_q_unknown_3(char *desc
, SAMR_Q_UNKNOWN_3
*q_u
, prs_struct
*ps
, int depth
)
153 if (q_u
== NULL
) return;
155 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_3");
160 smb_io_pol_hnd("user_pol", &(q_u
->user_pol
), ps
, depth
);
163 prs_uint16("switch_value", ps
, depth
, &(q_u
->switch_value
));
167 /*******************************************************************
168 reads or writes a structure.
169 ********************************************************************/
170 void make_samr_q_unknown_8(SAMR_Q_UNKNOWN_8
*q_u
,
171 POLICY_HND
*domain_pol
, uint16 switch_value
)
173 if (q_u
== NULL
) return;
175 DEBUG(5,("samr_make_q_unknown_8\n"));
177 memcpy(&q_u
->domain_pol
, domain_pol
, sizeof(q_u
->domain_pol
));
178 q_u
->switch_value
= switch_value
;
181 /*******************************************************************
182 reads or writes a structure.
183 ********************************************************************/
184 void samr_io_q_unknown_8(char *desc
, SAMR_Q_UNKNOWN_8
*q_u
, prs_struct
*ps
, int depth
)
186 if (q_u
== NULL
) return;
188 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_8");
193 smb_io_pol_hnd("domain_pol", &(q_u
->domain_pol
), ps
, depth
);
196 prs_uint16("switch_value", ps
, depth
, &(q_u
->switch_value
));
199 /*******************************************************************
200 makes a DOM_SID3 structure.
202 calculate length by adding up the size of the components.
203 ********************************************************************/
204 void make_dom_sid3(DOM_SID3
*sid3
, uint16 unk_0
, uint16 unk_1
, DOM_SID
*sid
)
206 if (sid3
== NULL
) return;
209 sid3
->len
= 2 + 8 + sid3
->sid
.num_auths
* 4;
212 /*******************************************************************
213 reads or writes a SAM_SID3 structure.
215 this one's odd, because the length (in bytes) is specified at the beginning.
216 the length _includes_ the length of the length, too :-)
218 ********************************************************************/
219 static void sam_io_dom_sid3(char *desc
, DOM_SID3
*sid3
, prs_struct
*ps
, int depth
)
221 if (sid3
== NULL
) return;
223 prs_debug(ps
, depth
, desc
, "sam_io_dom_sid3");
226 prs_uint16("len", ps
, depth
, &(sid3
->len
));
228 smb_io_dom_sid("", &(sid3
->sid
), ps
, depth
);
231 /*******************************************************************
232 makes a SAMR_R_UNKNOWN3 structure.
237 unknown_4,5 : 0x0000 0014
240 unknown_7 : 0x5800 or 0x0070
242 ********************************************************************/
243 static void make_sam_sid_stuff(SAM_SID_STUFF
*stf
,
244 uint16 unknown_2
, uint16 unknown_3
,
245 uint32 unknown_4
, uint16 unknown_6
, uint16 unknown_7
,
246 int num_sid3s
, DOM_SID3 sid3
[MAX_SAM_SIDS
])
248 stf
->unknown_2
= unknown_2
;
249 stf
->unknown_3
= unknown_3
;
251 bzero(stf
->padding1
, sizeof(stf
->padding1
));
253 stf
->unknown_4
= unknown_4
;
254 stf
->unknown_5
= unknown_4
;
256 stf
->unknown_6
= unknown_6
;
257 stf
->unknown_7
= unknown_7
;
259 stf
->num_sids
= num_sid3s
;
261 stf
->padding2
= 0x0000;
263 memcpy(stf
->sid
, sid3
, sizeof(DOM_SID3
) * num_sid3s
);
266 /*******************************************************************
267 reads or writes a SAM_SID_STUFF structure.
268 ********************************************************************/
269 static void sam_io_sid_stuff(char *desc
, SAM_SID_STUFF
*stf
, prs_struct
*ps
, int depth
)
273 if (stf
== NULL
) return;
275 DEBUG(5,("make_sam_sid_stuff\n"));
277 prs_uint16("unknown_2", ps
, depth
, &(stf
->unknown_2
));
278 prs_uint16("unknown_3", ps
, depth
, &(stf
->unknown_3
));
280 prs_uint8s(False
, "padding1", ps
, depth
, stf
->padding1
, sizeof(stf
->padding1
));
282 prs_uint32("unknown_4", ps
, depth
, &(stf
->unknown_4
));
283 prs_uint32("unknown_5", ps
, depth
, &(stf
->unknown_5
));
284 prs_uint16("unknown_6", ps
, depth
, &(stf
->unknown_6
));
285 prs_uint16("unknown_7", ps
, depth
, &(stf
->unknown_7
));
287 prs_uint32("num_sids ", ps
, depth
, &(stf
->num_sids
));
288 prs_uint16("padding2 ", ps
, depth
, &(stf
->padding2
));
290 SMB_ASSERT_ARRAY(stf
->sid
, stf
->num_sids
);
292 for (i
= 0; i
< stf
->num_sids
; i
++)
294 sam_io_dom_sid3("", &(stf
->sid
[i
]), ps
, depth
);
298 /*******************************************************************
299 reads or writes a SAMR_R_UNKNOWN3 structure.
300 ********************************************************************/
301 void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3
*r_u
,
302 uint16 unknown_2
, uint16 unknown_3
,
303 uint32 unknown_4
, uint16 unknown_6
, uint16 unknown_7
,
304 int num_sid3s
, DOM_SID3 sid3
[MAX_SAM_SIDS
],
307 if (r_u
== NULL
) return;
309 DEBUG(5,("samr_make_r_unknown_3\n"));
318 make_sam_sid_stuff(&(r_u
->sid_stuff
), unknown_2
, unknown_3
,
319 unknown_4
, unknown_6
, unknown_7
,
323 r_u
->status
= status
;
327 /*******************************************************************
328 reads or writes a SAMR_R_UNKNOWN_3 structure.
330 this one's odd, because the daft buggers use a different mechanism
331 for writing out the array of sids. they put the number of sids in
332 only one place: they've calculated the length of each sid and jumped
333 by that amount. then, retrospectively, the length of the whole buffer
334 is put at the beginning of the data stream.
338 ********************************************************************/
339 void samr_io_r_unknown_3(char *desc
, SAMR_R_UNKNOWN_3
*r_u
, prs_struct
*ps
, int depth
)
343 int ptr_sid_stuff
= 0;
345 if (r_u
== NULL
) return;
347 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_3");
352 prs_uint32("ptr_0 ", ps
, depth
, &(r_u
->ptr_0
));
356 /* reading. do the length later */
357 prs_uint32("sid_stuff_len0", ps
, depth
, &(r_u
->sid_stuff_len0
));
362 ptr_len0
= ps
->offset
; ps
->offset
+= 4;
367 prs_uint32("ptr_1 ", ps
, depth
, &(r_u
->ptr_1
));
370 /* reading. do the length later */
371 prs_uint32("sid_stuff_len1", ps
, depth
, &(r_u
->sid_stuff_len1
));
376 ptr_len1
= ps
->offset
; ps
->offset
+= 4;
381 ptr_sid_stuff
= ps
->offset
;
382 sam_io_sid_stuff("", &(r_u
->sid_stuff
), ps
, depth
);
386 if (!(ps
->io
)) /* storing not reading. do the length, now. */
388 if (ptr_sid_stuff
!= 0)
390 uint32 sid_stuff_len
= ps
->offset
- ptr_sid_stuff
;
391 int old_len
= ps
->offset
;
393 ps
->offset
= ptr_len0
;
394 prs_uint32("sid_stuff_len0", ps
, depth
, &sid_stuff_len
);
396 ps
->offset
= ptr_len1
;
397 prs_uint32("sid_stuff_len1", ps
, depth
, &sid_stuff_len
);
399 ps
->offset
= old_len
;
403 prs_uint32("status", ps
, depth
, &(r_u
->status
));
406 /*******************************************************************
407 reads or writes a SAM_STR1 structure.
408 ********************************************************************/
409 static void sam_io_sam_str1(char *desc
, SAM_STR1
*sam
, uint32 acct_buf
, uint32 name_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
411 if (sam
== NULL
) return;
413 prs_debug(ps
, depth
, desc
, "sam_io_sam_str1");
418 smb_io_unistr2("unistr2", &(sam
->uni_acct_name
), acct_buf
, ps
, depth
); /* account name unicode string */
419 smb_io_unistr2("unistr2", &(sam
->uni_full_name
), name_buf
, ps
, depth
); /* full name unicode string */
420 smb_io_unistr2("unistr2", &(sam
->uni_acct_desc
), desc_buf
, ps
, depth
); /* account description unicode string */
423 /*******************************************************************
424 makes a SAM_ENTRY1 structure.
425 ********************************************************************/
426 static void make_sam_entry1(SAM_ENTRY1
*sam
, uint32 user_idx
,
427 uint32 len_sam_name
, uint32 len_sam_full
, uint32 len_sam_desc
,
428 uint32 rid_user
, uint16 acb_info
)
430 if (sam
== NULL
) return;
432 DEBUG(5,("make_sam_entry1\n"));
434 sam
->user_idx
= user_idx
;
435 sam
->rid_user
= rid_user
;
436 sam
->acb_info
= acb_info
;
439 make_uni_hdr(&(sam
->hdr_acct_name
), len_sam_name
, len_sam_name
, len_sam_name
!= 0);
440 make_uni_hdr(&(sam
->hdr_user_name
), len_sam_full
, len_sam_full
, len_sam_full
!= 0);
441 make_uni_hdr(&(sam
->hdr_user_desc
), len_sam_desc
, len_sam_desc
, len_sam_desc
!= 0);
444 /*******************************************************************
445 reads or writes a SAM_ENTRY1 structure.
446 ********************************************************************/
447 static void sam_io_sam_entry1(char *desc
, SAM_ENTRY1
*sam
, prs_struct
*ps
, int depth
)
449 if (sam
== NULL
) return;
451 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry1");
456 prs_uint32("user_idx ", ps
, depth
, &(sam
->user_idx
));
458 prs_uint32("rid_user ", ps
, depth
, &(sam
->rid_user
));
459 prs_uint16("acb_info ", ps
, depth
, &(sam
->acb_info
));
460 prs_uint16("pad ", ps
, depth
, &(sam
->pad
));
462 smb_io_unihdr("unihdr", &(sam
->hdr_acct_name
), ps
, depth
); /* account name unicode string header */
463 smb_io_unihdr("unihdr", &(sam
->hdr_user_name
), ps
, depth
); /* account name unicode string header */
464 smb_io_unihdr("unihdr", &(sam
->hdr_user_desc
), ps
, depth
); /* account name unicode string header */
467 /*******************************************************************
468 reads or writes a SAM_STR2 structure.
469 ********************************************************************/
470 static void sam_io_sam_str2(char *desc
, SAM_STR2
*sam
, uint32 acct_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
472 if (sam
== NULL
) return;
474 prs_debug(ps
, depth
, desc
, "sam_io_sam_str2");
479 smb_io_unistr2("unistr2", &(sam
->uni_srv_name
), acct_buf
, ps
, depth
); /* account name unicode string */
480 smb_io_unistr2("unistr2", &(sam
->uni_srv_desc
), desc_buf
, ps
, depth
); /* account description unicode string */
483 /*******************************************************************
484 makes a SAM_ENTRY2 structure.
485 ********************************************************************/
486 static void make_sam_entry2(SAM_ENTRY2
*sam
, uint32 user_idx
,
487 uint32 len_sam_name
, uint32 len_sam_desc
,
488 uint32 rid_user
, uint16 acb_info
)
490 if (sam
== NULL
) return;
492 DEBUG(5,("make_sam_entry2\n"));
494 sam
->user_idx
= user_idx
;
495 sam
->rid_user
= rid_user
;
496 sam
->acb_info
= acb_info
;
499 make_uni_hdr(&(sam
->hdr_srv_name
), len_sam_name
, len_sam_name
, len_sam_name
!= 0);
500 make_uni_hdr(&(sam
->hdr_srv_desc
), len_sam_desc
, len_sam_desc
, len_sam_desc
!= 0);
503 /*******************************************************************
504 reads or writes a SAM_ENTRY2 structure.
505 ********************************************************************/
506 static void sam_io_sam_entry2(char *desc
, SAM_ENTRY2
*sam
, prs_struct
*ps
, int depth
)
508 if (sam
== NULL
) return;
510 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry2");
515 prs_uint32("user_idx ", ps
, depth
, &(sam
->user_idx
));
517 prs_uint32("rid_user ", ps
, depth
, &(sam
->rid_user
));
518 prs_uint16("acb_info ", ps
, depth
, &(sam
->acb_info
));
519 prs_uint16("pad ", ps
, depth
, &(sam
->pad
));
521 smb_io_unihdr("unihdr", &(sam
->hdr_srv_name
), ps
, depth
); /* account name unicode string header */
522 smb_io_unihdr("unihdr", &(sam
->hdr_srv_desc
), ps
, depth
); /* account name unicode string header */
525 /*******************************************************************
526 reads or writes a SAM_STR3 structure.
527 ********************************************************************/
528 static void sam_io_sam_str3(char *desc
, SAM_STR3
*sam
, uint32 acct_buf
, uint32 desc_buf
, prs_struct
*ps
, int depth
)
530 if (sam
== NULL
) return;
532 prs_debug(ps
, depth
, desc
, "sam_io_sam_str3");
537 smb_io_unistr2("unistr2", &(sam
->uni_grp_name
), acct_buf
, ps
, depth
); /* account name unicode string */
538 smb_io_unistr2("unistr2", &(sam
->uni_grp_desc
), desc_buf
, ps
, depth
); /* account description unicode string */
541 /*******************************************************************
542 makes a SAM_ENTRY3 structure.
543 ********************************************************************/
544 static void make_sam_entry3(SAM_ENTRY3
*sam
, uint32 grp_idx
,
545 uint32 len_grp_name
, uint32 len_grp_desc
, uint32 rid_grp
)
547 if (sam
== NULL
) return;
549 DEBUG(5,("make_sam_entry3\n"));
551 sam
->grp_idx
= grp_idx
;
552 sam
->rid_grp
= rid_grp
;
553 sam
->attr
= 0x07; /* group rid attributes - gets ignored by nt 4.0 */
555 make_uni_hdr(&(sam
->hdr_grp_name
), len_grp_name
, len_grp_name
, len_grp_name
!= 0);
556 make_uni_hdr(&(sam
->hdr_grp_desc
), len_grp_desc
, len_grp_desc
, len_grp_desc
!= 0);
559 /*******************************************************************
560 reads or writes a SAM_ENTRY3 structure.
561 ********************************************************************/
562 static void sam_io_sam_entry3(char *desc
, SAM_ENTRY3
*sam
, prs_struct
*ps
, int depth
)
564 if (sam
== NULL
) return;
566 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry3");
571 prs_uint32("grp_idx", ps
, depth
, &(sam
->grp_idx
));
573 prs_uint32("rid_grp", ps
, depth
, &(sam
->rid_grp
));
574 prs_uint32("attr ", ps
, depth
, &(sam
->attr
));
576 smb_io_unihdr("unihdr", &(sam
->hdr_grp_name
), ps
, depth
); /* account name unicode string header */
577 smb_io_unihdr("unihdr", &(sam
->hdr_grp_desc
), ps
, depth
); /* account name unicode string header */
580 /*******************************************************************
581 makes a SAM_ENTRY structure.
582 ********************************************************************/
583 static void make_sam_entry(SAM_ENTRY
*sam
, uint32 len_sam_name
, uint32 rid
)
585 if (sam
== NULL
) return;
587 DEBUG(5,("make_sam_entry\n"));
590 make_uni_hdr(&(sam
->hdr_name
), len_sam_name
, len_sam_name
, len_sam_name
!= 0);
593 /*******************************************************************
594 reads or writes a SAM_ENTRY structure.
595 ********************************************************************/
596 static void sam_io_sam_entry(char *desc
, SAM_ENTRY
*sam
, prs_struct
*ps
, int depth
)
598 if (sam
== NULL
) return;
600 prs_debug(ps
, depth
, desc
, "sam_io_sam_entry");
604 prs_uint32("rid", ps
, depth
, &(sam
->rid
));
605 smb_io_unihdr("unihdr", &(sam
->hdr_name
), ps
, depth
); /* account name unicode string header */
609 /*******************************************************************
610 makes a SAMR_Q_ENUM_DOM_USERS structure.
611 ********************************************************************/
612 void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS
*q_e
, POLICY_HND
*pol
,
613 uint16 req_num_entries
, uint16 unk_0
,
614 uint16 acb_mask
, uint16 unk_1
, uint32 size
)
616 if (q_e
== NULL
|| pol
== NULL
) return;
618 DEBUG(5,("make_q_enum_dom_users\n"));
620 memcpy(&(q_e
->pol
), pol
, sizeof(*pol
));
622 q_e
->req_num_entries
= req_num_entries
; /* zero indicates lots */
623 q_e
->unknown_0
= unk_0
; /* this gets returned in the response */
624 q_e
->acb_mask
= acb_mask
;
625 q_e
->unknown_1
= unk_1
;
626 q_e
->max_size
= size
;
629 /*******************************************************************
630 reads or writes a structure.
631 ********************************************************************/
632 void samr_io_q_enum_dom_users(char *desc
, SAMR_Q_ENUM_DOM_USERS
*q_e
, prs_struct
*ps
, int depth
)
634 if (q_e
== NULL
) return;
636 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_users");
641 smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
);
644 prs_uint16("req_num_entries", ps
, depth
, &(q_e
->req_num_entries
));
645 prs_uint16("unknown_0 ", ps
, depth
, &(q_e
->unknown_0
));
647 prs_uint16("acb_mask ", ps
, depth
, &(q_e
->acb_mask
));
648 prs_uint16("unknown_1 ", ps
, depth
, &(q_e
->unknown_1
));
650 prs_uint32("max_size ", ps
, depth
, &(q_e
->max_size
));
656 /*******************************************************************
657 makes a SAMR_R_ENUM_DOM_USERS structure.
658 ********************************************************************/
659 void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS
*r_u
,
660 uint16 total_num_entries
, uint16 unk_0
,
661 uint32 num_sam_entries
, SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
], uint32 status
)
665 if (r_u
== NULL
) return;
667 DEBUG(5,("make_samr_r_enum_dom_users\n"));
669 if (num_sam_entries
>= MAX_SAM_ENTRIES
)
671 num_sam_entries
= MAX_SAM_ENTRIES
;
672 DEBUG(5,("limiting number of entries to %d\n",
676 r_u
->total_num_entries
= total_num_entries
;
677 r_u
->unknown_0
= unk_0
;
679 if (total_num_entries
> 0)
681 r_u
->ptr_entries1
= 1;
682 r_u
->ptr_entries2
= 1;
683 r_u
->num_entries2
= num_sam_entries
;
684 r_u
->num_entries3
= num_sam_entries
;
686 SMB_ASSERT_ARRAY(r_u
->sam
, num_sam_entries
);
687 SMB_ASSERT_ARRAY(r_u
->uni_acct_name
, num_sam_entries
);
689 for (i
= 0; i
< num_sam_entries
; i
++)
691 make_sam_entry(&(r_u
->sam
[i
]),
692 pass
[i
].uni_user_name
.uni_str_len
,
695 copy_unistr2(&(r_u
->uni_acct_name
[i
]), &(pass
[i
].uni_user_name
));
698 r_u
->num_entries4
= num_sam_entries
;
702 r_u
->ptr_entries1
= 0;
703 r_u
->num_entries2
= num_sam_entries
;
704 r_u
->ptr_entries2
= 1;
707 r_u
->status
= status
;
710 /*******************************************************************
711 reads or writes a structure.
712 ********************************************************************/
713 void samr_io_r_enum_dom_users(char *desc
, SAMR_R_ENUM_DOM_USERS
*r_u
, prs_struct
*ps
, int depth
)
717 if (r_u
== NULL
) return;
719 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_users");
724 prs_uint16("total_num_entries", ps
, depth
, &(r_u
->total_num_entries
));
725 prs_uint16("unknown_0 ", ps
, depth
, &(r_u
->unknown_0
));
726 prs_uint32("ptr_entries1", ps
, depth
, &(r_u
->ptr_entries1
));
728 if (r_u
->total_num_entries
!= 0 && r_u
->ptr_entries1
!= 0)
730 prs_uint32("num_entries2", ps
, depth
, &(r_u
->num_entries2
));
731 prs_uint32("ptr_entries2", ps
, depth
, &(r_u
->ptr_entries2
));
732 prs_uint32("num_entries3", ps
, depth
, &(r_u
->num_entries3
));
734 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries2
);
736 for (i
= 0; i
< r_u
->num_entries2
; i
++)
739 sam_io_sam_entry("", &(r_u
->sam
[i
]), ps
, depth
);
742 SMB_ASSERT_ARRAY(r_u
->uni_acct_name
, r_u
->num_entries2
);
744 for (i
= 0; i
< r_u
->num_entries2
; i
++)
747 smb_io_unistr2("", &(r_u
->uni_acct_name
[i
]), r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
);
752 prs_uint32("num_entries4", ps
, depth
, &(r_u
->num_entries4
));
755 prs_uint32("status", ps
, depth
, &(r_u
->status
));
758 /*******************************************************************
759 makes a SAMR_Q_ENUM_DOM_ALIASES structure.
760 ********************************************************************/
761 void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES
*q_e
, POLICY_HND
*pol
, uint32 size
)
763 if (q_e
== NULL
|| pol
== NULL
) return;
765 DEBUG(5,("make_q_enum_dom_aliases\n"));
767 memcpy(&(q_e
->pol
), pol
, sizeof(*pol
));
770 q_e
->max_size
= size
;
774 /*******************************************************************
775 reads or writes a structure.
776 ********************************************************************/
777 void samr_io_q_enum_dom_aliases(char *desc
, SAMR_Q_ENUM_DOM_ALIASES
*q_e
, prs_struct
*ps
, int depth
)
779 if (q_e
== NULL
) return;
781 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_aliases");
786 smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
);
789 prs_uint32("unknown_0", ps
, depth
, &(q_e
->unknown_0
));
790 prs_uint32("max_size ", ps
, depth
, &(q_e
->max_size
));
796 /*******************************************************************
797 makes a SAMR_R_ENUM_DOM_ALIASES structure.
798 ********************************************************************/
799 void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES
*r_u
,
800 uint32 num_sam_entries
, SAM_USER_INFO_21 grps
[MAX_SAM_ENTRIES
],
805 if (r_u
== NULL
) return;
807 DEBUG(5,("make_samr_r_enum_dom_aliases\n"));
809 if (num_sam_entries
>= MAX_SAM_ENTRIES
)
811 num_sam_entries
= MAX_SAM_ENTRIES
;
812 DEBUG(5,("limiting number of entries to %d\n",
816 r_u
->num_entries
= num_sam_entries
;
818 if (num_sam_entries
> 0)
820 r_u
->ptr_entries
= 1;
821 r_u
->num_entries2
= num_sam_entries
;
822 r_u
->ptr_entries2
= 1;
823 r_u
->num_entries3
= num_sam_entries
;
825 SMB_ASSERT_ARRAY(r_u
->sam
, num_sam_entries
);
827 for (i
= 0; i
< num_sam_entries
; i
++)
829 make_sam_entry(&(r_u
->sam
[i
]),
830 grps
[i
].uni_user_name
.uni_str_len
,
833 copy_unistr2(&(r_u
->uni_grp_name
[i
]), &(grps
[i
].uni_user_name
));
836 r_u
->num_entries4
= num_sam_entries
;
840 r_u
->ptr_entries
= 0;
843 r_u
->status
= status
;
846 /*******************************************************************
847 reads or writes a structure.
848 ********************************************************************/
849 void samr_io_r_enum_dom_aliases(char *desc
, SAMR_R_ENUM_DOM_ALIASES
*r_u
, prs_struct
*ps
, int depth
)
853 if (r_u
== NULL
) return;
855 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_aliases");
860 prs_uint32("num_entries", ps
, depth
, &(r_u
->num_entries
));
861 prs_uint32("ptr_entries", ps
, depth
, &(r_u
->ptr_entries
));
863 if (r_u
->num_entries
!= 0 && r_u
->ptr_entries
!= 0)
865 prs_uint32("num_entries2", ps
, depth
, &(r_u
->num_entries2
));
866 prs_uint32("ptr_entries2", ps
, depth
, &(r_u
->ptr_entries2
));
867 prs_uint32("num_entries3", ps
, depth
, &(r_u
->num_entries3
));
869 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries
);
871 for (i
= 0; i
< r_u
->num_entries
; i
++)
873 sam_io_sam_entry("", &(r_u
->sam
[i
]), ps
, depth
);
876 for (i
= 0; i
< r_u
->num_entries
; i
++)
878 smb_io_unistr2("", &(r_u
->uni_grp_name
[i
]), r_u
->sam
[i
].hdr_name
.buffer
, ps
, depth
);
883 prs_uint32("num_entries4", ps
, depth
, &(r_u
->num_entries4
));
886 prs_uint32("status", ps
, depth
, &(r_u
->status
));
890 /*******************************************************************
891 makes a SAMR_Q_QUERY_DISPINFO structure.
892 ********************************************************************/
893 void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO
*q_e
, POLICY_HND
*pol
,
894 uint16 switch_level
, uint32 start_idx
, uint32 size
)
896 if (q_e
== NULL
|| pol
== NULL
) return;
898 DEBUG(5,("make_q_query_dispinfo\n"));
900 memcpy(&(q_e
->pol
), pol
, sizeof(*pol
));
902 q_e
->switch_level
= switch_level
;
905 q_e
->start_idx
= start_idx
;
906 q_e
->unknown_1
= 0x000007d0;
907 q_e
->max_size
= size
;
910 /*******************************************************************
911 reads or writes a structure.
912 ********************************************************************/
913 void samr_io_q_query_dispinfo(char *desc
, SAMR_Q_QUERY_DISPINFO
*q_e
, prs_struct
*ps
, int depth
)
915 if (q_e
== NULL
) return;
917 prs_debug(ps
, depth
, desc
, "samr_io_q_query_dispinfo");
922 smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
);
925 prs_uint16("switch_level", ps
, depth
, &(q_e
->switch_level
));
926 prs_uint16("unknown_0 ", ps
, depth
, &(q_e
->unknown_0
));
927 prs_uint32("start_idx ", ps
, depth
, &(q_e
->start_idx
));
928 prs_uint32("unknown_1 ", ps
, depth
, &(q_e
->unknown_1
));
929 prs_uint32("max_size ", ps
, depth
, &(q_e
->max_size
));
935 /*******************************************************************
936 makes a SAM_INFO_2 structure.
937 ********************************************************************/
938 void make_sam_info_2(SAM_INFO_2
*sam
, uint32 acb_mask
,
939 uint32 start_idx
, uint32 num_sam_entries
,
940 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
])
945 if (sam
== NULL
) return;
947 DEBUG(5,("make_sam_info_2\n"));
949 if (num_sam_entries
>= MAX_SAM_ENTRIES
)
951 num_sam_entries
= MAX_SAM_ENTRIES
;
952 DEBUG(5,("limiting number of entries to %d\n",
956 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++)
958 if (IS_BITS_SET_ALL(pass
[i
].acb_info
, acb_mask
))
960 make_sam_entry2(&(sam
->sam
[entries_added
]),
961 start_idx
+ entries_added
+ 1,
962 pass
[i
].uni_user_name
.uni_str_len
,
963 pass
[i
].uni_acct_desc
.uni_str_len
,
967 copy_unistr2(&(sam
->str
[entries_added
].uni_srv_name
), &(pass
[i
].uni_user_name
));
968 copy_unistr2(&(sam
->str
[entries_added
].uni_srv_desc
), &(pass
[i
].uni_acct_desc
));
973 sam
->num_entries
= entries_added
;
974 sam
->ptr_entries
= 1;
975 sam
->num_entries2
= entries_added
;
979 /*******************************************************************
980 reads or writes a structure.
981 ********************************************************************/
982 static void sam_io_sam_info_2(char *desc
, SAM_INFO_2
*sam
, prs_struct
*ps
, int depth
)
986 if (sam
== NULL
) return;
988 prs_debug(ps
, depth
, desc
, "sam_io_sam_info_2");
993 prs_uint32("num_entries ", ps
, depth
, &(sam
->num_entries
));
994 prs_uint32("ptr_entries ", ps
, depth
, &(sam
->ptr_entries
));
996 prs_uint32("num_entries2 ", ps
, depth
, &(sam
->num_entries2
));
998 SMB_ASSERT_ARRAY(sam
->sam
, sam
->num_entries
);
1000 for (i
= 0; i
< sam
->num_entries
; i
++)
1002 sam_io_sam_entry2("", &(sam
->sam
[i
]), ps
, depth
);
1005 for (i
= 0; i
< sam
->num_entries
; i
++)
1007 sam_io_sam_str2 ("", &(sam
->str
[i
]),
1008 sam
->sam
[i
].hdr_srv_name
.buffer
,
1009 sam
->sam
[i
].hdr_srv_desc
.buffer
,
1015 /*******************************************************************
1016 makes a SAM_INFO_1 structure.
1017 ********************************************************************/
1018 void make_sam_info_1(SAM_INFO_1
*sam
, uint32 acb_mask
,
1019 uint32 start_idx
, uint32 num_sam_entries
,
1020 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
])
1025 if (sam
== NULL
) return;
1027 DEBUG(5,("make_sam_info_1\n"));
1029 if (num_sam_entries
>= MAX_SAM_ENTRIES
)
1031 num_sam_entries
= MAX_SAM_ENTRIES
;
1032 DEBUG(5,("limiting number of entries to %d\n",
1036 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++)
1038 if (IS_BITS_SET_ALL(pass
[i
].acb_info
, acb_mask
))
1040 make_sam_entry1(&(sam
->sam
[entries_added
]),
1041 start_idx
+ entries_added
+ 1,
1042 pass
[i
].uni_user_name
.uni_str_len
,
1043 pass
[i
].uni_full_name
.uni_str_len
,
1044 pass
[i
].uni_acct_desc
.uni_str_len
,
1048 copy_unistr2(&(sam
->str
[entries_added
].uni_acct_name
), &(pass
[i
].uni_user_name
));
1049 copy_unistr2(&(sam
->str
[entries_added
].uni_full_name
), &(pass
[i
].uni_full_name
));
1050 copy_unistr2(&(sam
->str
[entries_added
].uni_acct_desc
), &(pass
[i
].uni_acct_desc
));
1056 sam
->num_entries
= entries_added
;
1057 sam
->ptr_entries
= 1;
1058 sam
->num_entries2
= entries_added
;
1062 /*******************************************************************
1063 reads or writes a structure.
1064 ********************************************************************/
1065 static void sam_io_sam_info_1(char *desc
, SAM_INFO_1
*sam
, prs_struct
*ps
, int depth
)
1069 if (sam
== NULL
) return;
1071 prs_debug(ps
, depth
, desc
, "sam_io_sam_info_1");
1076 prs_uint32("num_entries ", ps
, depth
, &(sam
->num_entries
));
1077 prs_uint32("ptr_entries ", ps
, depth
, &(sam
->ptr_entries
));
1079 prs_uint32("num_entries2 ", ps
, depth
, &(sam
->num_entries2
));
1081 SMB_ASSERT_ARRAY(sam
->sam
, sam
->num_entries
);
1083 for (i
= 0; i
< sam
->num_entries
; i
++)
1085 sam_io_sam_entry1("", &(sam
->sam
[i
]), ps
, depth
);
1088 for (i
= 0; i
< sam
->num_entries
; i
++)
1090 sam_io_sam_str1 ("", &(sam
->str
[i
]),
1091 sam
->sam
[i
].hdr_acct_name
.buffer
,
1092 sam
->sam
[i
].hdr_user_name
.buffer
,
1093 sam
->sam
[i
].hdr_user_desc
.buffer
,
1099 /*******************************************************************
1100 makes a SAMR_R_QUERY_DISPINFO structure.
1101 ********************************************************************/
1102 void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO
*r_u
,
1103 uint16 switch_level
, SAM_INFO_CTR
*ctr
, uint32 status
)
1105 if (r_u
== NULL
) return;
1107 DEBUG(5,("make_samr_r_query_dispinfo\n"));
1111 r_u
->unknown_0
= 0x0000001;
1112 r_u
->unknown_1
= 0x0000001;
1116 r_u
->unknown_0
= 0x0;
1117 r_u
->unknown_1
= 0x0;
1120 r_u
->switch_level
= switch_level
;
1122 r_u
->status
= status
;
1126 /*******************************************************************
1127 reads or writes a structure.
1128 ********************************************************************/
1129 void samr_io_r_query_dispinfo(char *desc
, SAMR_R_QUERY_DISPINFO
*r_u
, prs_struct
*ps
, int depth
)
1131 if (r_u
== NULL
) return;
1133 prs_debug(ps
, depth
, desc
, "samr_io_r_query_dispinfo");
1138 prs_uint32("unknown_0 ", ps
, depth
, &(r_u
->unknown_0
));
1139 prs_uint32("unknown_1 ", ps
, depth
, &(r_u
->unknown_1
));
1140 prs_uint16("switch_level ", ps
, depth
, &(r_u
->switch_level
));
1144 switch (r_u
->switch_level
)
1148 sam_io_sam_info_1("users", r_u
->ctr
->sam
.info1
, ps
, depth
);
1153 sam_io_sam_info_2("servers", r_u
->ctr
->sam
.info2
, ps
, depth
);
1158 DEBUG(5,("samr_io_r_query_dispinfo: unknown switch value\n"));
1163 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1167 /*******************************************************************
1168 makes a SAMR_Q_ENUM_DOM_GROUPS structure.
1169 ********************************************************************/
1170 void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS
*q_e
, POLICY_HND
*pol
,
1171 uint16 switch_level
, uint32 start_idx
, uint32 size
)
1173 if (q_e
== NULL
|| pol
== NULL
) return;
1175 DEBUG(5,("make_q_enum_dom_groups\n"));
1177 memcpy(&(q_e
->pol
), pol
, sizeof(*pol
));
1179 q_e
->switch_level
= switch_level
;
1182 q_e
->start_idx
= start_idx
;
1183 q_e
->unknown_1
= 0x000007d0;
1184 q_e
->max_size
= size
;
1188 /*******************************************************************
1189 reads or writes a structure.
1190 ********************************************************************/
1191 void samr_io_q_enum_dom_groups(char *desc
, SAMR_Q_ENUM_DOM_GROUPS
*q_e
, prs_struct
*ps
, int depth
)
1193 if (q_e
== NULL
) return;
1195 prs_debug(ps
, depth
, desc
, "samr_io_q_enum_dom_groups");
1200 smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
);
1203 prs_uint16("switch_level", ps
, depth
, &(q_e
->switch_level
));
1204 prs_uint16("unknown_0 ", ps
, depth
, &(q_e
->unknown_0
));
1205 prs_uint32("start_idx ", ps
, depth
, &(q_e
->start_idx
));
1206 prs_uint32("unknown_1 ", ps
, depth
, &(q_e
->unknown_1
));
1207 prs_uint32("max_size ", ps
, depth
, &(q_e
->max_size
));
1213 /*******************************************************************
1214 makes a SAMR_R_ENUM_DOM_GROUPS structure.
1215 ********************************************************************/
1216 void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS
*r_u
,
1217 uint32 start_idx
, uint32 num_sam_entries
,
1218 SAM_USER_INFO_21 pass
[MAX_SAM_ENTRIES
],
1224 if (r_u
== NULL
) return;
1226 DEBUG(5,("make_samr_r_enum_dom_groups\n"));
1228 if (num_sam_entries
>= MAX_SAM_ENTRIES
)
1230 num_sam_entries
= MAX_SAM_ENTRIES
;
1231 DEBUG(5,("limiting number of entries to %d\n",
1237 for (i
= start_idx
, entries_added
= 0; i
< num_sam_entries
; i
++)
1239 make_sam_entry3(&(r_u
->sam
[entries_added
]),
1240 start_idx
+ entries_added
+ 1,
1241 pass
[i
].uni_user_name
.uni_str_len
,
1242 pass
[i
].uni_acct_desc
.uni_str_len
,
1245 copy_unistr2(&(r_u
->str
[entries_added
].uni_grp_name
), &(pass
[i
].uni_user_name
));
1246 copy_unistr2(&(r_u
->str
[entries_added
].uni_grp_desc
), &(pass
[i
].uni_acct_desc
));
1251 if (entries_added
> 0)
1253 r_u
->unknown_0
= 0x0000492;
1254 r_u
->unknown_1
= 0x000049a;
1258 r_u
->unknown_0
= 0x0;
1259 r_u
->unknown_1
= 0x0;
1261 r_u
->switch_level
= 3;
1262 r_u
->num_entries
= entries_added
;
1263 r_u
->ptr_entries
= 1;
1264 r_u
->num_entries2
= entries_added
;
1268 r_u
->switch_level
= 0;
1271 r_u
->status
= status
;
1274 /*******************************************************************
1275 reads or writes a structure.
1276 ********************************************************************/
1277 void samr_io_r_enum_dom_groups(char *desc
, SAMR_R_ENUM_DOM_GROUPS
*r_u
, prs_struct
*ps
, int depth
)
1281 if (r_u
== NULL
) return;
1283 prs_debug(ps
, depth
, desc
, "samr_io_r_enum_dom_groups");
1288 prs_uint32("unknown_0 ", ps
, depth
, &(r_u
->unknown_0
));
1289 prs_uint32("unknown_1 ", ps
, depth
, &(r_u
->unknown_1
));
1290 prs_uint32("switch_level ", ps
, depth
, &(r_u
->switch_level
));
1292 if (r_u
->switch_level
!= 0)
1294 prs_uint32("num_entries ", ps
, depth
, &(r_u
->num_entries
));
1295 prs_uint32("ptr_entries ", ps
, depth
, &(r_u
->ptr_entries
));
1297 prs_uint32("num_entries2 ", ps
, depth
, &(r_u
->num_entries2
));
1299 SMB_ASSERT_ARRAY(r_u
->sam
, r_u
->num_entries
);
1301 for (i
= 0; i
< r_u
->num_entries
; i
++)
1303 sam_io_sam_entry3("", &(r_u
->sam
[i
]), ps
, depth
);
1306 for (i
= 0; i
< r_u
->num_entries
; i
++)
1308 sam_io_sam_str3 ("", &(r_u
->str
[i
]),
1309 r_u
->sam
[i
].hdr_grp_name
.buffer
,
1310 r_u
->sam
[i
].hdr_grp_desc
.buffer
,
1315 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1319 /*******************************************************************
1320 makes a SAMR_Q_QUERY_ALIASINFO structure.
1321 ********************************************************************/
1322 void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO
*q_e
,
1324 uint16 switch_level
)
1326 if (q_e
== NULL
|| pol
== NULL
) return;
1328 DEBUG(5,("make_q_query_aliasinfo\n"));
1330 memcpy(&(q_e
->pol
), pol
, sizeof(*pol
));
1332 q_e
->switch_level
= switch_level
;
1336 /*******************************************************************
1337 reads or writes a structure.
1338 ********************************************************************/
1339 void samr_io_q_query_aliasinfo(char *desc
, SAMR_Q_QUERY_ALIASINFO
*q_e
, prs_struct
*ps
, int depth
)
1341 if (q_e
== NULL
) return;
1343 prs_debug(ps
, depth
, desc
, "samr_io_q_query_aliasinfo");
1348 smb_io_pol_hnd("pol", &(q_e
->pol
), ps
, depth
);
1351 prs_uint16("switch_level", ps
, depth
, &(q_e
->switch_level
));
1355 /*******************************************************************
1356 makes a SAMR_R_QUERY_ALIASINFO structure.
1357 ********************************************************************/
1358 void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO
*r_u
,
1359 uint16 switch_value
, char *acct_desc
,
1362 if (r_u
== NULL
) return;
1364 DEBUG(5,("make_samr_r_query_aliasinfo\n"));
1370 r_u
->switch_value
= switch_value
;
1372 switch (switch_value
)
1376 int acct_len
= acct_desc
? strlen(acct_desc
) : 0;
1380 make_uni_hdr(&(r_u
->alias
.info3
.hdr_acct_desc
), acct_len
, acct_len
, acct_desc
? 1 : 0);
1381 make_unistr2(&(r_u
->alias
.info3
.uni_acct_desc
), acct_desc
, acct_len
);
1388 DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
1394 r_u
->status
= status
;
1398 /*******************************************************************
1399 reads or writes a structure.
1400 ********************************************************************/
1401 void samr_io_r_query_aliasinfo(char *desc
, SAMR_R_QUERY_ALIASINFO
*r_u
, prs_struct
*ps
, int depth
)
1403 if (r_u
== NULL
) return;
1405 prs_debug(ps
, depth
, desc
, "samr_io_r_query_aliasinfo");
1410 prs_uint32("ptr ", ps
, depth
, &(r_u
->ptr
));
1414 prs_uint16("switch_value", ps
, depth
, &(r_u
->switch_value
));
1417 if (r_u
->switch_value
!= 0)
1419 switch (r_u
->switch_value
)
1423 smb_io_unihdr ("", &(r_u
->alias
.info3
.hdr_acct_desc
), ps
, depth
);
1424 smb_io_unistr2("", &(r_u
->alias
.info3
.uni_acct_desc
), r_u
->alias
.info3
.hdr_acct_desc
.buffer
, ps
, depth
);
1429 DEBUG(4,("samr_io_r_query_aliasinfo: unsupported switch level\n"));
1438 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1441 /*******************************************************************
1442 reads or writes a SAMR_Q_LOOKUP_IDS structure.
1443 ********************************************************************/
1444 void samr_io_q_lookup_ids(char *desc
, SAMR_Q_LOOKUP_IDS
*q_u
, prs_struct
*ps
, int depth
)
1449 if (q_u
== NULL
) return;
1451 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_ids");
1456 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
1459 prs_uint32("num_sids1", ps
, depth
, &(q_u
->num_sids1
));
1460 prs_uint32("ptr ", ps
, depth
, &(q_u
->ptr
));
1461 prs_uint32("num_sids2", ps
, depth
, &(q_u
->num_sids2
));
1463 SMB_ASSERT_ARRAY(q_u
->ptr_sid
, q_u
->num_sids2
);
1465 for (i
= 0; i
< q_u
->num_sids2
; i
++)
1467 slprintf(tmp
, sizeof(tmp
) - 1, "ptr[%02d]", i
);
1468 prs_uint32(tmp
, ps
, depth
, &(q_u
->ptr_sid
[i
]));
1471 for (i
= 0; i
< q_u
->num_sids2
; i
++)
1473 if (q_u
->ptr_sid
[i
] != 0)
1475 slprintf(tmp
, sizeof(tmp
)-1, "sid[%02d]", i
);
1476 smb_io_dom_sid2(tmp
, &(q_u
->sid
[i
]), ps
, depth
);
1484 /*******************************************************************
1485 makes a SAMR_R_LOOKUP_IDS structure.
1486 ********************************************************************/
1487 void make_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS
*r_u
,
1488 uint32 num_rids
, uint32
*rid
, uint32 status
)
1491 if (r_u
== NULL
) return;
1493 DEBUG(5,("make_samr_r_lookup_ids\n"));
1497 r_u
->num_entries
= num_rids
;
1499 r_u
->num_entries2
= num_rids
;
1501 SMB_ASSERT_ARRAY(r_u
->rid
, num_rids
);
1503 for (i
= 0; i
< num_rids
; i
++)
1505 r_u
->rid
[i
] = rid
[i
];
1510 r_u
->num_entries
= 0;
1512 r_u
->num_entries2
= 0;
1515 r_u
->status
= status
;
1518 /*******************************************************************
1519 reads or writes a structure.
1520 ********************************************************************/
1521 void samr_io_r_lookup_ids(char *desc
, SAMR_R_LOOKUP_IDS
*r_u
, prs_struct
*ps
, int depth
)
1525 if (r_u
== NULL
) return;
1527 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_ids");
1532 prs_uint32("num_entries", ps
, depth
, &(r_u
->num_entries
));
1533 prs_uint32("ptr ", ps
, depth
, &(r_u
->ptr
));
1534 prs_uint32("num_entries2", ps
, depth
, &(r_u
->num_entries2
));
1536 if (r_u
->num_entries
!= 0)
1538 SMB_ASSERT_ARRAY(r_u
->rid
, r_u
->num_entries2
);
1540 for (i
= 0; i
< r_u
->num_entries2
; i
++)
1542 slprintf(tmp
, sizeof(tmp
)-1, "rid[%02d]", i
);
1543 prs_uint32(tmp
, ps
, depth
, &(r_u
->rid
[i
]));
1547 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1550 /*******************************************************************
1551 reads or writes a structure.
1552 ********************************************************************/
1553 void samr_io_q_lookup_names(char *desc
, SAMR_Q_LOOKUP_NAMES
*q_u
, prs_struct
*ps
, int depth
)
1557 if (q_u
== NULL
) return;
1559 prs_debug(ps
, depth
, desc
, "samr_io_q_lookup_names");
1564 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
1567 prs_uint32("num_rids1", ps
, depth
, &(q_u
->num_rids1
));
1568 prs_uint32("rid ", ps
, depth
, &(q_u
->rid
));
1569 prs_uint32("ptr ", ps
, depth
, &(q_u
->ptr
));
1570 prs_uint32("num_rids2", ps
, depth
, &(q_u
->num_rids2
));
1572 SMB_ASSERT_ARRAY(q_u
->hdr_user_name
, q_u
->num_rids2
);
1574 for (i
= 0; i
< q_u
->num_rids2
; i
++)
1576 smb_io_unihdr ("", &(q_u
->hdr_user_name
[i
]), ps
, depth
);
1578 for (i
= 0; i
< q_u
->num_rids2
; i
++)
1580 smb_io_unistr2("", &(q_u
->uni_user_name
[i
]), q_u
->hdr_user_name
[i
].buffer
, ps
, depth
);
1587 /*******************************************************************
1588 makes a SAMR_R_LOOKUP_NAMES structure.
1589 ********************************************************************/
1590 void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES
*r_u
,
1591 uint32 num_rids
, uint32
*rid
, uint32 status
)
1594 if (r_u
== NULL
) return;
1596 DEBUG(5,("make_samr_r_lookup_names\n"));
1600 r_u
->num_entries
= num_rids
;
1601 r_u
->undoc_buffer
= 1;
1602 r_u
->num_entries2
= num_rids
;
1604 SMB_ASSERT_ARRAY(r_u
->dom_rid
, num_rids
);
1606 for (i
= 0; i
< num_rids
; i
++)
1608 make_dom_rid3(&(r_u
->dom_rid
[i
]), rid
[i
]);
1611 r_u
->num_entries3
= num_rids
;
1615 r_u
->num_entries
= 0;
1616 r_u
->undoc_buffer
= 0;
1617 r_u
->num_entries2
= 0;
1618 r_u
->num_entries3
= 0;
1621 r_u
->status
= status
;
1624 /*******************************************************************
1625 reads or writes a structure.
1626 ********************************************************************/
1627 void samr_io_r_lookup_names(char *desc
, SAMR_R_LOOKUP_NAMES
*r_u
, prs_struct
*ps
, int depth
)
1630 if (r_u
== NULL
) return;
1632 prs_debug(ps
, depth
, desc
, "samr_io_r_lookup_names");
1637 prs_uint32("num_entries ", ps
, depth
, &(r_u
->num_entries
));
1638 prs_uint32("undoc_buffer", ps
, depth
, &(r_u
->undoc_buffer
));
1639 prs_uint32("num_entries2", ps
, depth
, &(r_u
->num_entries2
));
1641 if (r_u
->num_entries
!= 0)
1643 SMB_ASSERT_ARRAY(r_u
->dom_rid
, r_u
->num_entries2
);
1645 for (i
= 0; i
< r_u
->num_entries2
; i
++)
1647 smb_io_dom_rid3("", &(r_u
->dom_rid
[i
]), ps
, depth
);
1652 prs_uint32("num_entries3", ps
, depth
, &(r_u
->num_entries3
));
1654 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1657 /*******************************************************************
1658 reads or writes a structure.
1659 ********************************************************************/
1660 void samr_io_q_unknown_12(char *desc
, SAMR_Q_UNKNOWN_12
*q_u
, prs_struct
*ps
, int depth
)
1665 if (q_u
== NULL
) return;
1667 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_12");
1672 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
1675 prs_uint32("num_gids1", ps
, depth
, &(q_u
->num_gids1
));
1676 prs_uint32("rid ", ps
, depth
, &(q_u
->rid
));
1677 prs_uint32("ptr ", ps
, depth
, &(q_u
->ptr
));
1678 prs_uint32("num_gids2", ps
, depth
, &(q_u
->num_gids2
));
1680 SMB_ASSERT_ARRAY(q_u
->gid
, q_u
->num_gids2
);
1682 for (i
= 0; i
< q_u
->num_gids2
; i
++)
1684 slprintf(tmp
, sizeof(tmp
) - 1, "gid[%02d] ", i
);
1685 prs_uint32(tmp
, ps
, depth
, &(q_u
->gid
[i
]));
1692 /*******************************************************************
1693 makes a SAMR_R_UNKNOWN_12 structure.
1694 ********************************************************************/
1695 void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12
*r_u
,
1696 uint32 num_aliases
, fstring
*als_name
, uint32
*num_als_usrs
,
1700 if (r_u
== NULL
|| als_name
== NULL
|| num_als_usrs
== NULL
) return;
1702 DEBUG(5,("make_samr_r_unknown_12\n"));
1706 r_u
->num_aliases1
= num_aliases
;
1707 r_u
->ptr_aliases
= 1;
1708 r_u
->num_aliases2
= num_aliases
;
1710 r_u
->num_als_usrs1
= num_aliases
;
1711 r_u
->ptr_als_usrs
= 1;
1712 r_u
->num_als_usrs2
= num_aliases
;
1714 SMB_ASSERT_ARRAY(r_u
->hdr_als_name
, num_aliases
);
1716 for (i
= 0; i
< num_aliases
; i
++)
1718 int als_len
= als_name
[i
] != NULL
? strlen(als_name
[i
]) : 0;
1719 make_uni_hdr(&(r_u
->hdr_als_name
[i
]), als_len
, als_len
, als_name
[i
] ? 1 : 0);
1720 make_unistr2(&(r_u
->uni_als_name
[i
]), als_name
[i
], als_len
);
1721 r_u
->num_als_usrs
[i
] = num_als_usrs
[i
];
1726 r_u
->num_aliases1
= num_aliases
;
1727 r_u
->ptr_aliases
= 0;
1728 r_u
->num_aliases2
= num_aliases
;
1730 r_u
->num_als_usrs1
= num_aliases
;
1731 r_u
->ptr_als_usrs
= 0;
1732 r_u
->num_als_usrs2
= num_aliases
;
1735 r_u
->status
= status
;
1738 /*******************************************************************
1739 reads or writes a structure.
1740 ********************************************************************/
1741 void samr_io_r_unknown_12(char *desc
, SAMR_R_UNKNOWN_12
*r_u
, prs_struct
*ps
, int depth
)
1745 if (r_u
== NULL
) return;
1747 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_12");
1752 prs_uint32("num_aliases1", ps
, depth
, &(r_u
->num_aliases1
));
1753 prs_uint32("ptr_aliases ", ps
, depth
, &(r_u
->ptr_aliases
));
1754 prs_uint32("num_aliases2", ps
, depth
, &(r_u
->num_aliases2
));
1756 if (r_u
->ptr_aliases
!= 0 && r_u
->num_aliases1
!= 0)
1758 SMB_ASSERT_ARRAY(r_u
->hdr_als_name
, r_u
->num_aliases2
);
1760 for (i
= 0; i
< r_u
->num_aliases2
; i
++)
1762 slprintf(tmp
, sizeof(tmp
) - 1, "als_hdr[%02d] ", i
);
1763 smb_io_unihdr ("", &(r_u
->hdr_als_name
[i
]), ps
, depth
);
1765 for (i
= 0; i
< r_u
->num_aliases2
; i
++)
1767 slprintf(tmp
, sizeof(tmp
) - 1, "als_str[%02d] ", i
);
1768 smb_io_unistr2("", &(r_u
->uni_als_name
[i
]), r_u
->hdr_als_name
[i
].buffer
, ps
, depth
);
1774 prs_uint32("num_als_usrs1", ps
, depth
, &(r_u
->num_als_usrs1
));
1775 prs_uint32("ptr_als_usrs ", ps
, depth
, &(r_u
->ptr_als_usrs
));
1776 prs_uint32("num_als_usrs2", ps
, depth
, &(r_u
->num_als_usrs2
));
1778 if (r_u
->ptr_als_usrs
!= 0 && r_u
->num_als_usrs1
!= 0)
1780 SMB_ASSERT_ARRAY(r_u
->num_als_usrs
, r_u
->num_als_usrs2
);
1782 for (i
= 0; i
< r_u
->num_als_usrs2
; i
++)
1784 slprintf(tmp
, sizeof(tmp
) - 1, "als_usrs[%02d] ", i
);
1785 prs_uint32(tmp
, ps
, depth
, &(r_u
->num_als_usrs
[i
]));
1789 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1793 /*******************************************************************
1794 reads or writes a structure.
1795 ********************************************************************/
1796 void make_samr_q_open_user(SAMR_Q_OPEN_USER
*q_u
,
1798 uint32 unk_0
, uint32 rid
)
1800 if (q_u
== NULL
) return;
1802 DEBUG(5,("samr_make_q_open_user\n"));
1804 memcpy(&q_u
->domain_pol
, pol
, sizeof(q_u
->domain_pol
));
1806 q_u
->unknown_0
= unk_0
;
1807 q_u
->user_rid
= rid
;
1810 /*******************************************************************
1811 reads or writes a structure.
1812 ********************************************************************/
1813 void samr_io_q_open_user(char *desc
, SAMR_Q_OPEN_USER
*q_u
, prs_struct
*ps
, int depth
)
1815 if (q_u
== NULL
) return;
1817 prs_debug(ps
, depth
, desc
, "samr_io_q_open_user");
1822 smb_io_pol_hnd("domain_pol", &(q_u
->domain_pol
), ps
, depth
);
1825 prs_uint32("unknown_0", ps
, depth
, &(q_u
->unknown_0
));
1826 prs_uint32("user_rid ", ps
, depth
, &(q_u
->user_rid
));
1831 /*******************************************************************
1832 reads or writes a structure.
1833 ********************************************************************/
1834 void samr_io_r_open_user(char *desc
, SAMR_R_OPEN_USER
*r_u
, prs_struct
*ps
, int depth
)
1836 if (r_u
== NULL
) return;
1838 prs_debug(ps
, depth
, desc
, "samr_io_r_open_user");
1843 smb_io_pol_hnd("user_pol", &(r_u
->user_pol
), ps
, depth
);
1846 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1849 /*******************************************************************
1850 makes a SAMR_Q_QUERY_USERGROUPS structure.
1851 ********************************************************************/
1852 void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS
*q_u
,
1855 if (q_u
== NULL
|| hnd
== NULL
) return;
1857 DEBUG(5,("make_samr_q_query_usergroups\n"));
1859 memcpy(&(q_u
->pol
), hnd
, sizeof(q_u
->pol
));
1863 /*******************************************************************
1864 reads or writes a structure.
1865 ********************************************************************/
1866 void samr_io_q_query_usergroups(char *desc
, SAMR_Q_QUERY_USERGROUPS
*q_u
, prs_struct
*ps
, int depth
)
1868 if (q_u
== NULL
) return;
1870 prs_debug(ps
, depth
, desc
, "samr_io_q_query_usergroups");
1875 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
1879 /*******************************************************************
1880 makes a SAMR_R_QUERY_USERGROUPS structure.
1881 ********************************************************************/
1882 void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS
*r_u
,
1883 uint32 num_gids
, DOM_GID
*gid
, uint32 status
)
1885 if (r_u
== NULL
) return;
1887 DEBUG(5,("make_samr_r_query_usergroups\n"));
1892 r_u
->num_entries
= num_gids
;
1894 r_u
->num_entries2
= num_gids
;
1901 r_u
->num_entries
= 0;
1905 r_u
->status
= status
;
1908 /*******************************************************************
1909 reads or writes a structure.
1910 ********************************************************************/
1911 void samr_io_r_query_usergroups(char *desc
, SAMR_R_QUERY_USERGROUPS
*r_u
, prs_struct
*ps
, int depth
)
1914 if (r_u
== NULL
) return;
1916 prs_debug(ps
, depth
, desc
, "samr_io_r_query_usergroups");
1921 prs_uint32("ptr_0 ", ps
, depth
, &(r_u
->ptr_0
));
1923 if (r_u
->ptr_0
!= 0)
1925 prs_uint32("num_entries ", ps
, depth
, &(r_u
->num_entries
));
1926 prs_uint32("ptr_1 ", ps
, depth
, &(r_u
->ptr_1
));
1928 if (r_u
->num_entries
!= 0)
1930 prs_uint32("num_entries2", ps
, depth
, &(r_u
->num_entries2
));
1932 for (i
= 0; i
< r_u
->num_entries2
; i
++)
1934 smb_io_gid("", &(r_u
->gid
[i
]), ps
, depth
);
1938 prs_uint32("status", ps
, depth
, &(r_u
->status
));
1941 /*******************************************************************
1942 makes a SAMR_Q_QUERY_USERINFO structure.
1943 ********************************************************************/
1944 void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO
*q_u
,
1945 POLICY_HND
*hnd
, uint16 switch_value
)
1947 if (q_u
== NULL
|| hnd
== NULL
) return;
1949 DEBUG(5,("make_samr_q_query_userinfo\n"));
1951 memcpy(&(q_u
->pol
), hnd
, sizeof(q_u
->pol
));
1952 q_u
->switch_value
= switch_value
;
1956 /*******************************************************************
1957 reads or writes a structure.
1958 ********************************************************************/
1959 void samr_io_q_query_userinfo(char *desc
, SAMR_Q_QUERY_USERINFO
*q_u
, prs_struct
*ps
, int depth
)
1961 if (q_u
== NULL
) return;
1963 prs_debug(ps
, depth
, desc
, "samr_io_q_query_userinfo");
1968 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
1971 prs_uint16("switch_value", ps
, depth
, &(q_u
->switch_value
)); /* 0x0015 or 0x0011 */
1976 /*******************************************************************
1977 reads or writes a LOGON_HRS structure.
1978 ********************************************************************/
1979 static void sam_io_logon_hrs(char *desc
, LOGON_HRS
*hrs
, prs_struct
*ps
, int depth
)
1981 if (hrs
== NULL
) return;
1983 prs_debug(ps
, depth
, desc
, "sam_io_logon_hrs");
1988 prs_uint32 ( "len ", ps
, depth
, &(hrs
->len
));
1992 DEBUG(5,("sam_io_logon_hrs: truncating length\n"));
1996 prs_uint8s (False
, "hours", ps
, depth
, hrs
->hours
, hrs
->len
);
1999 /*************************************************************************
2000 make_sam_user_info21
2002 unknown_3 = 0x00ff ffff
2003 unknown_5 = 0x0002 0000
2004 unknown_6 = 0x0000 04ec
2006 *************************************************************************/
2007 void make_sam_user_info21(SAM_USER_INFO_21
*usr
,
2010 NTTIME
*logoff_time
,
2011 NTTIME
*kickoff_time
,
2012 NTTIME
*pass_last_set_time
,
2013 NTTIME
*pass_can_change_time
,
2014 NTTIME
*pass_must_change_time
,
2037 int len_user_name
= user_name
!= NULL
? strlen(user_name
) : 0;
2038 int len_full_name
= full_name
!= NULL
? strlen(full_name
) : 0;
2039 int len_home_dir
= home_dir
!= NULL
? strlen(home_dir
) : 0;
2040 int len_dir_drive
= dir_drive
!= NULL
? strlen(dir_drive
) : 0;
2041 int len_logon_script
= logon_script
!= NULL
? strlen(logon_script
) : 0;
2042 int len_profile_path
= profile_path
!= NULL
? strlen(profile_path
) : 0;
2043 int len_description
= description
!= NULL
? strlen(description
) : 0;
2044 int len_workstations
= workstations
!= NULL
? strlen(workstations
) : 0;
2045 int len_unknown_str
= unknown_str
!= NULL
? strlen(unknown_str
) : 0;
2046 int len_munged_dial
= munged_dial
!= NULL
? strlen(munged_dial
) : 0;
2048 usr
->logon_time
= *logon_time
;
2049 usr
->logoff_time
= *logoff_time
;
2050 usr
->kickoff_time
= *kickoff_time
;
2051 usr
->pass_last_set_time
= *pass_last_set_time
;
2052 usr
->pass_can_change_time
= *pass_can_change_time
;
2053 usr
->pass_must_change_time
= *pass_must_change_time
;
2055 make_uni_hdr(&(usr
->hdr_user_name
), len_user_name
, len_user_name
, len_user_name
!= 0);
2056 make_uni_hdr(&(usr
->hdr_full_name
), len_full_name
, len_full_name
, len_full_name
!= 0);
2057 make_uni_hdr(&(usr
->hdr_home_dir
), len_home_dir
, len_home_dir
, len_home_dir
!= 0);
2058 make_uni_hdr(&(usr
->hdr_dir_drive
), len_dir_drive
, len_dir_drive
, len_dir_drive
!= 0);
2059 make_uni_hdr(&(usr
->hdr_logon_script
), len_logon_script
, len_logon_script
, len_logon_script
!= 0);
2060 make_uni_hdr(&(usr
->hdr_profile_path
), len_profile_path
, len_profile_path
, len_profile_path
!= 0);
2061 make_uni_hdr(&(usr
->hdr_acct_desc
), len_description
, len_description
, len_description
!= 0);
2062 make_uni_hdr(&(usr
->hdr_workstations
), len_workstations
, len_workstations
, len_workstations
!= 0);
2063 make_uni_hdr(&(usr
->hdr_unknown_str
), len_unknown_str
, len_unknown_str
, len_workstations
!= 0);
2064 make_uni_hdr(&(usr
->hdr_munged_dial
), len_munged_dial
, len_munged_dial
, len_workstations
!= 0);
2066 bzero(usr
->nt_pwd
, sizeof(usr
->nt_pwd
));
2067 bzero(usr
->lm_pwd
, sizeof(usr
->lm_pwd
));
2069 usr
->user_rid
= user_rid
;
2070 usr
->group_rid
= group_rid
;
2071 usr
->acb_info
= acb_info
;
2072 usr
->unknown_3
= unknown_3
; /* 0x00ff ffff */
2074 usr
->logon_divs
= logon_divs
; /* should be 168 (hours/week) */
2075 usr
->ptr_logon_hrs
= hrs
? 1 : 0;
2076 usr
->unknown_5
= unknown_5
; /* 0x0002 0000 */
2078 bzero(usr
->padding1
, sizeof(usr
->padding1
));
2080 make_unistr2(&(usr
->uni_user_name
), user_name
, len_user_name
);
2081 make_unistr2(&(usr
->uni_full_name
), full_name
, len_full_name
);
2082 make_unistr2(&(usr
->uni_home_dir
), home_dir
, len_home_dir
);
2083 make_unistr2(&(usr
->uni_dir_drive
), dir_drive
, len_dir_drive
);
2084 make_unistr2(&(usr
->uni_logon_script
), logon_script
, len_logon_script
);
2085 make_unistr2(&(usr
->uni_profile_path
), profile_path
, len_profile_path
);
2086 make_unistr2(&(usr
->uni_acct_desc
), description
, len_description
);
2087 make_unistr2(&(usr
->uni_workstations
), workstations
, len_workstations
);
2088 make_unistr2(&(usr
->uni_unknown_str
), unknown_str
, len_unknown_str
);
2089 make_unistr2(&(usr
->uni_munged_dial
), munged_dial
, len_munged_dial
);
2091 usr
->unknown_6
= unknown_6
; /* 0x0000 04ec */
2096 memcpy(&(usr
->logon_hrs
), hrs
, sizeof(usr
->logon_hrs
));
2100 memset(&(usr
->logon_hrs
), 0xff, sizeof(usr
->logon_hrs
));
2105 /*******************************************************************
2106 reads or writes a structure.
2107 ********************************************************************/
2108 static void sam_io_user_info21(char *desc
, SAM_USER_INFO_21
*usr
, prs_struct
*ps
, int depth
)
2110 if (usr
== NULL
) return;
2112 prs_debug(ps
, depth
, desc
, "lsa_io_user_info");
2117 smb_io_time("logon_time ", &(usr
->logon_time
) , ps
, depth
);
2118 smb_io_time("logoff_time ", &(usr
->logoff_time
) , ps
, depth
);
2119 smb_io_time("kickoff_time ", &(usr
->kickoff_time
) , ps
, depth
);
2120 smb_io_time("pass_last_set_time ", &(usr
->pass_last_set_time
) , ps
, depth
);
2121 smb_io_time("pass_can_change_time ", &(usr
->pass_can_change_time
) , ps
, depth
);
2122 smb_io_time("pass_must_change_time", &(usr
->pass_must_change_time
), ps
, depth
);
2124 smb_io_unihdr("hdr_user_name ", &(usr
->hdr_user_name
) , ps
, depth
); /* username unicode string header */
2125 smb_io_unihdr("hdr_full_name ", &(usr
->hdr_full_name
) , ps
, depth
); /* user's full name unicode string header */
2126 smb_io_unihdr("hdr_home_dir ", &(usr
->hdr_home_dir
) , ps
, depth
); /* home directory unicode string header */
2127 smb_io_unihdr("hdr_dir_drive ", &(usr
->hdr_dir_drive
) , ps
, depth
); /* home directory drive */
2128 smb_io_unihdr("hdr_logon_script", &(usr
->hdr_logon_script
), ps
, depth
); /* logon script unicode string header */
2129 smb_io_unihdr("hdr_profile_path", &(usr
->hdr_profile_path
), ps
, depth
); /* profile path unicode string header */
2130 smb_io_unihdr("hdr_acct_desc ", &(usr
->hdr_acct_desc
) , ps
, depth
); /* account description */
2131 smb_io_unihdr("hdr_workstations", &(usr
->hdr_workstations
), ps
, depth
); /* workstations user can log on from */
2132 smb_io_unihdr("hdr_unknown_str ", &(usr
->hdr_unknown_str
), ps
, depth
); /* unknown string */
2133 smb_io_unihdr("hdr_munged_dial ", &(usr
->hdr_munged_dial
), ps
, depth
); /* workstations user can log on from */
2135 prs_uint8s (False
, "lm_pwd ", ps
, depth
, usr
->lm_pwd
, sizeof(usr
->lm_pwd
));
2136 prs_uint8s (False
, "nt_pwd ", ps
, depth
, usr
->nt_pwd
, sizeof(usr
->nt_pwd
));
2138 prs_uint32("user_rid ", ps
, depth
, &(usr
->user_rid
)); /* User ID */
2139 prs_uint32("group_rid ", ps
, depth
, &(usr
->group_rid
)); /* Group ID */
2140 prs_uint16("acb_info ", ps
, depth
, &(usr
->acb_info
)); /* Group ID */
2143 prs_uint32("unknown_3 ", ps
, depth
, &(usr
->unknown_3
));
2144 prs_uint16("logon_divs ", ps
, depth
, &(usr
->logon_divs
)); /* logon divisions per week */
2146 prs_uint32("ptr_logon_hrs ", ps
, depth
, &(usr
->ptr_logon_hrs
));
2147 prs_uint32("unknown_5 ", ps
, depth
, &(usr
->unknown_5
));
2149 prs_uint8s (False
, "padding1 ", ps
, depth
, usr
->padding1
, sizeof(usr
->padding1
));
2151 /* here begins pointed-to data */
2153 smb_io_unistr2("uni_user_name ", &(usr
->uni_user_name
) , usr
->hdr_user_name
.buffer
, ps
, depth
); /* username unicode string */
2154 smb_io_unistr2("uni_full_name ", &(usr
->uni_full_name
) , usr
->hdr_full_name
.buffer
, ps
, depth
); /* user's full name unicode string */
2155 smb_io_unistr2("uni_home_dir ", &(usr
->uni_home_dir
) , usr
->hdr_home_dir
.buffer
, ps
, depth
); /* home directory unicode string */
2156 smb_io_unistr2("uni_dir_drive ", &(usr
->uni_dir_drive
) , usr
->hdr_dir_drive
.buffer
, ps
, depth
); /* home directory drive unicode string */
2157 smb_io_unistr2("uni_logon_script", &(usr
->uni_logon_script
), usr
->hdr_logon_script
.buffer
, ps
, depth
); /* logon script unicode string */
2158 smb_io_unistr2("uni_profile_path", &(usr
->uni_profile_path
), usr
->hdr_profile_path
.buffer
, ps
, depth
); /* profile path unicode string */
2159 smb_io_unistr2("uni_acct_desc ", &(usr
->uni_acct_desc
), usr
->hdr_acct_desc
.buffer
, ps
, depth
); /* user description unicode string */
2160 smb_io_unistr2("uni_workstations", &(usr
->uni_workstations
), usr
->hdr_workstations
.buffer
, ps
, depth
); /* worksations user can log on from */
2161 smb_io_unistr2("uni_unknown_str ", &(usr
->uni_unknown_str
), usr
->hdr_unknown_str
.buffer
, ps
, depth
); /* unknown string */
2162 smb_io_unistr2("uni_munged_dial ", &(usr
->uni_munged_dial
), usr
->hdr_munged_dial
.buffer
, ps
, depth
); /* worksations user can log on from */
2164 prs_uint32("unknown_6 ", ps
, depth
, &(usr
->unknown_6
));
2165 prs_uint32("padding4 ", ps
, depth
, &(usr
->padding4
));
2167 if (usr
->ptr_logon_hrs
)
2169 sam_io_logon_hrs("logon_hrs", &(usr
->logon_hrs
) , ps
, depth
);
2175 /*******************************************************************
2176 makes a SAMR_R_QUERY_USERINFO structure.
2177 ********************************************************************/
2178 void make_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO
*r_u
,
2179 uint16 switch_value
, void *info
, uint32 status
)
2182 if (r_u
== NULL
|| info
== NULL
) return;
2184 DEBUG(5,("make_samr_r_query_userinfo\n"));
2187 r_u
->switch_value
= 0;
2191 r_u
->switch_value
= switch_value
;
2193 switch (switch_value
)
2198 r_u
->info
.id10
= (SAM_USER_INFO_10
*)info
;
2206 r_u
->info
.id11
= (SAM_USER_INFO_11
*)info
;
2214 r_u
->info
.id21
= (SAM_USER_INFO_21
*)info
;
2221 DEBUG(4,("make_samr_r_query_aliasinfo: unsupported switch level\n"));
2227 r_u
->status
= status
; /* return status */
2230 /*******************************************************************
2231 reads or writes a structure.
2232 ********************************************************************/
2233 void samr_io_r_query_userinfo(char *desc
, SAMR_R_QUERY_USERINFO
*r_u
, prs_struct
*ps
, int depth
)
2235 if (r_u
== NULL
) return;
2237 prs_debug(ps
, depth
, desc
, "samr_io_r_query_userinfo");
2242 prs_uint32("ptr ", ps
, depth
, &(r_u
->ptr
));
2243 prs_uint16("switch_value", ps
, depth
, &(r_u
->switch_value
));
2246 if (r_u
->ptr
!= 0 && r_u
->switch_value
!= 0)
2248 switch (r_u
->switch_value
)
2253 if (r_u->info.id10 != NULL)
2255 sam_io_user_info10("", r_u->info.id10, ps, depth);
2259 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2266 if (r_u->info.id11 != NULL)
2268 sam_io_user_info11("", r_u->info.id11, ps, depth);
2272 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2280 if (r_u
->info
.id21
!= NULL
)
2282 sam_io_user_info21("", r_u
->info
.id21
, ps
, depth
);
2286 DEBUG(2,("samr_io_r_query_userinfo: info pointer not initialised\n"));
2293 DEBUG(2,("samr_io_r_query_userinfo: unknown switch level\n"));
2300 prs_uint32("status", ps
, depth
, &(r_u
->status
));
2303 /*******************************************************************
2304 reads or writes a structure.
2305 ********************************************************************/
2306 void samr_io_q_unknown_32(char *desc
, SAMR_Q_UNKNOWN_32
*q_u
, prs_struct
*ps
, int depth
)
2308 if (q_u
== NULL
) return;
2310 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_32");
2315 smb_io_pol_hnd("pol", &(q_u
->pol
), ps
, depth
);
2318 smb_io_unihdr ("", &(q_u
->hdr_mach_acct
), ps
, depth
);
2319 smb_io_unistr2("", &(q_u
->uni_mach_acct
), q_u
->hdr_mach_acct
.buffer
, ps
, depth
);
2323 prs_uint32("acct_ctrl", ps
, depth
, &(q_u
->acct_ctrl
));
2324 prs_uint16("unknown_1", ps
, depth
, &(q_u
->unknown_1
));
2325 prs_uint16("unknown_2", ps
, depth
, &(q_u
->unknown_2
));
2328 /*******************************************************************
2329 reads or writes a structure.
2330 ********************************************************************/
2331 void samr_io_r_unknown_32(char *desc
, SAMR_R_UNKNOWN_32
*r_u
, prs_struct
*ps
, int depth
)
2333 if (r_u
== NULL
) return;
2335 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_32");
2340 smb_io_pol_hnd("pol", &(r_u
->pol
), ps
, depth
);
2343 prs_uint32("status", ps
, depth
, &(r_u
->status
));
2347 /*******************************************************************
2348 makes a SAMR_Q_CONNECT structure.
2349 ********************************************************************/
2350 void make_samr_q_connect(SAMR_Q_CONNECT
*q_u
,
2351 char *srv_name
, uint32 unknown_0
)
2353 int len_srv_name
= strlen(srv_name
);
2355 if (q_u
== NULL
) return;
2357 DEBUG(5,("make_q_connect\n"));
2359 /* make PDC server name \\server */
2360 make_unistr2(&(q_u
->uni_srv_name
), srv_name
, len_srv_name
);
2362 /* example values: 0x0000 0002 */
2363 q_u
->unknown_0
= unknown_0
;
2367 /*******************************************************************
2368 reads or writes a structure.
2369 ********************************************************************/
2370 void samr_io_q_connect(char *desc
, SAMR_Q_CONNECT
*q_u
, prs_struct
*ps
, int depth
)
2372 if (q_u
== NULL
) return;
2374 prs_debug(ps
, depth
, desc
, "samr_io_q_connect");
2379 prs_uint32("ptr_srv_name", ps
, depth
, &(q_u
->ptr_srv_name
));
2380 smb_io_unistr2("", &(q_u
->uni_srv_name
), q_u
->ptr_srv_name
, ps
, depth
);
2384 prs_uint32("unknown_0 ", ps
, depth
, &(q_u
->unknown_0
));
2387 /*******************************************************************
2388 reads or writes a structure.
2389 ********************************************************************/
2390 void samr_io_r_connect(char *desc
, SAMR_R_CONNECT
*r_u
, prs_struct
*ps
, int depth
)
2392 if (r_u
== NULL
) return;
2394 prs_debug(ps
, depth
, desc
, "samr_io_r_connect");
2399 smb_io_pol_hnd("connect_pol", &(r_u
->connect_pol
), ps
, depth
);
2402 prs_uint32("status", ps
, depth
, &(r_u
->status
));
2405 /*******************************************************************
2406 makes a SAMR_Q_OPEN_ALIAS structure.
2407 ********************************************************************/
2408 void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS
*q_u
,
2409 uint32 unknown_0
, uint32 rid
)
2411 if (q_u
== NULL
) return;
2413 DEBUG(5,("make_q_open_alias\n"));
2415 /* example values: 0x0000 0008 */
2416 q_u
->unknown_0
= unknown_0
;
2418 q_u
->rid_alias
= rid
;
2421 /*******************************************************************
2422 reads or writes a structure.
2423 ********************************************************************/
2424 void samr_io_q_open_alias(char *desc
, SAMR_Q_OPEN_ALIAS
*q_u
, prs_struct
*ps
, int depth
)
2426 if (q_u
== NULL
) return;
2428 prs_debug(ps
, depth
, desc
, "samr_io_q_open_alias");
2433 prs_uint32("unknown_0", ps
, depth
, &(q_u
->unknown_0
));
2434 prs_uint32("rid_alias", ps
, depth
, &(q_u
->rid_alias
));
2437 /*******************************************************************
2438 reads or writes a structure.
2439 ********************************************************************/
2440 void samr_io_r_open_alias(char *desc
, SAMR_R_OPEN_ALIAS
*r_u
, prs_struct
*ps
, int depth
)
2442 if (r_u
== NULL
) return;
2444 prs_debug(ps
, depth
, desc
, "samr_io_r_open_alias");
2449 smb_io_pol_hnd("pol", &(r_u
->pol
), ps
, depth
);
2452 prs_uint32("status", ps
, depth
, &(r_u
->status
));
2457 /* SAMR_Q_CHGPASSWD_USER */
2458 typedef struct q_samr_chgpasswd_user_info
2462 UNIHDR hdr_server
; /* server name unicode header */
2463 UNISTR2 uni_server
; /* server name unicode string */
2465 UNIHDR hdr_user_name
; /* username unicode string header */
2466 UNISTR2 uni_user_name
; /* username unicode string */
2468 SAMR_ENC_PASSWD nt_newpass
;
2469 SAMR_ENC_HASH nt_oldhash
;
2471 uint32 unknown_1
; /* seems to always contain 0001 */
2473 SAMR_ENC_PASSWD lm_newpass
;
2474 SAMR_ENC_HASH lm_oldhash
;
2476 } SAMR_Q_CHGPASSWD_USER
;
2478 /* SAMR_R_CHGPASSWD_USER */
2479 typedef struct r_samr_chgpasswd_user_info
2481 uint32 result
; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
2483 } SAMR_R_CHGPASSWD_USER
;
2488 /*******************************************************************
2489 makes a SAMR_Q_UNKNOWN_38 structure.
2490 ********************************************************************/
2491 void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38
*q_u
, char *srv_name
)
2493 int len_srv_name
= strlen(srv_name
);
2495 if (q_u
== NULL
) return;
2497 DEBUG(5,("make_q_unknown_38\n"));
2500 make_uni_hdr(&(q_u
->hdr_srv_name
), len_srv_name
, len_srv_name
, len_srv_name
!= 0);
2501 make_unistr2(&(q_u
->uni_srv_name
), srv_name
, len_srv_name
);
2505 /*******************************************************************
2506 reads or writes a structure.
2507 ********************************************************************/
2508 void samr_io_q_unknown_38(char *desc
, SAMR_Q_UNKNOWN_38
*q_u
, prs_struct
*ps
, int depth
)
2510 if (q_u
== NULL
) return;
2512 prs_debug(ps
, depth
, desc
, "samr_io_q_unknown_38");
2517 prs_uint32("ptr", ps
, depth
, &(q_u
->ptr
));
2520 smb_io_unihdr ("", &(q_u
->hdr_srv_name
), ps
, depth
);
2521 smb_io_unistr2("", &(q_u
->uni_srv_name
), q_u
->hdr_srv_name
.buffer
, ps
, depth
);
2525 /*******************************************************************
2526 makes a SAMR_R_UNKNOWN_38 structure.
2527 ********************************************************************/
2528 void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38
*r_u
,
2529 uint16 level
, uint32 status
)
2531 if (r_u
== NULL
) return;
2533 DEBUG(5,("make_r_unknown_38\n"));
2535 r_u
->level
.value
= level
;
2537 r_u
->status
= status
;
2540 /*******************************************************************
2541 reads or writes a structure.
2542 ********************************************************************/
2543 void samr_io_r_unknown_38(char *desc
, SAMR_R_UNKNOWN_38
*r_u
, prs_struct
*ps
, int depth
)
2545 if (r_u
== NULL
) return;
2547 prs_debug(ps
, depth
, desc
, "samr_io_r_unknown_38");
2552 smb_io_lookup_level("level ", &(r_u
->level
), ps
, depth
);
2553 prs_uint32("ptr_0 ", ps
, depth
, &(r_u
->ptr_0
));
2554 prs_uint32("status", ps
, depth
, &(r_u
->status
));
2557 /*******************************************************************
2558 reads or writes a SAMR_ENC_PASSWD structure.
2559 ********************************************************************/
2560 void samr_io_enc_passwd(char *desc
, SAMR_ENC_PASSWD
*pwd
, prs_struct
*ps
, int depth
)
2562 if (pwd
== NULL
) return;
2564 prs_debug(ps
, depth
, desc
, "samr_io_enc_passwd");
2569 prs_uint32("ptr", ps
, depth
, &(pwd
->ptr
));
2570 prs_uint8s(False
, "pwd", ps
, depth
, pwd
->pass
, sizeof(pwd
->pass
));
2573 /*******************************************************************
2574 reads or writes a SAMR_ENC_HASH structure.
2575 ********************************************************************/
2576 void samr_io_enc_hash(char *desc
, SAMR_ENC_HASH
*hsh
, prs_struct
*ps
, int depth
)
2578 if (hsh
== NULL
) return;
2580 prs_debug(ps
, depth
, desc
, "samr_io_enc_hash");
2585 prs_uint32("ptr ", ps
, depth
, &(hsh
->ptr
));
2586 prs_uint8s(False
, "hash", ps
, depth
, hsh
->hash
, sizeof(hsh
->hash
));
2590 /* SAMR_Q_CHGPASSWD_USER */
2591 typedef struct q_samr_chgpasswd_user_info
2595 UNIHDR hdr_server
; /* server name unicode header */
2596 UNISTR2 uni_server
; /* server name unicode string */
2598 UNIHDR hdr_user_name
; /* username unicode string header */
2599 UNISTR2 uni_user_name
; /* username unicode string */
2601 SAMR_ENC_PASSWD nt_newpass
;
2602 SAMR_ENC_HASH nt_oldhash
;
2604 uint32 unknown_1
; /* seems to always contain 0001 */
2606 SAMR_ENC_PASSWD lm_newpass
;
2607 SAMR_ENC_HASH lm_oldhash
;
2609 } SAMR_Q_CHGPASSWD_USER
;
2611 /* SAMR_R_CHGPASSWD_USER */
2612 typedef struct r_samr_chgpasswd_user_info
2614 uint32 result
; /* 0 == OK, C000006A (NT_STATUS_WRONG_PASSWORD) */
2616 } SAMR_R_CHGPASSWD_USER
;
2621 /*******************************************************************
2622 makes a SAMR_Q_UNKNOWN_12 structure.
2623 ********************************************************************/
2624 void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12
*q_u
,
2625 POLICY_HND
*pol
, uint32 rid
,
2626 uint32 num_gids
, uint32
*gid
)
2629 if (q_u
== NULL
) return;
2631 DEBUG(5,("make_samr_r_unknwon_12\n"));
2633 memcpy(&(q_u
->pol
), pol
, sizeof(*pol
));
2635 q_u
->num_gids1
= num_gids
;
2638 q_u
->num_gids2
= num_gids
;
2640 for (i
= 0; i
< num_gids
; i
++)
2642 q_u
->gid
[i
] = gid
[i
];
2649 /*******************************************************************
2650 makes a SAMR_Q_UNKNOWN_21 structure.
2651 ********************************************************************/
2652 void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21
*q_c
,
2653 POLICY_HND
*hnd
, uint16 unk_1
, uint16 unk_2
)
2655 if (q_c
== NULL
|| hnd
== NULL
) return;
2657 DEBUG(5,("make_samr_q_unknown_21\n"));
2659 memcpy(&(q_c
->group_pol
), hnd
, sizeof(q_c
->group_pol
));
2660 q_c
->unknown_1
= unk_1
;
2661 q_c
->unknown_2
= unk_2
;
2665 /*******************************************************************
2666 makes a SAMR_Q_UNKNOWN_13 structure.
2667 ********************************************************************/
2668 void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13
*q_c
,
2669 POLICY_HND
*hnd
, uint16 unk_1
, uint16 unk_2
)
2671 if (q_c
== NULL
|| hnd
== NULL
) return;
2673 DEBUG(5,("make_samr_q_unknown_13\n"));
2675 memcpy(&(q_c
->alias_pol
), hnd
, sizeof(q_c
->alias_pol
));
2676 q_c
->unknown_1
= unk_1
;
2677 q_c
->unknown_2
= unk_2
;