@@ -49,8 +49,8 @@ The providers are configured to use a default service named ``ldap``,
4949but you can override this setting in the security component's
5050configuration.
5151
52- An LDAP client can be simply configured, using the following service
53- definition:
52+ An LDAP client can be simply configured using the built-in `` ldap `` PHP
53+ extension with the following service definition:
5454
5555.. configuration-block ::
5656
@@ -59,13 +59,17 @@ definition:
5959 # app/config/services.yml
6060 services :
6161 ldap :
62- class : Symfony\Component\Ldap\LdapClient
62+ class : Symfony\Component\Ldap\Ldap
63+ arguments : ['@ext_ldap_adapter']
64+ ext_ldap_adapter :
65+ class : Symfony\Component\Ldap\Adapter\ExtLdap\Adapter
6366 arguments :
64- - my-server # host
65- - 389 # port
66- - 3 # version
67- - false # SSL
68- - true # TLS
67+ - host : my-server
68+ port : 389
69+ encryption : tls
70+ options :
71+ protocol_version : 3
72+ referrals : false
6973
7074 .. code-block :: xml
7175
@@ -76,31 +80,43 @@ definition:
7680 xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
7781
7882 <services >
79- <service id =" ldap" class =" Symfony\Component\Ldap\LdapClient" >
80- <argument >my-server</argument >
81- <argument >389</argument >
82- <argument >3</argument >
83- <argument >false</argument >
84- <argument >true</argument >
83+ <service id =" ldap" class =" Symfony\Component\Ldap\Ldap" >
84+ <argument type =" service" id =" ext_ldap_adapter" />
85+ </service >
86+ <service id =" ext_ldap_adapter" class =" Symfony\Component\Ldap\Adapter\ExtLdap\Adapter" >
87+ <argument type =" collection" >
88+ <argument key =" host" >my-server</argument >
89+ <argument key =" port" >389</argument >
90+ <argument key =" encryption" >tls</argument >
91+ <argument key =" options" type =" collection" >
92+ <argument key =" protocol_version" >3</argument >
93+ <argument key =" referrals" >false</argument >
94+ </argument >
95+ </argument >
8596 </service >
8697 </services >
8798 </container >
8899
89100 .. code-block :: php
90101
91102 // app/config/services.php
92- use Symfony\Component\Ldap\LdapClient;
103+ use Symfony\Component\Ldap\Ldap;
104+ use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
93105 use Symfony\Component\DependencyInjection\Definition;
94106
107+ $container->register('ldap', Ldap::class)
108+ ->addArgument(new Reference('ext_ldap_adapter'));
109+
95110 $container
96- ->setDefinition('ldap', new Definition(LdapClient::class, array(
97- 'my-server',
98- 389,
99- 3,
100- false,
101- true,
102-
103- ));
111+ ->setDefinition('ext_ldap_adapter', new Definition(Adapter::class, array(
112+ 'host' => 'my-server',
113+ 'port' => 389,
114+ 'encryption' => 'tls',
115+ 'options' => array(
116+ 'protocol_version' => 3,
117+ 'referrals' => false
118+ )
119+ )));
104120
105121 Fetching Users Using the LDAP User Provider
106122-------------------------------------------
0 commit comments