Code

new jobs try to translate mac to real name and at it to targettag at job-queue
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Mar 2008 12:57:20 +0000 (12:57 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Mar 2008 12:57:20 +0000 (12:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9993 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/modules/GosaPackages.pm

index 7e50aef0295095b5006510d5a43037591a22f2d4..6e581101e2e6e41e34dac4a6e5101f4098ccc0fa 100644 (file)
@@ -348,8 +348,28 @@ sub process_job_msg {
             "</xml>";
     }
     
-    # check wether mac address is already known in known_daemons or known_clients
-    my $target = 'none';
+       # if mac address is already known in ldap, set targettag to 'cn'
+    my $target;
+       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);
+               $target = "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);
+                       $target = "none";
+               } else {
+                       my $entry= $mesg->entry(0);
+                       $target = $entry->get_value("cn");
+               }
+       }
 
     if( $error == 0 ) {
         # add job to job queue