summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorblizzz <blizzz@owncloud.com>2012-11-06 07:24:15 -0800
committerblizzz <blizzz@owncloud.com>2012-11-06 07:24:15 -0800
commit64ac208fb2e237f402af4bcaad8270086438061f (patch)
treebe5488e664bc3ff07c11629551de22c81036f075 /apps/user_ldap
parentbfaed9a8b629d1c1c54ada7bcf1bc85011cf20fe (diff)
parentca24f4767b996bcded139dd9189592e57eade2a6 (diff)
downloadnextcloud-server-64ac208fb2e237f402af4bcaad8270086438061f.tar.gz
nextcloud-server-64ac208fb2e237f402af4bcaad8270086438061f.zip
Merge pull request #258 from wardragon/ldap_existence_check_no_refactor
LDAP: improved object existence check
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/access.php12
-rw-r--r--apps/user_ldap/user_ldap.php5
2 files changed, 11 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index f1e2143cfaf..9cbb21ead0e 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -40,9 +40,11 @@ abstract class Access {
* @brief reads a given attribute for an LDAP record identified by a DN
* @param $dn the record in question
* @param $attr the attribute that shall be retrieved
- * @returns the values in an array on success, false otherwise
+ * if empty, just check the record's existence
+ * @returns an array of values on success or an empty
+ * array if $attr is empty, false otherwise
*
- * Reads an attribute from an LDAP entry
+ * Reads an attribute from an LDAP entry or check if entry exists
*/
public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
if(!$this->checkConnection()) {
@@ -57,10 +59,14 @@ abstract class Access {
}
$rr = @ldap_read($cr, $dn, $filter, array($attr));
if(!is_resource($rr)) {
- \OCP\Util::writeLog('user_ldap', 'readAttribute '.$attr.' failed for DN '.$dn, \OCP\Util::DEBUG);
+ \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
//in case an error occurs , e.g. object does not exist
return false;
}
+ if (empty($attr)) {
+ \OCP\Util::writeLog('user_ldap', 'readAttribute: '.$dn.' found', \OCP\Util::DEBUG);
+ return array();
+ }
$er = ldap_first_entry($cr, $rr);
if(!is_resource($er)) {
//did not match the filter, return false
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 69e470c78a7..6591d1d5fee 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -149,9 +149,8 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
return false;
}
- //if user really still exists, we will be able to read his objectclass
- $objcs = $this->readAttribute($dn, 'objectclass');
- if(!$objcs || empty($objcs)) {
+ //check if user really still exists by reading its entry
+ if(!is_array($this->readAttribute($dn, ''))) {
$this->connection->writeToCache('userExists'.$uid, false);
return false;
}