Skip to content

Commit cb8f129

Browse files
arkstechalasr
authored andcommitted
[Ldap] fix refreshUser() ignoring extra_fields
1 parent 5b719d1 commit cb8f129

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function refreshUser(UserInterface $user)
108108
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
109109
}
110110

111-
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles());
111+
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles(), $user->getExtraFields());
112112
}
113113

114114
/**

src/Symfony/Component/Ldap/Tests/Security/LdapUserProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,14 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
330330
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);
331331
$this->assertInstanceOf(LdapUser::class, $provider->loadUserByUsername('foo'));
332332
}
333+
334+
public function testRefreshUserShouldReturnUserWithSameProperties()
335+
{
336+
$ldap = $this->createMock(LdapInterface::class);
337+
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword', ['email']);
338+
339+
$user = new LdapUser(new Entry('foo'), 'foo', 'bar', ['ROLE_DUMMY'], ['email' => 'foo@symfony.com']);
340+
341+
$this->assertEquals($user, $provider->refreshUser($user));
342+
}
333343
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy