X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fmodules%2FClientPackages.pm;h=fb8aab830dd33adcc62e5226f235e304b16f934c;hb=a1a372b00f22bf95a8dc29870e1ec5dabfe157c9;hp=1db6d0193cbe264297711c699bf249997db94dea;hpb=f5f04a5521a10b4d41fd64b5029805c197d9d2fc;p=gosa.git diff --git a/gosa-si/modules/ClientPackages.pm b/gosa-si/modules/ClientPackages.pm index 1db6d0193..fb8aab830 100644 --- a/gosa-si/modules/ClientPackages.pm +++ b/gosa-si/modules/ClientPackages.pm @@ -513,7 +513,6 @@ sub here_i_am { # return acknowledgement to client $out_hash = &create_xml_hash("registered", $server_address, $source); - # give the new client his ldap config # Workaround: Send within the registration response, if the client will get an ldap config later my $new_ldap_config_out = &new_ldap_config($source, $session_id); @@ -554,6 +553,39 @@ sub here_i_am { push(@out_msg_l, $syslog_config_out); } + # update ldap entry if exists + my $ldap_handle= &main::get_ldap_handle(); + my $ldap_res= $ldap_handle->search( + base => $ldap_base, + scope => 'sub', + #attrs => ['ipHostNumber'], + filter => "(&(objectClass=GOhard)(macAddress=$mac_address))"); + if($ldap_res->code) { + &main::daemon_log("$session_id ERROR: LDAP Entry for client with mac address $mac_address not found: ".$ldap_res->error, 1); + } elsif ($ldap_res->count != 1) { + &main::daemon_log("$session_id ERROR: client with mac address $mac_address not found/unique/active - not updating ldap entry". + "\n\tbase: $ldap_base". + "\n\tscope: sub". + "\n\tattrs: ipHostNumber". + "\n\tfilter: (&(objectClass=GOhard)(macaddress=$mac_address))", 1); + } else { + my $entry= $ldap_res->pop_entry(); + my $ip_address= $entry->get_value('ipHostNumber'); + my $source_ip= ($1) if $source =~ /^([0-9\.]*?):[0-9]*$/; + if(not defined($ip_address) and defined($source_ip)) { + $entry->add( 'ipHostNumber' => $source_ip ); + my $mesg= $entry->update($ldap_handle); + $mesg->code && &main::daemon_log("$session_id ERROR: Updating IP Address for client with mac address $mac_address failed with '".$mesg->mesg()."'", 1); + } elsif(defined($source_ip) and not ($source_ip eq $ip_address)) { + $entry->replace( 'ipHostNumber' => $source_ip ); + my $mesg= $entry->update($ldap_handle); + $mesg->code && &main::daemon_log("$session_id ERROR: Updating IP Address for client with mac address $mac_address failed with '".$mesg->mesg()."'", 1); + } elsif (not defined($source_ip)) { + &main::daemon_log("ERROR: Could not parse source value '$source' perhaps not an ip address?", 1); + } + } + &main::release_ldap_handle($ldap_handle); + # notify registered client to all other server my %mydata = ( 'client' => $source, 'macaddress' => $mac_address); my $mymsg = &build_msg('new_foreign_client', $main::server_address, "KNOWN_SERVER", \%mydata); @@ -650,7 +682,7 @@ sub new_syslog_config { my $ldap_res = $ldap_handle->search( base => $ldap_base, scope => 'sub', attrs => ['gotoSyslogServer'], - filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))"); + filter => "(&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))"); if($ldap_res->code) { &main::daemon_log("$session_id ERROR: new_syslog_config: ldap search: ".$ldap_res->error, 1); &main::release_ldap_handle($ldap_handle); @@ -663,7 +695,7 @@ sub new_syslog_config { "\n\tbase: $ldap_base". "\n\tscope: sub". "\n\tattrs: gotoSyslogServer". - "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); + "\n\tfilter: (&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); &main::release_ldap_handle($ldap_handle); return; } @@ -726,7 +758,7 @@ sub new_ntp_config { my $ldap_res = $ldap_handle->search( base => $ldap_base, scope => 'sub', attrs => ['gotoNtpServer'], - filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))"); + filter => "(&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))"); if($ldap_res->code) { &main::daemon_log("$session_id ERROR: new_ntp_config: ldap search: ".$ldap_res->error, 1); &main::release_ldap_handle($ldap_handle); @@ -739,7 +771,7 @@ sub new_ntp_config { "\n\tbase: $ldap_base". "\n\tscope: sub". "\n\tattrs: gotoNtpServer". - "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); + "\n\tfilter: (&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); &main::release_ldap_handle($ldap_handle); return; } @@ -838,7 +870,7 @@ sub new_ldap_config { $mesg = $ldap_handle->search( base => $ldap_base, scope => 'sub', attrs => ['dn', 'gotoLdapServer', 'FAIclass'], - filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))"); + filter => "(&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))"); if($mesg->code) { &main::daemon_log("$session_id ERROR: new_ldap_config: unable to search for '(&(objectClass=gosaGroupOfNames)(member=$filter_dn))': ".$mesg->error, 1); &main::release_ldap_handle($ldap_handle); @@ -851,7 +883,7 @@ sub new_ldap_config { "\n\tbase: $ldap_base". "\n\tscope: sub". "\n\tattrs: dn, gotoLdapServer, FAIclass". - "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); + "\n\tfilter: (&(gosaGroupObjects=[W])(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1); &main::release_ldap_handle($ldap_handle); return; } @@ -1002,7 +1034,7 @@ sub hardware_config { } else { my $entry= $mesg->entry(0); if (defined($entry->get_value("gotoHardwareChecksum"))) { - if (! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) { + if (! ($entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum)) { $entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum); if($entry->update($ldap_handle)) { &main::daemon_log("$session_id INFO: Hardware changed! Detection triggered.", 5);