Skip to content

Commit

Permalink
Improvement: ensure UserDirectory->registerUser will never go into an…
Browse files Browse the repository at this point in the history
… infinite recursive loop.
  • Loading branch information
Boy Baukema committed Aug 4, 2015
1 parent 7401d52 commit 4f6136c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions library/EngineBlock/UserDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ public function findUsersByIdentifier($identifier)

/**
* @param array $saml2attributes
* @param bool $retry
* @return array
* @throws EngineBlock_Exception
* @throws EngineBlock_Exception_MissingRequiredFields
*/
public function registerUser(array $saml2attributes)
public function registerUser(array $saml2attributes, $retry = true)
{
$ldapAttributes = $this->_getSaml2AttributesFieldMapper()->saml2AttributesToLdapAttributes($saml2attributes);
$ldapAttributes = $this->_enrichLdapAttributes($ldapAttributes, $saml2attributes);
Expand All @@ -107,8 +108,8 @@ public function registerUser(array $saml2attributes)
// not returning a user, then another process registering the user, then the current process failing to
// add the user because it was already added...
// So if a user has already been added we simply try again
if ($e->getCode() === Zend_Ldap_Exception::LDAP_ALREADY_EXISTS) {
return $this->registerUser($saml2attributes);
if ($retry && $e->getCode() === Zend_Ldap_Exception::LDAP_ALREADY_EXISTS) {
return $this->registerUser($saml2attributes, false);
}
else {
throw new EngineBlock_Exception("LDAP failure", EngineBlock_Exception::CODE_ALERT, $e);
Expand Down

0 comments on commit 4f6136c

Please sign in to comment.