/usr/bin/dbgen is in 389-ds-base 1.3.4.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 | #!/usr/bin/env perl
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# END COPYRIGHT BLOCK
#------------------------------------------------------------------------
## NAME
## dbgen
##
## DESCRIPTION
## Random LDIF database creator, specially modified from DirectoryMark
## Original weibe done by David Boreham in C++.
##
## Fixed random seed generator for uniqueness
## Updated function MakeRandomName:
## Changed default RDN type to UID and
## added -c option to enable CN type naming
## Added personal_title and generationQualifier data
## Added function to create randon SSN's if needed
## Updated generation output to show total entries created regardless of -v option
## Changed userPassword to be the same as UID.
## Now, dc style namingcontext can be used.
#------------------------------------------------------------------------
use Getopt::Long;
sub PrintUsage {
print STDERR
"Usage: $0 [options] -o output_file -n number\n",
"\t Where options are:\n",
"\t -o filename output file\n",
"\t -s suffix, default is 'dc=example,dc=com'\n",
"\t -c for CN naming style RDN's : default is UID\n",
"\t -z extra objectclasses to add to base used in -O - should be AUXILIARY or SUB\n",
"\t -j 0 pad numbers used in RDN to this many digits e.g. with 4 1 becomes 0001 (ignored unless -b is specified)\n",
"\t -m naming attribute for RDN\n",
"\t -n number of entries to generate\n",
"\t -b beginning number for RDN (ending number is -n value + beginning number)\n",
"\t -p for organizationalPersons, default is inetOrgPerson\n",
"\t -r seed---seed number for random number generator\n",
"\t -g print extra entries for orgchart\n",
"\t -x suppress printing pre amble\n",
"\t -y suppress printing organizational units\n",
"\t -l location of directory containing data files, default is /usr/share/dirsrv/data\n",
"\t -u add groups containing uniquemembers;\n\t generate a group for every 100 user entries created that contains the 100 members.\n",
"\t -v verbose\n",
"\t -q quiet\n",
"\n";
exit;
}
&PrintUsage if ($#ARGV == -1);
@EmployeeTypes = ("Manager", "Normal", "Peon");
@personal_title = ("Mr",
"Mrs",
"Miss",
"Senior",
"Junior",
"III",
"Cool");
@generationQ = ("I",
"II",
"III",
"IV",
"V",
"VI",
"VII");
@title_ranks = ("Senior",
"Master",
"Associate",
"Junior",
"Chief",
"Supreme",
"Elite");
@positions =("Accountant",
"Admin",
"Architect",
"Assistant",
"Artist",
"Consultant",
"Czar",
"Dictator",
"Director",
"Diva",
"Dreamer",
"Evangelist",
"Engineer",
"Figurehead",
"Fellow",
"Grunt",
"Guru",
"Janitor",
"Madonna",
"Manager",
"Pinhead",
"President",
"Punk",
"Sales Rep",
"Stooge",
"Visionary",
"Vice President",
"Writer",
"Warrior",
"Yahoo");
@localities = ("Mountain View", "Redmond", "Redwood Shores", "Armonk",
"Cambridge", "Santa Clara", "Sunnyvale", "Alameda",
"Cupertino", "Menlo Park", "Palo Alto", "Orem",
"San Jose", "San Francisco", "Milpitas", "Hartford", "Windsor",
"Boston", "New York", "Detroit", "Dallas", "Denver");
@area_codes = ("303", "415", "408", "510", "804", "818",
"213", "206", "714");
my $mycert =
"usercertificate;binary:: MIIBvjCCASegAwIBAgIBAjANBgkqhkiG9w0BAQQFADAnMQ8wDQYD\n VQQDEwZjb25maWcxFDASBgNVBAMTC01NUiBDQSBDZXJ0MB4XDTAxMDQwNTE1NTEwNloXDTExMDcw\n NTE1NTEwNlowIzELMAkGA1UEChMCZnIxFDASBgNVBAMTC01NUiBTMSBDZXJ0MIGfMA0GCSqGSIb3\n DQEBAQUAA4GNADCBiQKBgQDNlmsKEaPD+o3mAUwmW4E40MPs7aiui1YhorST3KzVngMqe5PbObUH\n MeJN7CLbq9SjXvdB3y2AoVl/s5UkgGz8krmJ8ELfUCU95AQls321RwBdLRjioiQ3MGJiFjxwYRIV\n j1CUTuX1y8dC7BWvZ1/EB0yv0QDtp2oVMUeoK9/9sQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBADev\n hxY6QyDMK3Mnr7vLGe/HWEZCObF+qEo2zWScGH0Q+dAmhkCCkNeHJoqGN4NWjTdnBcGaAr5Y85k1\n o/vOAMBsZePbYx4SrywL0b/OkOmQX+mQwieC2IQzvaBRyaNMh309vrF4w5kExReKfjR/gXpHiWQz\n GSxC5LeQG4k3IP34\n";
%ceo =
(
"uid" => "ceo",
"givenname" => "John",
"sn" => "Budd",
"title" => "CEO",
"cn" => "",
"dn" => ""
);
%ep0 =
(
"uid" => "exec_president0",
"givenname" => "Paul",
"sn" => "Grant",
"title" => "Exective President",
"cn" => "",
"dn" => ""
);
%ep1 =
(
"uid" => "exec_president1",
"givenname" => "Jill",
"sn" => "Peterson",
"title" => "Exective President",
"cn" => "",
"dn" => ""
);
@exective_presidents = (\%ep0, \%ep1);
%p0 =
(
"uid" => "president0",
"givenname" => "Pete",
"sn" => "Dunne",
"title" => "President",
"cn" => "",
"dn" => ""
);
%p1 =
(
"uid" => "president1",
"givenname" => "Jannet",
"sn" => "Keys",
"title" => "President",
"cn" => "",
"dn" => ""
);
%p2 =
(
"uid" => "president2",
"givenname" => "Kathy",
"sn" => "Yang",
"title" => "President",
"cn" => "",
"dn" => ""
);
%p3 =
(
"uid" => "president3",
"givenname" => "Anne",
"sn" => "Meissner",
"title" => "President",
"cn" => "",
"dn" => ""
);
@presidents = (\%p0, \%p1, \%p2, \%p3);
%vp0 =
(
"uid" => "vice_president0",
"givenname" => "Jack",
"sn" => "Cho",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
%vp1 =
(
"uid" => "vice_president1",
"givenname" => "Diane",
"sn" => "Smith",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
%vp2 =
(
"uid" => "vice_president2",
"givenname" => "Alex",
"sn" => "Merrells",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
%vp3 =
(
"uid" => "vice_president3",
"givenname" => "Yumi",
"sn" => "Mehta",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
%vp4 =
(
"uid" => "vice_president4",
"givenname" => "Michael",
"sn" => "Natkovich",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
%vp5 =
(
"uid" => "vice_president5",
"givenname" => "Keith",
"sn" => "Lucus",
"title" => "Vice President",
"cn" => "",
"dn" => ""
);
@vice_presidents = (\%vp0, \%vp1, \%vp2, \%vp3, \%vp4, \%vp5);
%d0 =
(
"uid" => "director0",
"givenname" => "Chris",
"sn" => "Harrison",
"title" => "Director",
"cn" => "",
"dn" => ""
),
%d1 =
(
"uid" => "director1",
"givenname" => "Jane",
"sn" => "Baker",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d2 =
(
"uid" => "director2",
"givenname" => "Ed",
"sn" => "Becket",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d3 =
(
"uid" => "director3",
"givenname" => "Will",
"sn" => "Stevenson",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d4 =
(
"uid" => "director4",
"givenname" => "Kieran",
"sn" => "Beckham",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d5 =
(
"uid" => "director5",
"givenname" => "Greg",
"sn" => "Emerson",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d6 =
(
"uid" => "director6",
"givenname" => "Ian",
"sn" => "Parker",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d7 =
(
"uid" => "director7",
"givenname" => "Liem",
"sn" => "Olson",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d8 =
(
"uid" => "director8",
"givenname" => "George",
"sn" => "Cruise",
"title" => "Director",
"cn" => "",
"dn" => ""
);
%d9 =
(
"uid" => "director9",
"givenname" => "Yoshiko",
"sn" => "Tucker",
"title" => "Director",
"cn" => "",
"dn" => ""
);
@directors = (\%d0, \%d1, \%d2, \%d3, \%d4, \%d5, \%d6, \%d7, \%d8, \%d9);
%m0 =
(
"uid" => "manager0",
"givenname" => "Teresa",
"sn" => "Chan",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m1 =
(
"uid" => "manager1",
"givenname" => "Tom",
"sn" => "Anderson",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m2 =
(
"uid" => "manager2",
"givenname" => "Olga",
"sn" => "Young",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m3 =
(
"uid" => "manager3",
"givenname" => "Bill",
"sn" => "Graham",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m4 =
(
"uid" => "manager4",
"givenname" => "Todd",
"sn" => "Hoover",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m5 =
(
"uid" => "manager5",
"givenname" => "Ken",
"sn" => "Hamilton",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m6 =
(
"uid" => "manager6",
"givenname" => "Christine",
"sn" => "Jobs",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m7 =
(
"uid" => "manager7",
"givenname" => "Joanna",
"sn" => "Lake",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m8 =
(
"uid" => "manager8",
"givenname" => "Kim",
"sn" => "Remley",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m9 =
(
"uid" => "manager9",
"givenname" => "Nick",
"sn" => "Pennebaker",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m10 =
(
"uid" => "manager10",
"givenname" => "Ted",
"sn" => "Hardy",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m11 =
(
"uid" => "manager11",
"givenname" => "Tanya",
"sn" => "Nielsen",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m12 =
(
"uid" => "manager12",
"givenname" => "Sam",
"sn" => "Madams",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m13 =
(
"uid" => "manager13",
"givenname" => "Judy",
"sn" => "Stewart",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m14 =
(
"uid" => "manager14",
"givenname" => "Martha",
"sn" => "Kidman",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m15 =
(
"uid" => "manager15",
"givenname" => "Leo",
"sn" => "Knuth",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m16 =
(
"uid" => "manager16",
"givenname" => "Cecil",
"sn" => "Guibas",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
%m17 =
(
"uid" => "manager17",
"givenname" => "Jay",
"sn" => "Hows",
"title" => "Manager",
"cn" => "",
"dn" => ""
);
@managers = (\%m0, \%m1, \%m2, \%m3, \%m4, \%m5, \%m6, \%m7, \%m8, \%m9, \%m10, \%m11, \%m12, \%m13, \%m14, \%m15, \%m16, \%m17);
sub flush {
local($old) = select(shift);
$| = 1;
print "";
$| = 0;
select($old);
}
my $Number_To_Generate = 1;
$Output_File_Name = "output.ldif";
$Random_Seed = 0;
$Suffix = 'dc=example,dc=com';
$NamingType = "uid";
$inetOrgPerson = "objectClass: inetOrgPerson\n";
$PrintOrgChartDat = 0;
$DataDir = "/usr/share/dirsrv/data";
$BeginNum = 0;
$ZeroPad = 0;
$Verbose = 0;
$debug = 0;
$Quiet = 0;
$opt_x = 0;
$opt_y = 0;
$opt_z = "";
# group + uniquemember
$opt_u = 0;
$gid = 0;
$gnum = 0;
$membercount = 100; # default member count in a group
GetOptions('number=i' => \$Number_To_Generate,
'output=s' => \$Output_File_Name,
'random=i' => \$Random_Seed,
'suffix=s' => \$Suffix,
'cnInDn' => \$opt_c,
'moreChoices=s' => \$opt_m,
'person' => \$opt_p,
'graph' => \$PrintOrgChartDat,
'location=s' => \$DataDir,
'beginNum=i' => \$BeginNum,
'x' => \$opt_x,
'y' => \$opt_y,
'z' => \$opt_z,
'j=i' => \$ZeroPad,
'verbose' => \$Verbose,
'debug' => \$debug,
'quiet' => \$Quiet,
'uniqueMember' => \$opt_u,
);
$Random_Seed = $Random_Seed || 0xdbdbdbdb;
$NamingType = "cn" if ($opt_c);
$NamingType = $opt_m if ($opt_m);
$inetOrgPerson = "" if ($opt_p);
$ExtraObjClasses = "";
if ($opt_z) {
$ExtraObjClasses = join "\n", map { "objectClass: $_" } split(/ /, $opt_z);
$ExtraObjClasses .= "\n";
}
$printpreamble = 1;
if ("" != $opt_x)
{
$printpreamble = 0;
}
$printorgunit = 1;
if ("" != $opt_y)
{
$printorgunit = 0;
}
if (0 != $opt_u) {
if ($membercount > $Number_To_Generate) {
$membercount = $Number_To_Generate;
}
@members = ();
}
if ($Suffix =~ /o=/) {
($Organization) = $Suffix =~ /o=([^,]+)/;
$objectvalue = "organization";
$line = "o: $Organization";
if ($Organization =~ /\s+/) {
($Organization) = $Organization =~ /([^\s]+)/;
$Organization .= ".com";
} elsif ($Organization !~ /\.com|\.net|\.org/) {
$Organization .= ".com";
}
} elsif ($Suffix =~ /dc=/) {
$Organization = $Suffix;
$Organization =~ s/,\s*dc=/./g;
($domain) = $Organization =~ /dc=([^\.]+)/;
$Organization =~ s/dc=//;
$objectvalue = "domain";
$line = "dc: $domain";
}
# Print help message if user doesn't know how many entries to make
# or no output file specified
if ( (!$Number_To_Generate) || (!$Output_File_Name)) {
&PrintUsage;
}
if ($Output_File_Name eq '-') {
*OUTPUT_FILE = *STDOUT;
} else {
open (OUTPUT_FILE, ">>$Output_File_Name") ||
die "Error---Can't open output file $Output_File_Name\n";
}
srand($Random_Seed);
print "Loading Name Data...\n" if $Verbose;
$GivenNamesFile = "$DataDir/dbgen-GivenNames";
$FamilyNamesFile = "$DataDir/dbgen-FamilyNames";
$OrgUnitsFile = "$DataDir/dbgen-OrgUnits";
&ReadGivenNames;
&ReadFamilyNames;
&ReadOrgUnits;
print "Done\n" if $Verbose;
if ($printpreamble)
{
if ($piranha) {
&PrintPreAmblePiranha($Output_File_Name);
}
else {
&PrintPreAmbleBarracuda($Output_File_Name);
}
}
if ($printorgunit)
{
&PrintOrganizationalUnits;
}
if ($PrintOrgChartDat)
{
# CEO
&PrintManagers(\%ceo, "", $ceo{"dn"});
for (my $j = 0; $j < @exective_presidents; $j++)
{
&PrintManagers($exective_presidents[$j], &MakeRandomOrgUnit, $ceo{"dn"});
}
# Presidents
for (my $j = 0; $j < @presidents; $j++)
{
my $who = int rand @exective_presidents;
&PrintManagers($presidents[$j],
&MakeRandomOrgUnit, $exective_presidents[$who]{"dn"});
}
# Vice Presidents
for (my $j = 0; $j < @vice_presidents; $j++)
{
my $who = int rand @presidents;
&PrintManagers($vice_presidents[$j],
&MakeRandomOrgUnit, $presidents[$who]{"dn"});
}
# Directors
for (my $j = 0; $j < @directors; $j++)
{
my $who = int rand @vice_presidents;
&PrintManagers($directors[$j],
&MakeRandomOrgUnit, $vice_presidents[$who]{"dn"});
}
# Managers
for (my $j = 0; $j < @managers; $j++)
{
my $who = int rand @directors;
&PrintManagers($managers[$j],
&MakeRandomOrgUnit, $directors[$who]{"dn"});
}
}
print "Generating $Number_To_Generate entries, please wait\n" if $Verbose;
print "Progress: " if $Verbose;
# We don't want people with duplicate names, so for each name generated,
# add it to "TheMap", which is an associative array with the
# name as the key. If there's a duplicate, throw the name out and
# try again.
$dups = 0;
# Generate Number_To_Generate distinct entries. If a duplicate
# is created, toss it out and try again.
# CHANGED: updated to allow for uid naming style or cn style. Check the RDN for uniqueness
for ($x= $BeginNum; $x < ($Number_To_Generate+$BeginNum); $x++) {
($givenName, $sn, $cn, $uid, $rdn,) = &MakeRandomName;
if (&AddAndCheck($rdn)) {
print "Duplicate: $rdn...\n" if $debug;
&flush(STDOUT);
$dups++;
$x--;
next;
}
$OrgUnit = &MakeRandomOrgUnit;
$facsimileTelephoneNumber = &MakeRandomTelephone;
$postalAddress = &MakeRandomPostalAddress (
int rand 1000,
int rand 1000,
$OrgUnit);
$postOfficeBox = int rand 10000;
$telephoneNumber = &MakeRandomTelephone;
$title = &MakeRandomTitle($OrgUnit);
# $userPassword = reverse ($cn);
# $userPassword =~ s/\s//g;
# $userPassword = substr($userPassword, 0, 10);
$locality = &MakeRandomLocality;
# $desc = "[0] This is $cn" . "'s description.";
$fourdigit = int rand 10000;
$desc = "2;$fourdigit;CN=Red Hat CS 71GA Demo,O=Red Hat CS 71GA Demo,C=US;CN=RHCS Agent - admin01,UID=admin01,O=redhat,C=US";
my $z = 1;
# for (; $z < 1024; $z++)
for (; $z < 2; $z++)
{
$desc = $desc . " [$z] This is $cn" . "'s description.";
}
$description = $desc;
$mail = &MakeMailAddress($givenName, $sn, $Organization);
if ($inetOrgPerson) {
$carLicense = "carLicense: " . &MakeRandomCarLicense . "\n";
$departmentNumber = "departmentNumber: " . (int rand 10000) . "\n";
$employeeType = "employeeType: " . &MakeRandomEmployeeType . "\n";
$homePhone = "homePhone: " . &MakeRandomTelephone . "\n";
$initials = "initials: " . &MakeInitials ($givenName, $sn) . "\n";
$mobile = "mobile: " . &MakeRandomTelephone . "\n";
$pager = "pager: " . &MakeRandomTelephone . "\n";
if ($PrintOrgChartDat) {
$managerCn = $managers[int rand @managers]{"dn"};
} else {
$managerCn = "cn=" . $managers[int rand @managers]{"givenname"} . " " .
$managers[int rand @managers]{"sn"};
}
($junk, $junk, $secretary_cn) = &MakeRandomName;
$manager = "manager: " . $managerCn . "\n";
$secretary = "secretary: cn=" . $secretary_cn . "\n";
$roomNumber = "roomNumber: " . (int rand 10000) . "\n";
$userPassword = "$uid\n";
}
if ($PrintOrgChartDat or !$printorgunit) {
$dnstr = "$NamingType=$rdn,ou=People,$Suffix";
} else {
$dnstr = "$NamingType=$rdn,ou=$OrgUnit,$Suffix";
}
if ($opt_u) {
# with group + memof
print OUTPUT_FILE
"dn: $dnstr\n",
"objectClass: top\n",
"objectClass: person\n",
"objectClass: organizationalPerson\n",
"objectClass: inetAdmin\n",
$inetOrgPerson, $ExtraObjClasses,
"cn: $cn\n",
"sn: $sn\n",
"uid: $uid\n",
"givenName: $givenName\n",
"description: $description\n",
"userPassword: $userPassword",
$departmentNumber,
$employeeType,
$homePhone,
$initials,
"telephoneNumber: $telephoneNumber\n",
"facsimileTelephoneNumber: $facsimileTelephoneNumber\n",
$mobile,
$pager,
$manager,
$secretary,
$roomNumber,
$carLicense,
"l: $locality\n",
"ou: $OrgUnit\n",
"mail: $mail\n",
"postalAddress: $postalAddress\n",
"title: $title\n",
$mycert,
"\n";
push(@members, $dnstr);
$gnum += 1;
if ($gnum >= $membercount) {
my $gdnstr = "dn: cn=Group$gid,$Suffix\n";
print OUTPUT_FILE
$gdnstr,
"objectClass: top\n",
"objectClass: groupOfUniqueNames\n",
"cn: Group$gid\n";
foreach $member (@members) {
print OUTPUT_FILE "uniqueMember: $member\n";
}
print OUTPUT_FILE "\n";
@members = ();
$gid += 1;
$gnum = 0;
}
} else {
# no group + memof
print OUTPUT_FILE
"dn: $dnstr\n",
"objectClass: top\n",
"objectClass: person\n",
"objectClass: organizationalPerson\n",
$inetOrgPerson, $ExtraObjClasses,
"cn: $cn\n",
"sn: $sn\n",
"uid: $uid\n",
"givenName: $givenName\n",
"description: $description\n",
"userPassword: $userPassword",
$departmentNumber,
$employeeType,
$homePhone,
$initials,
"telephoneNumber: $telephoneNumber\n",
"facsimileTelephoneNumber: $facsimileTelephoneNumber\n",
$mobile,
$pager,
$manager,
$secretary,
$roomNumber,
$carLicense,
"l: $locality\n",
"ou: $OrgUnit\n",
"mail: $mail\n",
"postalAddress: $postalAddress\n",
"title: $title\n",
$mycert,
"\n";
}
if (!$Quiet) {
if ($x % 1000 == 0) {
print "." if $Verbose;
&flush(STDOUT);
}
}
}
print "\n" if $Verbose;
print "Generated $x entries\n" if $Verbose;
if ($Verbose) {
print "$dups duplicates skipped\n";
}
exit 0;
sub ReadOrgUnits {
open (ORG_UNITS, $OrgUnitsFile) ||
die "Bad news, failed to open Org Units, $OrgUnitsFile: $!\n";
while(<ORG_UNITS>) {
chop;
push (@OrganizationalUnits, $_);
}
close ORG_UNITS;
}
sub ReadGivenNames {
open (GIVEN_NAMES, $GivenNamesFile) ||
die "Bad News, failed to load given names. $GivenNamesFile\n";
$i = 0;
while (<GIVEN_NAMES>) {
chop;
$given_names[$i++] = $_;
}
close GIVEN_NAMES;
}
sub ReadFamilyNames {
open (FAMILY_NAMES, $FamilyNamesFile) ||
die "Bad News, failed to load Family Names. $FamilyNamesFile\n";
$i = 0;
while (<FAMILY_NAMES>) {
chop;
$family_names[$i++] = $_;
}
close FAMILY_NAMES;
}
sub PrintPreAmblePiranha {
local($output_file) = @_;
print OUTPUT_FILE<<End_Of_File
dn: $Suffix
objectClass: top
objectClass: $objectvalue
$line
subtreeaci: +(&(privilege=write)(target=ldap:///self))
subtreeaci: +(privilege=compare)
subtreeaci: +(|(privilege=search)(privilege=read))
End_Of_File
;
}
sub PrintPreAmbleBarracuda {
local($output_file) = @_;
print OUTPUT_FILE<<End_Of_File
dn: $Suffix
objectClass: top
objectClass: $objectvalue
$line
aci: (target=ldap:///$Suffix)(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";)
aci: (target=ldap:///$Suffix)(targetattr=*)(version 3.0; acl "acl2"; allow(write) groupdn = "ldap:///cn=Directory Administrators, $Suffix";)
aci: (target=ldap:///$Suffix)(targetattr=*)(version 3.0; acl "acl3"; allow(read, search, compare) userdn = "ldap:///anyone";)
End_Of_File
;
}
sub PrintPreAmbleNoACI {
local($output_file) = @_;
print OUTPUT_FILE<<End_Of_File
dn: $Suffix
objectClass: top
objectClass: organization
o: $Organization
End_Of_File
;
}
sub PrintOrganizationalUnits {
foreach $ou (@OrganizationalUnits) {
print OUTPUT_FILE
"dn: ou=$ou,$Suffix\n",
"objectClass: top\n",
"objectClass: organizationalUnit\n",
"ou: $ou\n\n";
}
if ($PrintOrgChartDat) {
print OUTPUT_FILE
"dn: ou=People,$Suffix\n",
"objectClass: top\n",
"objectClass: organizationalUnit\n",
"ou: People\n\n";
}
}
sub PrintManagers {
my ($obj, $orgUnit, $managerCn) = @_;
my $rdn = $$obj{"$NamingType"};
my $uid = $$obj{"uid"};
my $givenName = $$obj{"givenname"};
my $sn = $$obj{"sn"};
my $title = $$obj{"title"};
$$obj{"cn"} = "$givenName $sn";
my $cn = $$obj{"cn"};
$facsimileTelephoneNumber = &MakeRandomTelephone;
$postalAddress = &MakeRandomPostalAddress (
int rand 1000,
int rand 1000,
$OrgUnit);
$postOfficeBox = int rand 10000;
$telephoneNumber = &MakeRandomTelephone;
$locality = &MakeRandomLocality;
$description = "This is $cn" . "'s description";
$mail = &MakeMailAddress($givenName, $sn, $Organization);
$$obj{"dn"} = "$NamingType=$rdn, ou=People, $Suffix";
if ($inetOrgPerson) {
$carLicense = "carLicense: " . &MakeRandomCarLicense . "\n";
$departmentNumber = "departmentNumber: " . (int rand 10000) . "\n";
$employeeType = "employeeType: " . $title . "\n";
$homePhone = "homePhone: " . &MakeRandomTelephone . "\n";
$initials = "initials: " . &MakeInitials ($givenName, $sn) . "\n";
$mobile = "mobile: " . &MakeRandomTelephone . "\n";
$pager = "pager: " . &MakeRandomTelephone . "\n";
($junk, $junk, $secretary_cn) = &MakeRandomName;
if ("" ne $managerCn) {
$manager = "manager: cn=" . $managerCn . "\n";
}
$secretary = "secretary: cn=" . $secretary_cn . "\n";
$roomNumber = "roomNumber: " . (int rand 10000) . "\n";
$userPassword = "$uid\n";
}
$dnstr = "$NamingType=$rdn,ou=People,$Suffix";
if ("" ne $orgUnit) {
$oustr = "ou: $orgUnit\n";
}
print OUTPUT_FILE
"dn: $dnstr\n",
"objectClass: top\n",
"objectClass: person\n",
"objectClass: organizationalPerson\n",
$inetOrgPerson,
"cn: $cn\n",
"sn: $sn\n",
"uid: $uid\n",
"givenName: $givenName\n",
"description: $description\n",
"userPassword: $userPassword",
$departmentNumber,
$employeeType,
$homePhone,
$initials,
"telephoneNumber: $telephoneNumber\n",
"facsimileTelephoneNumber: $facsimileTelephoneNumber\n",
$mobile,
$pager,
$manager,
$secretary,
$roomNumber,
$carLicense,
"l: $locality\n",
$oustr,
"mail: $mail\n",
"postalAddress: $postalAddress\n",
"title: $title\n",
$mycert,
"\n";
}
sub MakeRandomTitle {
local($org_unit) = @_;
return
"$title_ranks[rand @title_ranks] $org_unit $positions[rand @positions]";
}
sub MakeRandomLocality {
return $localities[rand @localities];
}
sub MakeRandomName {
local($Given_Name, $Surname, $Full_Name, $UID, $uniq, $first, $last, $RDN);
# Get the unique number depending if a seed was set or not.
$uniq = int rand($Random_Seed) if ($Random_Seed);
$uniq = $x if (!$Random_Seed);
$Given_Name = $given_names[rand @given_names];
$Surname = $family_names[rand @family_names];
$Full_Name = "$Given_Name $Surname";
$first = substr($Given_Name, 0,1);
$last = substr($Surname, 0,8);
$UID = $first . $last . "$uniq";
# Create the uid based on the DN naming type defined
if ($BeginNum) { # use a uniquenumber for the RDN value
if ($ZeroPad) {
$RDN = sprintf "%0.${ZeroPad}d", $x;
} else {
$RDN = $x;
}
} elsif ($NamingType eq "uid") {
$RDN = $UID;
} else {
$RDN = $Full_Name;
}
return ($Given_Name, $Surname, $Full_Name, $UID, $RDN);
}
sub MakeRandomOrgUnit {
return $OrganizationalUnits[rand @OrganizationalUnits];
}
sub MakeRandomTelephone {
local($prefix, $suffix, $Phone_Number);
$prefix = int rand(900) + 100;
$suffix = int rand(9000) + 1000;
return $Phone_Number = "+1 " . $area_codes[rand @area_codes] . " " .
"$prefix-$suffix";
}
sub MakeRandomSSN {
local($one, $two, $three, $SSN);
$one = int rand(900) +99;
$two = int rand(90) +9;
$three = int rand(9000) + 999;
return $SSN = "$one-$two-$three";
}
sub MakeRandomEmployeeType {
return $EmployeeTypes[rand @EmployeeTypes];
}
sub MakeRandomPersonalTitle {
return $personal_title[rand @personal_title];
}
sub MakeRandomCarLicense {
local ($rand_char_index, $ascii_value, $license);
for (1..7) {
$rand_char_index = int rand 36;
$ascii_value = ($rand_char_index > 9) ? $rand_char_index + 55 :
$rand_char_index + 48;
$license .= pack ("c", $ascii_value);
}
return $license;
}
# All entries are added to TheMap which checks to see
# if the name is already there
sub AddAndCheck {
local($RDN) = @_;
# now isn't this better than STL?
if ($TheMap{$RDN}) {
return 1;
}
else {
$TheMap{$RDN} = 1;
return 0;
}
}
sub MakeMailAddress {
local($given_name, $sur_name, $Organization) = @_;
return "$given_name". "_$sur_name\@$Organization";
}
sub MakeRandomPostalAddress {
local ($org, $departmentNumber,$roomNumber, $OrgUnit) = @_;
return "$org, $OrgUnit Dept \#$departmentNumber, Room\#$roomNumber";
}
sub MakeInitials {
local ($givenName, $sn) = @_;
local ($first, $last);
($first) = $givenName =~ /^(\w).*/;
($last) = $sn =~ /^(\w).*/;
return "$first" . ". " . "$last" . ".";
}
|