summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a74eb41)
raw | patch | inline | side by side (parent: a74eb41)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 13 Feb 2008 14:44:15 +0000 (14:44 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 13 Feb 2008 14:44:15 +0000 (14:44 +0000) |
Write gosaUnitTag for newly created LDAP entries if defined (either config file or server-specific in LDAP).
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8896 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8896 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/modules/SIPackages.pm | patch | blob | history |
index bc1be2ff8cd024b3a19074c4a705927e18e09350..f8c56e6bf88b4517a087db15677ec31ee466807b 100644 (file)
my $server;
my $network_interface;
my $no_bus;
-my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret);
+my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret, $gosa_unit_tag);
my %cfg_defaults = (
"ldap-admin-dn" => [\$ldap_admin_dn, ""],
"ldap-admin-password" => [\$ldap_admin_password, ""],
"max-clients" => [\$max_clients, 100],
+ "gosa-unit-tag" => [\$gosa_unit_tag, ""],
},
"SIPackages" => {
"key" => [\$SIPackages_key, ""],
$network_interface= &get_interface_for_ip($server_ip);
$server_mac_address= &get_mac($network_interface);
+# Unit tag can be defined in config
+if(not defined($gosa_unit_tag) || length($gosa_unit_tag)==0) {
+ # Read gosaUnitTag from LDAP
+ my $tmp_ldap= Net::LDAP->new($ldap_uri);
+ if(defined($tmp_ldap)) {
+ my $mesg= $tmp_ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
+ # Perform search for Unit Tag
+ $mesg = $tmp_ldap->search(
+ base => $ldap_base,
+ scope => 'sub',
+ attrs => ['gosaUnitTag'],
+ filter => "(macaddress=$server_mac_address)"
+ );
+
+ if ($mesg->count == 1) {
+ my $entry= $mesg->entry(0);
+ my $unit_tag= $entry->get_value("gosaUnitTag");
+ if(defined($unit_tag) && length($unit_tag) > 0) {
+ &main::daemon_log("Detected gosaUnitTag $unit_tag for creating entries", 4);
+ $gosa_unit_tag= $unit_tag;
+ }
+ $mesg = $tmp_ldap->unbind;
+ }
+ }
+}
+
# complete addresses
#if( $server_ip eq "0.0.0.0" ) {
# $server_ip = "127.0.0.1";
$entry->add("gotomode" => "locked");
$entry->add("gotoSysStatus" => "new-system");
$entry->add("ipHostNumber" => $ipaddress);
+ if(defined($gosa_unit_tag) && length($gosa_unit_tag) > 0) {
+ $entry->add("objectClass" => "gosaAdministrativeUnit");
+ $entry->add("gosaUnitTag" => $gosa_unit_tag);
+ }
if(my $res=$entry->update($ldap)) {
# Fill $mesg again
$mesg = $ldap->search(