Code

Updated user-filter handling.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Oct 2008 13:14:02 +0000 (13:14 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Oct 2008 13:14:02 +0000 (13:14 +0000)
-The filter was very slow due to the fact that the complete department and all included  objects were checked by every request.
-No only the requested object is checked.
-Added a new ldap method which allows to check filter settings on a single object. ldap->object_match_filter($dn,"cn=h*")

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12788 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 02f4c9573f623a0b0a00cb21ff19314b0ffc5908..2a0055bee7aa430756e8b230da21458903f3f859 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 0601a984204c50b73a151eb8abc1c47717aa9145..d5bc7419dad377772bd2fd4794a0bfb5420f47a0 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;
-              }
             }
           }