]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: fix potential infinite loop introduced with 4c4aa92eef858a2a96bb5676304acbcaafa...
authorArthur Schiwon <blizzz@owncloud.com>
Wed, 29 Aug 2012 17:11:32 +0000 (19:11 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 29 Aug 2012 17:37:18 +0000 (19:37 +0200)
apps/user_ldap/group_ldap.php
apps/user_ldap/lib/access.php

index b29ebe30c51728653a083e7630dd871cf3ff93d6..aac3ed78917a06b1f4ba794c9b971072c6b74dd6 100644 (file)
@@ -232,7 +232,26 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface {
         * @return bool
         */
        public function groupExists($gid){
-               return in_array($gid, $this->getGroups());
+               if($this->connection->isCached('groupExists'.$gid)) {
+                       return $this->connection->getFromCache('groupExists'.$gid);
+               }
+
+               //getting dn, if false the group does not exist. If dn, it may be mapped only, requires more checking.
+               $dn = $this->username2dn($gid);
+               if(!$dn) {
+                       $this->connection->writeToCache('groupExists'.$gid, false);
+                       return false;
+               }
+
+               //if group really still exists, we will be able to read its objectclass
+               $objcs = $this->readAttribute($dn, 'objectclass');
+               if(!$objcs || empty($objcs)) {
+                       $this->connection->writeToCache('groupExists'.$gid, false);
+                       return false;
+               }
+
+               $this->connection->writeToCache('groupExists'.$gid, true);
+               return true;
        }
 
        /**
index 9abbd91c179f3948688b9d0064b3e0cf6403358a..089548a69ba75fe9ae95926cb1c3be4c837b587f 100644 (file)
@@ -137,20 +137,6 @@ abstract class Access {
                $dn = $this->ocname2dn($name, true);
                if($dn) {
                        return $dn;
-               } else {
-                       //fallback: user is not mapped
-                       $filter = $this->combineFilterWithAnd(array(
-                               $this->connection->ldapUserFilter,
-                               $this->connection->ldapUserDisplayName . '=' . $name,
-                       ));
-                       $result = $this->searchUsers($filter, 'dn');
-                       if(isset($result[0]['dn'])) {
-                               //try mapping, if names equalize return DN
-                               $uid = $this->dn2username($result[0]['dn']);
-                               if($uid == $name) {
-                                       return $result[0]['dn'];
-                               }
-                       }
                }
 
                return false;