Code

add plain name to job queue by TASKBEING at clMessages.pm
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Apr 2008 11:59:06 +0000 (11:59 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Apr 2008 11:59:06 +0000 (11:59 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10721 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/server/events/clMessages.pm

index b566687623c15df941f43bdb860b2ef32c996481..7425bfbac4690a6e232317d12598f3c1f3e17e65 100644 (file)
@@ -373,9 +373,30 @@ sub TASKBEGIN {
                        }
                
                        # in case of no and more than one running jobs in queue, add one single job
-
-# TODO
                        # resolve plain name for host $macaddress
+                       my $plain_name;
+                       my $ldap_handle = &main::get_ldap_handle($session_id);
+                       if( not defined $ldap_handle ) {
+                               &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
+                               $plain_name = "none";
+
+                       # try to fetch a 'real name'
+                       } else {
+                               my $mesg = $ldap_handle->search(
+                                               base => $main::ldap_base,
+                                               scope => 'sub',
+                                               attrs => ['cn'],
+                                               filter => "(macAddress=$macaddress)");
+                               if($mesg->code) {
+                                       &main::daemon_log($mesg->error, 1);
+                                       $plain_name = "none";
+                               } else {
+                                       my $entry= $mesg->entry(0);
+                                       $plain_name = $entry->get_value("cn");
+                               }
+                       }
+
+
                        &main::daemon_log("$session_id DEBUG: add job to queue for host '$macaddress'", 7); 
                        my $func_dic = {table=>$main::job_queue_tn,
                                        primkey=>[],
@@ -387,7 +408,7 @@ sub TASKBEGIN {
                                        targettag=>$source,
                                        xmlmessage=>'none',
                                        macaddress=>$macaddress,
-                                       plainname=>'none',
+                                       plainname=>$plain_name,
                        };
                        my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
                        if ($err != 0)  {