8000 [Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry by csarrazi · Pull Request #21579 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry #21579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading 8000
Diff view
Diff view
Next Next commit
LdapUserProvider should not throw an exception if the uid key does no…
…t exist in the response
  • Loading branch information
csarrazi committed Feb 10, 2017
commit 193a553ddb6e74cc4deddd2a4c645ab08931496b
11 changes: 9 additions & 2 deletions src/Symfony/Component/Security/Core/User/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LdapUserProvider implements UserProviderInterface
public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null)
{
if (null === $uidKey) {
$uidKey = 'uid';
$uidKey = 'sAMAccountName';
}

$this->ldap = $ldap;
Expand Down Expand Up @@ -87,7 +87,13 @@ public function loadUserByUsername($username)
}

$entry = $entries[0];
$username = $this->getAttributeValue($entry, $this->uidKey);

try {
if (null !== $this->uidKey) {
$username = $this->getAttributeValue($entry, $this->uidKey);
}
} catch (InvalidArgumentException $e) {
}

return $this->loadUser($username, $entry);
}
Expand Down Expand Up @@ -123,6 +129,7 @@ public function supportsClass($class)
protected function loadUser($username, Entry $entry)
{
$password = null;

if (null !== $this->passwordAttribute) {
$password = $this->getAttributeValue($entry, $this->passwordAttribute);
}
Expand Down
0