6 my $opt_hostname = `hostname`;
17 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time);
18 return sprintf "%04u%02u%02u%02u%02u%02u.0Z",
19 $year+1900, $mon+1, $mday, $hour, $min, $sec;
22 #######################
23 # substitute a single variable
28 if ($var eq "BASEDN") {
32 if ($var eq "NETBIOSNAME") {
36 if ($var eq "DNSNAME") {
40 if ($var eq "DNSDOMAIN") {
44 die "ERROR: Uknown substitution variable $var\n";
47 #####################################################################
48 # write a string into a file
51 my($filename) = shift;
54 open(FILE, ">$filename") || die "can't open $filename";
59 #####################################################################
60 # read a file into a string
63 my($filename) = shift;
65 open(INPUTFILE, $filename) || return undef;
66 my($saved_delim) = $/;
68 my($data) = <INPUTFILE>;
74 ############################################
82 --realm REALM set realm
83 --domain DOMAIN set domain
84 --hostname HOSTNAME set hostname
86 You must provide at least a realm and domain
95 'help|h|?' => \$opt_help,
96 'realm=s' => \$opt_realm,
97 'domain=s' => \$opt_domain,
98 'hostname=s' => \$opt_hostname,
108 $opt_realm=uc($opt_realm);
109 $opt_domain=uc($opt_domain);
110 $opt_hostname=lc($opt_hostname);
111 $netbiosname=uc($opt_hostname);
113 print "Provisioning host '$opt_hostname' with netbios name '$netbiosname' for domain '$opt_domain' in realm '$opt_realm'\n";
115 print "generating ldif ...\n";
117 $dnsdomain = lc($opt_realm);
118 $dnsname = $opt_hostname.".".$dnsdomain;
119 $basedn = "DC=" . join(",DC=", split(/\./, $opt_realm));
121 my $data = FileLoad("rootdse.ldif") || die "Unable to load rootdse.ldif\n";
125 print "applying substitutions ...\n";
127 while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
128 my $sub = substitute($2);
134 print "saving ldif to newrootdse.ldif ...\n";
136 FileSave("newrootdse.ldif", $res);
138 unlink("newrootdse.ldb");
140 print "creating newrootdse.ldb ...\n";
142 # allow provisioning to be run from the source directory
143 $ENV{"PATH"} .= ":bin";
145 system("ldbadd -H newrootdse.ldb newrootdse.ldif");
149 Please move newrootdse.ldb to rootdse.ldb in the lib/private/ directory of your