@@ -49,8 +49,8 @@ The providers are configured to use a default service named ``ldap``,
49
49
but you can override this setting in the security component's
50
50
configuration.
51
51
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:
54
54
55
55
.. configuration-block ::
56
56
@@ -59,13 +59,17 @@ definition:
59
59
# app/config/services.yml
60
60
services :
61
61
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
63
66
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
69
73
70
74
.. code-block :: xml
71
75
@@ -76,31 +80,43 @@ definition:
76
80
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
77
81
78
82
<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 >
85
96
</service >
86
97
</services >
87
98
</container >
88
99
89
100
.. code-block :: php
90
101
91
102
// app/config/services.php
92
- use Symfony\Component\Ldap\LdapClient;
103
+ use Symfony\Component\Ldap\Ldap;
104
+ use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
93
105
use Symfony\Component\DependencyInjection\Definition;
94
106
107
+ $container->register('ldap', Ldap::class)
108
+ ->addArgument(new Reference('ext_ldap_adapter'));
109
+
95
110
$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
+ )));
104
120
105
121
Fetching Users Using the LDAP User Provider
106
122
-------------------------------------------
0 commit comments