summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it>2012-11-05 15:38:49 +0100
committerLorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it>2012-11-05 15:38:49 +0100
commit510191db6885153a98350d1a3530834491e0b552 (patch)
tree20d62fb49f70c8c03b6b901697be691157a2e40a /apps
parentccbf4e993c99c6a42c8e1574405244dbd5f660ca (diff)
downloadnextcloud-server-510191db6885153a98350d1a3530834491e0b552.tar.gz
nextcloud-server-510191db6885153a98350d1a3530834491e0b552.zip
Return true or false from readAttribute if $attr is empty
This way, readAttribute can act as an existence checker.
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/access.php11
-rw-r--r--apps/user_ldap/user_ldap.php5
2 files changed, 10 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index f1e2143cfaf..822e0b441c0 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -40,9 +40,10 @@ 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 true or the values in an array on success, 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 +58,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 true;
+ }
$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..4c0893a5103 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(!$this->readAttribute($dn, '') ) {
$this->connection->writeToCache('userExists'.$uid, false);
return false;
}