]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: cheaper userExists() implementation
authorArthur Schiwon <blizzz@owncloud.com>
Fri, 22 Jun 2012 10:42:07 +0000 (12:42 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Fri, 22 Jun 2012 10:43:09 +0000 (12:43 +0200)
apps/user_ldap/user_ldap.php

index 9281aebe81d90b718d96e049d564cf5fe1c6f2f0..48e7d429fcb6416ad0430d9021e74b79ea9caa98 100644 (file)
@@ -124,7 +124,19 @@ class OC_USER_LDAP extends OC_User_Backend {
         * @return boolean
         */
        public function userExists($uid){
-               return in_array($uid, $this->getUsers());
+               //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking.
+               $dn = OC_LDAP::username2dn($uid);
+               if(!$dn) {
+                       return false;
+               }
+
+               //if user really still exists, we will be able to read his cn
+               $cn = OC_LDAP::readAttribute($dn, 'cn');
+               if(!$cn || empty($cn)) {
+                       return false;
+               }
+
+               return true;
        }
 
 }