Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee4d9a7

Browse files
csarrazifabpot
authored andcommitted
[Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry
1 parent81ad336 commitee4d9a7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎src/Symfony/Component/Security/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-
publicfunctiontestLoadUserByUsernameFailsIfEntryHasNoUidKeyAttribute()
154+
publicfunctiontestLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute()
158155
{
159156
$result =$this->getMockBuilder(CollectionInterface::class)->getMock();
160157
$query =$this->getMockBuilder(QueryInterface::class)->getMock();

‎src/Symfony/Component/Security/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
publicfunction__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
protectedfunctionloadUser($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)

[8]ページ先頭

©2009-2025 Movatter.jp