Skip to content

Commit

Permalink
Fixed issue #10323: LDAP Authentication not working
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed May 12, 2016
1 parent e018d00 commit 9c19c83
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions application/core/plugins/AuthLDAP/AuthLDAP.php
Expand Up @@ -506,24 +506,10 @@ public function newUserSession()
}

// Authentication was successful, now see if we have a user or that we should create one
if (is_null($user)) {
if ($this->autoCreate === true) {
/*
* Dispatch the newUserLogin event, and hope that after this we can find the user
* this allows users to create their own plugin for handling the user creation
* we will need more methods to pass username, rdn and ldap connection.
*/
$this->pluginManager->dispatchEvent(new PluginEvent('newUserLogin', $this));

// Check ourselves, we do not want fake responses from a plugin
$user = $this->api->getUserByName($username);
}

if (is_null($user)) {
if (is_null($user) && !$autoCreateFlag) {
$this->setAuthFailure(self::ERROR_USERNAME_INVALID);
ldap_close($ldapconn); // all done? close connection
return;
}
}

ldap_close($ldapconn); // all done? close connection
Expand All @@ -535,15 +521,15 @@ public function newUserSession()
{
Permission::model()->setGlobalPermission($iNewUID, 'surveys', array('create_p'));
}
$user = $this->api->getUserByName($username);
if ($user === null)
{
$this->setAuthFailure(self::ERROR_USERNAME_INVALID, gT('Credentials are valid but we failed to create a user'));
return;
}
}
$user = $this->api->getUserByName($username);
if ($user === null)
{
$this->setAuthFailure(self::ERROR_USERNAME_INVALID, gT('Credentials are valid but we failed to create a user'));
return;
}

// If we made it here, authentication was a success and we do have a valid user
$this->pluginManager->dispatchEvent(new PluginEvent('newUserLogin', $this));
$this->setAuthSuccess($user);
}
}

0 comments on commit 9c19c83

Please sign in to comment.