From db15b7b88560f1ee2f3f3178883511739f1b21fd Mon Sep 17 00:00:00 2001 From: janw Date: Fri, 1 Feb 2008 11:37:42 +0000 Subject: [PATCH] gotoHardwareChecksum gets added to LDAP if not present git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8718 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/modules/SIPackages.pm | 41 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index bcd376f81..f346ae26d 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -682,7 +682,7 @@ sub new_ldap_config { # Bind to a directory with dn and password - my $mesg= $ldap->bind($ldap_admin_dn, $ldap_admin_password); + my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password); # Perform search $mesg = $ldap->search( base => $ldap_base, @@ -803,7 +803,7 @@ sub process_detected_hardware { # DESCRIPTION: #=============================================================================== sub hardware_config { - my ($address, $gotoHardwareChecksum, $detectedHardware) = @_ ; + my ($address, $gotoHardwareChecksum) = @_ ; my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'"; my $res = $main::known_clients_db->select_dbentry( $sql_statement ); @@ -829,20 +829,37 @@ sub hardware_config { return; } - # Bind to a directory with dn and password - my $mesg= $ldap->bind($ldap_admin_dn, $ldap_admin_password); + my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password); # Perform search - $mesg = $ldap->search( base => $ldap_base, - scope => 'sub', - attrs => ['dn', 'gotoHardwareChecksum'], - filter => "(&(objectClass=GOhard)(macaddress=$macaddress))"); - #$mesg->code && die $mesg->error; + $mesg = $ldap->search( + base => $ldap_base, + scope => 'sub', + filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))" + ); + + if($mesg->count() == 0) { + &main::daemon_log("Host was not found in LDAP!", 1); + return; + } - #my $entry= $mesg->entry(0); - #my $dn= $entry->dn; - #my @servers= $entry->get_value("gotoHardwareChecksum"); + my $entry= $mesg->entry(0); + my $dn= $entry->dn; + if(defined($entry->get_value("gotoHardwareChecksum"))) { + return; + } else { + # need to fill it to LDAP + $entry->add(gotoHardwareChecksum => $gotoHardwareChecksum); + &main::daemon_log(Dumper($entry->update($ldap)),1); + + # Look if there another host with this checksum to use the hardware config + $mesg = $ldap->search( + base => $ldap_base, + scope => 'sub', + filter => "(&(objectClass=GOhard)(gotoHardwareChecksum=$gotoHardwareChecksum))" + ); + } # Assemble data package my %data = (); -- 2.30.2