From e0b0803b24ee4c7167c52838078bce93baaaab02 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 21 Feb 2008 09:50:15 +0000 Subject: [PATCH] Updated termDNS -Class initializes up to 20 times faster now ... git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9006 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_systemManagement.inc | 8 ++-- .../systems/admin/systems/class_termDNS.inc | 40 +++++++++++++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gosa-plugins/systems/admin/systems/class_systemManagement.inc b/gosa-plugins/systems/admin/systems/class_systemManagement.inc index e49653d78..5cf90e187 100644 --- a/gosa-plugins/systems/admin/systems/class_systemManagement.inc +++ b/gosa-plugins/systems/admin/systems/class_systemManagement.inc @@ -63,7 +63,7 @@ class systems extends plugin /* Call parent execute */ plugin::execute(); - session::set('LOCK_VARS_TO_USE',array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/")); + session::set('LOCK_VARS_TO_USE',array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/","/^menu_action/")); /******************** Check for functional posts, edit|delete|add|... system devices @@ -488,11 +488,11 @@ class systems extends plugin foreach($ids as $id){ $dn = $this->terminals[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } $this->dns[$id] = $dn; } + if ($user= get_multiple_locks($this->dns)){ + return(gen_locked_message($user,$this->dns)); + } $dns_names = "
";
         foreach($this->dns as $dn){
diff --git a/gosa-plugins/systems/admin/systems/class_termDNS.inc b/gosa-plugins/systems/admin/systems/class_termDNS.inc
index 81dcc4ecc..b4a6a7962 100644
--- a/gosa-plugins/systems/admin/systems/class_termDNS.inc
+++ b/gosa-plugins/systems/admin/systems/class_termDNS.inc
@@ -138,18 +138,42 @@ class termDNS extends plugin
       }
     }
 
-    /* Create a list of used mac and ip addresses */
+    /* Create a list of used mac and ip addresses.
+
+       ! We use this optically huge amount of code to fetch all 
+       Mac and IP addresses, because a simple search for mac and IP
+       over the whole ldap server was 10 to 20 times slower.
+     */
+    $deps  = array();
+    $ou = preg_replace("/,.*$/","",get_ou("systemsou"));
+    $a_ous = array(get_ou("serverou"),
+                  get_ou("terminalou"),
+                  get_ou("workstationou"),
+                  get_ou("printerou"),
+                  get_ou("phoneou"),
+                  get_ou("componentou"));
+  
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
+    $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn"));
     while($attrs = $ldap->fetch()){
-      if(isset($attrs['ipHostNumber'][0])){
-        $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
+      foreach($a_ous as $allowed){
+        $deps[] = $allowed.$attrs['dn'];
       }
-      if(isset($attrs['macAddress'][0])){
-        $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
-      }
-    } 
+    }
+
+    foreach($deps as $dep){
+      $ldap->cd($dep);
+      $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
+      while($attrs = $ldap->fetch()){
+        if(isset($attrs['ipHostNumber'][0])){
+          $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
+        }
+        if(isset($attrs['macAddress'][0])){
+          $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
+        }
+      } 
+    }
 
     /* Save initial ip and mac values, to be able 
         check if the used values are already in use */ 
-- 
2.30.2