Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 5651c6b

Browse files
Merge branch '3.2'
* 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 ...
2 parents ae24bb9 + 7d9766e commit 5651c6b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Core/Tests/User/LdapUserProviderTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
151151
);
152152
}
153153

154-
/**
155-
* @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
156-
*/
157-
public function testLoadUserByUsernameFailsIfEntryHasNoUidKeyAttribute()
154+
public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute()
158155
{
159156
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
160157
$query = $this->getMockBuilder(QueryInterface::class)->getMock();

Core/User/LdapUserProvider.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class LdapUserProvider implements UserProviderInterface
4848
public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null)
4949
{
5050
if (null === $uidKey) {
51-
$uidKey = 'uid';
51+
$uidKey = 'sAMAccountName';
5252
}
5353

5454
$this->ldap = $ldap;
@@ -87,7 +87,13 @@ public function loadUserByUsername($username)
8787
}
8888

8989
$entry = $entries[0];
90-
$username = $this->getAttributeValue($entry, $this->uidKey);
90+
91+
try {
92+
if (null !== $this->uidKey) {
93+
$username = $this->getAttributeValue($entry, $this->uidKey);
94+
}
95+
} catch (InvalidArgumentException $e) {
96+
}
9197

9298
return $this->loadUser($username, $entry);
9399
}
@@ -123,6 +129,7 @@ public function supportsClass($class)
123129
protected function loadUser($username, Entry $entry)
124130
{
125131
$password = null;
132+
126133
if (null !== $this->passwordAttribute) {
127134
$password = $this->getAttributeValue($entry, $this->passwordAttribute);
128135
}

0 commit comments

Comments
 (0)