Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Merge branch '3.2'
Browse files Browse the repository at this point in the history
* 3.2: (27 commits)
  Improve tracking of environment variables in the case of private services
  [DI] Align AutowirePass with 2.8
  property constraints can be added in child classes
  added test for staticClassLoader in LazyLoadingMetadatafactory
  fixed PHPUnit setUp and tearDown method visibility
  spelling fixes
  Readd Symfony version status in the toolbar
  [Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry
  make sure that null can be the invalid value
  [VarDumper] Improve dump of AMQP* Object
  Fix annotations cache folder path
  [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap
  Ignore missing 'debug.file_link_formatter' service in Debug bundle
  [VarDumper] Fixed dumping of terminated generator
  bumped Symfony version to 3.2.4
  updated VERSION for 3.2.3
  updated CHANGELOG for 3.2.3
  bumped Symfony version to 2.8.18
  updated VERSION for 2.8.17
  updated CHANGELOG for 2.8.17
  ...
  • Loading branch information
nicolas-grekas committed Feb 14, 2017
2 parents ae24bb9 + 7d9766e commit 5651c6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 1 addition & 4 deletions Core/Tests/User/LdapUserProviderTest.php
Expand Up @@ -151,10 +151,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
);
}

/**
* @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
*/
public function testLoadUserByUsernameFailsIfEntryHasNoUidKeyAttribute()
public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute()
{
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
Expand Down
11 changes: 9 additions & 2 deletions Core/User/LdapUserProvider.php
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 comments on commit 5651c6b

Please sign in to comment.