Code

Improved filter check speed
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 08:15:40 +0000 (08:15 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 29 Oct 2008 08:15:40 +0000 (08:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12795 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_ldap.inc
gosa-core/include/class_userinfo.inc

index a28a151382e63675fe7b94c6a32a2b84c52cdc67..310781c1989095f829e15b19c0f6b570a5dc48ee 100644 (file)
@@ -293,6 +293,19 @@ class LDAP{
     }
   }
 
+  function object_match_filter($dn,$filter)
+  {
+    if($this->hascon){
+      if ($this->reconnect) $this->connect();
+      $res =  @ldap_read($this->cid, LDAP::fix($dn), $filter, array("objectClass"));
+      $rv =   @ldap_count_entries($this->cid, $res);
+      return($rv);
+    }else{
+      $this->error = "Could not connect to LDAP server";
+      return(FALSE);
+    }
+  }
+
   function set_size_limit($size)
   {
     /* Ignore zero settings */
index ce80f8bde57ba788e208c53c486d1778241ea5ed..6d89552098a88b164cd5b9ea41d38b00172b5d76 100644 (file)
@@ -349,22 +349,8 @@ class userinfo
 
           /* With user filter */
           if (isset($subacl['filter']) && !empty($subacl['filter'])){
-            $sdn = preg_replace("/^[^,]*+,/","",$dn);
-            $ldap->cd($sdn);
-            $ldap->ls($subacl['filter'],$sdn);
-            if(!$ldap->count()){
+            if(!$ldap->object_match_filter($dn,$subacl['filter'])){
               continue;
-            }else{
-              $found = FALSE; 
-              while($attrs = $ldap->fetch()){
-                if($attrs['dn'] == $dn){
-                  $found = TRUE;
-                  break;
-                }
-              }
-              if(!$found){
-                continue;
-              }
             }
           }