index daaa161e18e40c6af1f200de1987d0492d699f9a..4e8705902fa71a76c43613b132a95b8730de400d 100644 (file)
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
- &main::refresh_ldap_handle();
- if( defined($main::ldap_handle) ) {
+
+ my $ldap_handle = &main::get_ldap_handle();
+ if( defined($ldap_handle) ) {
&main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5);
# Perform search for Unit Tag
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
my $hostname= `hostname -f`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
$hostname= `hostname -s`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
#===============================================================================
sub read_configfile {
my $cfg;
- if( defined( $main::cfg_file) && ( length($main::cfg_file) > 0 )) {
+ if( defined( $main::cfg_file) && ( (-s $main::cfg_file) > 0 )) {
if( -r $main::cfg_file ) {
$cfg = Config::IniFiles->new( -file => $main::cfg_file );
} else {
eval{ require $event; };
if( $@ ) {
- &main::daemon_log("import of event module '$event' failed", 1);
+ &main::daemon_log("S ERROR: import of event module '$event' failed", 1);
&main::daemon_log("$@", 8);
next;
}
}
# Build LDAP connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
&main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
# Perform search
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'gosaUnitTag', 'FAIclass'],
filter => "(&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))");
# Do we need to look at an object class?
if (length(@servers) < 1){
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'FAIclass'],
filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
if (defined $unit_tag){
# Find admin base and department name
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'ou'],
filter => "(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$unit_tag))");
# check hit
my $hit_counter = keys %{$res};
if( not $hit_counter == 1 ) {
- &main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
+ &main::daemon_log("$session_id ERROR: more or no hit found in known_clients_db by query by '$address'", 1);
}
my $macaddress = $res->{1}->{macaddress};
my $hostkey = $res->{1}->{hostkey};
if (not defined $macaddress) {
- &main::daemon_log("ERROR: no mac address found for client $address", 1);
+ &main::daemon_log("$session_id ERROR: no mac address found for client $address", 1);
return;
}
# Build LDAP connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
- &main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
# Perform search
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
if (defined($entry->get_value("gotoHardwareChecksum"))) {
if (! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
$entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum);
- if($entry->update($main::ldap_handle)) {
+ if($entry->update($ldap_handle)) {
&main::daemon_log("$session_id INFO: Hardware changed! Detection triggered.", 5);
}
} else {