Skip to content

Commit 8ddd533

Browse files
committed
Merge pull request #1 from nietonfir/http_basic_ldap
Update HttpBasicLdapFactory
2 parents a30191f + a783e5c commit 8ddd533

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HttpBasicLdapFactory extends HttpBasicFactory
2828
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
2929
{
3030
$provider = 'security.authentication.provider.ldap_bind.'.$id;
31-
$container
31+
$definition = $container
3232
->setDefinition($provider, new ChildDefinition('security.authentication.provider.ldap_bind'))
3333
->replaceArgument(0, new Reference($userProvider))
3434
->replaceArgument(1, new Reference('security.user_checker.'.$id))
@@ -40,6 +40,10 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
4040
// entry point
4141
$entryPointId = $this->createEntryPoint($container, $id, $config, $defaultEntryPoint);
4242

43+
if (!empty($config['query_string'])) {
44+
$definition->addMethodCall('setQueryString', array($config['query_string']));
45+
}
46+
4347
// listener
4448
$listenerId = 'security.authentication.listener.basic.'.$id;
4549
$listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.basic'));
@@ -57,6 +61,7 @@ public function addConfiguration(NodeDefinition $node)
5761
->children()
5862
->scalarNode('service')->defaultValue('ldap')->end()
5963
->scalarNode('dn_string')->defaultValue('{username}')->end()
64+
->scalarNode('query_string')->end()
6065
->end()
6166
;
6267
}

src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
9393

9494
if ($this->queryString) {
9595
$query = str_replace('{username}', $username, $this->queryString);
96-
97-
$query = $this->ldap->query($this->dnString, $query);
98-
$result = $query->execute();
96+
$result = $this->ldap->query($this->dnString, $query)->execute();
9997
if (1 !== $result->count()) {
10098
throw new BadCredentialsException('The presented username is invalid.');
10199
}

0 commit comments

Comments
 (0)