1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; 13 14use Symfony\Component\Config\Definition\Builder\NodeDefinition; 15use Symfony\Component\DependencyInjection\ChildDefinition; 16use Symfony\Component\DependencyInjection\ContainerBuilder; 17use Symfony\Component\DependencyInjection\Reference; 18 19/** 20 * FormLoginLdapFactory creates services for form login ldap authentication. 21 * 22 * @author Grégoire Pineau <lyrixx@lyrixx.info> 23 * @author Charles Sarrazin <charles@sarraz.in> 24 */ 25class FormLoginLdapFactory extends FormLoginFactory 26{ 27 protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) 28 { 29 $provider = 'security.authentication.provider.ldap_bind.'.$id; 30 $definition = $container 31 ->setDefinition($provider, new ChildDefinition('security.authentication.provider.ldap_bind')) 32 ->replaceArgument(0, new Reference($userProviderId)) 33 ->replaceArgument(1, new Reference('security.user_checker.'.$id)) 34 ->replaceArgument(2, $id) 35 ->replaceArgument(3, new Reference($config['service'])) 36 ->replaceArgument(4, $config['dn_string']) 37 ; 38 39 if (!empty($config['query_string'])) { 40 $definition->addMethodCall('setQueryString', [$config['query_string']]); 41 } 42 43 return $provider; 44 } 45 46 public function addConfiguration(NodeDefinition $node) 47 { 48 parent::addConfiguration($node); 49 50 $node 51 ->children() 52 ->scalarNode('service')->defaultValue('ldap')->end() 53 ->scalarNode('dn_string')->defaultValue('{username}')->end() 54 ->scalarNode('query_string')->end() 55 ->end() 56 ; 57 } 58 59 public function getKey() 60 { 61 return 'form-login-ldap'; 62 } 63} 64