2 Unix SMB/Netbios implementation.
4 Samba utility functions
5 Copyright (C) Andrew Tridgell 1992-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /****************************************************************************
27 ****************************************************************************/
28 void display_alias_members(FILE *out_hnd, enum action_type action,
29 uint32 num_mem, char *const *const sid_mem,
38 report(out_hnd, "\tNo Alias Members\n");
42 report(out_hnd, "\tAlias Members:\n");
43 report(out_hnd, "\t-------------\n");
47 case ACTION_ENUMERATE:
51 for (i = 0; i < num_mem; i++)
53 if (sid_mem[i] != NULL)
55 report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
57 get_sid_name_use_str(type[i]));
65 report(out_hnd, "\n");
72 /****************************************************************************
73 display alias rid info
74 ****************************************************************************/
75 void display_alias_rid_info(FILE *out_hnd, enum action_type action,
77 uint32 num_rids, uint32 *const rid)
84 sid_to_string(sid_str, sid);
87 report(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
91 report(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
92 report(out_hnd, "\t----------\n");
96 case ACTION_ENUMERATE:
100 for (i = 0; i < num_rids; i++)
102 report(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
109 report(out_hnd, "\n");
115 /****************************************************************************
116 display group members
117 ****************************************************************************/
118 void display_group_members(FILE *out_hnd, enum action_type action,
119 uint32 num_mem, char *const *const name, uint32 *const type)
127 report(out_hnd, "\tNo Members\n");
131 report(out_hnd, "\tMembers:\n");
132 report(out_hnd, "\t-------\n");
136 case ACTION_ENUMERATE:
140 for (i = 0; i < num_mem; i++)
142 report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
143 name[i], get_sid_name_use_str(type[i]));
150 report(out_hnd, "\n");
157 /****************************************************************************
159 ****************************************************************************/
160 void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *const info1)
169 case ACTION_ENUMERATE:
173 unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1);
174 report(out_hnd, "\tGroup Name:\t%s\n", temp);
175 unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1);
176 report(out_hnd, "\tDescription:\t%s\n", temp);
177 report(out_hnd, "\tunk1:%d\n", info1->unknown_1);
178 report(out_hnd, "\tNum Members:%d\n", info1->num_members);
188 /****************************************************************************
190 ****************************************************************************/
191 void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *const info4)
200 case ACTION_ENUMERATE:
204 unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1);
205 report(out_hnd, "\tGroup Description:%s\n",
216 /****************************************************************************
217 display sam sync structure
218 ****************************************************************************/
219 void display_group_info_ctr(FILE *out_hnd, enum action_type action,
220 GROUP_INFO_CTR *const ctr)
226 report(out_hnd, "\tSAM Group Info\n");
227 report(out_hnd, "\t--------------\n");
231 case ACTION_ENUMERATE:
233 switch (ctr->switch_value1)
237 display_group_info1(out_hnd, ACTION_HEADER , &ctr->group.info1);
238 display_group_info1(out_hnd, ACTION_ENUMERATE, &ctr->group.info1);
239 display_group_info1(out_hnd, ACTION_FOOTER , &ctr->group.info1);
244 display_group_info4(out_hnd, ACTION_HEADER , &ctr->group.info4);
245 display_group_info4(out_hnd, ACTION_ENUMERATE, &ctr->group.info4);
246 display_group_info4(out_hnd, ACTION_FOOTER , &ctr->group.info4);
254 report(out_hnd, "\n");
260 /****************************************************************************
261 display group rid info
262 ****************************************************************************/
263 void display_group_rid_info(FILE *out_hnd, enum action_type action,
264 uint32 num_gids, DOM_GID *const gid)
272 report(out_hnd, "\tNo Groups\n");
276 report(out_hnd, "\tGroup Info\n");
277 report(out_hnd, "\t----------\n");
281 case ACTION_ENUMERATE:
285 for (i = 0; i < num_gids; i++)
287 report(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
288 gid[i].g_rid, gid[i].attr);
295 report(out_hnd, "\n");
302 /****************************************************************************
303 display alias name info
304 ****************************************************************************/
305 void display_alias_name_info(FILE *out_hnd, enum action_type action,
306 uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs)
312 if (num_aliases == 0)
314 report(out_hnd, "\tNo Aliases\n");
318 report(out_hnd, "\tAlias Names\n");
319 report(out_hnd, "\t----------- \n");
323 case ACTION_ENUMERATE:
327 for (i = 0; i < num_aliases; i++)
329 report(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
330 alias_name[i], num_als_usrs[i]);
337 report(out_hnd, "\n");
343 /****************************************************************************
345 ****************************************************************************/
346 void display_alias_info3(FILE *out_hnd, enum action_type action, ALIAS_INFO3 *const info3)
355 case ACTION_ENUMERATE:
359 unistr2_to_ascii(temp, &info3->uni_acct_desc, sizeof(temp)-1);
360 report(out_hnd, "\tDescription:\t%s\n", temp);
370 /****************************************************************************
371 display sam sync structure
372 ****************************************************************************/
373 void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
374 ALIAS_INFO_CTR *const ctr)
380 report(out_hnd, "\tSAM Group Info\n");
381 report(out_hnd, "\t--------------\n");
385 case ACTION_ENUMERATE:
387 switch (ctr->switch_value1)
391 display_alias_info3(out_hnd, ACTION_HEADER , &ctr->alias.info3);
392 display_alias_info3(out_hnd, ACTION_ENUMERATE, &ctr->alias.info3);
393 display_alias_info3(out_hnd, ACTION_FOOTER , &ctr->alias.info3);
401 report(out_hnd, "\n");
408 /****************************************************************************
409 display sam_user_info_21 structure
410 ****************************************************************************/
411 void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr)
417 report(out_hnd, "\tUser Info, Level 0x15\n");
418 report(out_hnd, "\t---------------------\n");
422 case ACTION_ENUMERATE:
426 unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp)-1);
427 report(out_hnd, "\t\tUser Name :\t%s\n", temp);
429 unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp)-1);
430 report(out_hnd, "\t\tFull Name :\t%s\n", temp);
432 unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp)-1);
433 report(out_hnd, "\t\tHome Drive :\t%s\n", temp);
435 unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp)-1);
436 report(out_hnd, "\t\tDir Drive :\t%s\n", temp);
438 unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp)-1);
439 report(out_hnd, "\t\tProfile Path:\t%s\n", temp);
441 unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp)-1);
442 report(out_hnd, "\t\tLogon Script:\t%s\n", temp);
444 unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp)-1);
445 report(out_hnd, "\t\tDescription :\t%s\n", temp);
447 unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1);
448 report(out_hnd, "\t\tWorkstations:\t%s\n", temp);
450 unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1);
451 report(out_hnd, "\t\tUnknown Str :\t%s\n", temp);
453 unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1);
454 report(out_hnd, "\t\tRemote Dial :\t%s\n", temp);
456 report(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
457 report(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
458 report(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
459 report(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
460 report(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
461 report(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
463 report(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
465 report(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
466 report(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
467 report(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
469 report(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
470 report(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
471 report(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
473 report(out_hnd, "\t\tpadding1[0..7]...\n");
475 if (usr->ptr_logon_hrs)
477 report(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
484 report(out_hnd, "\n");
491 /****************************************************************************
492 display sam sync structure
493 ****************************************************************************/
494 void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
495 SAM_UNK_INFO_2 *const info2)
503 case ACTION_ENUMERATE:
506 unistr2_to_ascii(name, &(info2->uni_domain), sizeof(name)-1);
507 report(out_hnd, "Domain:\t%s\n", name);
509 unistr2_to_ascii(name, &(info2->uni_server), sizeof(name)-1);
510 report(out_hnd, "Server:\t%s\n", name);
512 report(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs);
513 report(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps);
514 report(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps);
516 report(out_hnd, "Sequence No:\t%d\n", info2->seq_num);
518 report(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0);
519 report(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1);
520 report(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2);
521 report(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3);
522 report(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4);
523 report(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5);
524 report(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6);
530 report(out_hnd, "\n");
536 /****************************************************************************
537 display sam sync structure
538 ****************************************************************************/
539 void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
540 uint32 switch_value, SAM_UNK_CTR *const ctr)
546 report(out_hnd, "\tSAM Domain Info\n");
547 report(out_hnd, "\t---------------\n");
551 case ACTION_ENUMERATE:
553 switch (switch_value)
557 display_sam_unk_info_2(out_hnd, ACTION_HEADER , &ctr->info.inf2);
558 display_sam_unk_info_2(out_hnd, ACTION_ENUMERATE, &ctr->info.inf2);
559 display_sam_unk_info_2(out_hnd, ACTION_FOOTER , &ctr->info.inf2);
567 report(out_hnd, "\n");
573 /****************************************************************************
574 sam info level 1 display function
575 ****************************************************************************/
576 void display_sam_info_1(FILE *out_hnd, enum action_type action,
577 SAM_ENTRY1 *const e1, SAM_STR1 *const s1)
588 report(out_hnd, "Sam Level 1:\n");
592 case ACTION_ENUMERATE:
596 report(out_hnd, "\tIndex:\t%d\n", e1->user_idx);
597 report(out_hnd, "\tRID:\t0x%x\n", e1->rid_user);
598 report(out_hnd, "\tACB:\t%s\n",
599 pwdb_encode_acct_ctrl(e1->acb_info,
600 NEW_PW_FORMAT_SPACE_PADDED_LEN));
602 unistr_to_ascii(tmp, s1->uni_acct_name.buffer, sizeof(tmp)-1);
603 report(out_hnd, "\tAccount Name:\t%s\n", tmp);
604 unistr_to_ascii(tmp, s1->uni_full_name.buffer, sizeof(tmp)-1);
605 report(out_hnd, "\tFull Name:\t%s\n", tmp);
606 unistr_to_ascii(tmp, s1->uni_acct_desc.buffer, sizeof(tmp)-1);
607 report(out_hnd, "\tUser Description:\t%s\n", tmp);
613 report(out_hnd, "\n");
620 /****************************************************************************
621 connection info level 1 container display function
622 ****************************************************************************/
623 void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action,
624 uint32 count, SAM_DISPINFO_1 *const ctr)
628 report(out_hnd, "display_sam_info_1_ctr: unavailable due to an internal error\n");
638 case ACTION_ENUMERATE:
642 for (i = 0; i < count; i++)
644 display_sam_info_1(out_hnd, ACTION_HEADER , &ctr->sam[i], &ctr->str[i]);
645 display_sam_info_1(out_hnd, ACTION_ENUMERATE, &ctr->sam[i], &ctr->str[i]);
646 display_sam_info_1(out_hnd, ACTION_FOOTER , &ctr->sam[i], &ctr->str[i]);
657 /****************************************************************************
658 connection info container display function
659 ****************************************************************************/
660 void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
661 uint16 level, uint32 count,
662 SAM_DISPINFO_CTR *const ctr)
666 report(out_hnd, "display_sam_info_ctr: unavailable due to an internal error\n");
674 display_sam_info_1_ctr(out_hnd, action,
675 count, ctr->sam.info1);
680 report(out_hnd, "display_sam_info_ctr: Unknown Info Level\n");