Skip to content
Snippets Groups Projects
Commit d32ec43e authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

LDAP class may limit size on allowed attributes

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1139 44740490-163a-0410-bde0-09ae8108e29a
parent 81194831
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,7 @@ class SimpleSAML_Auth_LDAP {
/**
* Search DN for attributes, and return associative array.
*/
public function getAttributes($dn, $attributes = null) {
public function getAttributes($dn, $attributes = NULL, $maxsize = NULL) {
$searchtxt = (is_array($attributes) ? join(',', $attributes) : 'all attributes');
SimpleSAML_Logger::debug('Library - LDAP: Get attributes from ' . $dn . ' (' . $searchtxt . ')');
......@@ -156,6 +156,7 @@ class SimpleSAML_Auth_LDAP {
$attributeName = $ldapAttributes[$i];
$base64encode = FALSE;
$include = FALSE;
if (strtolower($attributeName) === 'jpegphoto') {
$base64encode = TRUE;
......@@ -166,10 +167,17 @@ class SimpleSAML_Auth_LDAP {
$values = array();
for ($j = 0; $j < $valueCount; $j++) {
$values[] = ($base64encode ? base64_encode($attribute[$j]) : $attribute[$j] );
}
/*
SimpleSAML_Logger::debug('Library - attribute size of [' . $attributeName . '] (' . strlen($attribute[$j]) . ' of ' .
(is_null($maxsize) ? 'NA' : $maxsize) . ')');
*/
if (is_null($maxsize) or strlen($attribute[$j]) < $maxsize) {
$include = TRUE;
$values[] = ($base64encode ? base64_encode($attribute[$j]) : $attribute[$j] );
}
$attributes[$attributeName] = $values;
}
if ($include) $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