From: janw Date: Wed, 13 Feb 2008 14:44:15 +0000 (+0000) Subject: Added config file option gosa-unit-tag (server.conf). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bca3ce5ba8e04e21c5a0460fe0863ecead3936ce;p=gosa.git Added config file option gosa-unit-tag (server.conf). 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 --- diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index bc1be2ff8..f8c56e6bf 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -26,7 +26,7 @@ my ($bus_activ, $bus_key, $bus_ip, $bus_port); 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 = ( @@ -45,6 +45,7 @@ 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, ""], @@ -59,6 +60,32 @@ my %cfg_defaults = ( $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"; @@ -818,6 +845,10 @@ sub process_detected_hardware { $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(