diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-10-27 19:15:13 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-10-27 19:43:07 +0200 |
commit | 3f85432df9d269908fc1bea66133246d4efce656 (patch) | |
tree | 78b5295c0786d893c0e4e5ae3dc7e8e55677eaa9 /apps | |
parent | b390da3eba41f31c20f7c0f2925dedc840343290 (diff) | |
download | nextcloud-server-3f85432df9d269908fc1bea66133246d4efce656.tar.gz nextcloud-server-3f85432df9d269908fc1bea66133246d4efce656.zip |
LDAP: make filter in readAttribute configurable
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/lib/access.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 9b870a8c6dc..f1e2143cfaf 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -44,7 +44,7 @@ abstract class Access { * * Reads an attribute from an LDAP entry */ - public function readAttribute($dn, $attr) { + public function readAttribute($dn, $attr, $filter = 'objectClass=*') { if(!$this->checkConnection()) { \OCP\Util::writeLog('user_ldap', 'No LDAP Connector assigned, access impossible for readAttribute.', \OCP\Util::WARN); return false; @@ -55,13 +55,17 @@ abstract class Access { \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG); return false; } - $rr = @ldap_read($cr, $dn, 'objectClass=*', array($attr)); + $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); //in case an error occurs , e.g. object does not exist return false; } $er = ldap_first_entry($cr, $rr); + if(!is_resource($er)) { + //did not match the filter, return false + return false; + } //LDAP attributes are not case sensitive $result = \OCP\Util::mb_array_change_key_case(ldap_get_attributes($cr, $er), MB_CASE_LOWER, 'UTF-8'); $attr = mb_strtolower($attr, 'UTF-8'); |