Skip to content
Snippets Groups Projects
Commit 4c5a372b authored by Olav Morken's avatar Olav Morken
Browse files

Auth/LDAP: Preserve case of attribute names during ldap attribute retrival.

Note that this may break existing applications.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@602 44740490-163a-0410-bde0-09ae8108e29a
parent ecd9736c
No related branches found
No related tags found
No related merge requests found
......@@ -142,22 +142,37 @@ class SimpleSAML_Auth_LDAP {
if ($sr === false)
throw new Exception('Could not retrieve attributes for user: ' . ldap_error($this->ldap));
$ldapentry = @ldap_get_entries($this->ldap, $sr);
if ($ldapentry === false)
throw new Exception('Could not retrieve results from attribute retrieval for user:' . ldap_error($this->ldap));
$ldapEntry = @ldap_first_entry($this->ldap, $sr);
if ($ldapEntry === false) {
throw new Exception('Could not retrieve attributes for user -' .
' could not select first entry: ' . ldap_error($this->ldap));
}
$ldapAttributes = @ldap_get_attributes($this->ldap, $ldapEntry);
if ($ldapAttributes === false) {
throw new Exception('Could not retrieve attributes for user -' .
' error fetching attributes for select first entry: ' . ldap_error($this->ldap));
}
$attributes = array();
for ($i = 0; $i < $ldapentry[0]['count']; $i++) {
for ($i = 0; $i < $ldapAttributes['count']; $i++) {
$attributeName = $ldapAttributes[$i];
/* Skip the 'jpegphoto' attribute. */
if (strtolower($attributeName) === 'jpegphoto') {
continue;
}
$attribute = $ldapAttributes[$attributeName];
$valueCount = $attribute['count'];
$values = array();
if ($ldapentry[0][$i] == 'jpegphoto') continue;
for ($j = 0; $j < $ldapentry[0][$ldapentry[0][$i]]['count']; $j++) {
$values[] = $ldapentry[0][$ldapentry[0][$i]][$j];
for ($j = 0; $j < $valueCount; $j++) {
$values[] = $attribute[$j];
}
$attributes[$ldapentry[0][$i]] = $values;
$attributes[$attributeName] = $values;
}
SimpleSAML_Logger::debug('Library - LDAP: Found attributes (' . join(',', array_keys($attributes)) . ')');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment