|
|
|
@ -38,9 +38,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) { |
|
|
|
|
if(!$this->checkConnection()) { |
|
|
|
@ -55,10 +57,14 @@ abstract class Access { |
|
|
|
|
} |
|
|
|
|
$rr = @ldap_read($cr, $dn, 'objectClass=*', 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); |
|
|
|
|
//LDAP attributes are not case sensitive |
|
|
|
|
$result = \OCP\Util::mb_array_change_key_case(ldap_get_attributes($cr, $er), MB_CASE_LOWER, 'UTF-8'); |
|
|
|
|