Skip to content

Commit 2afbe31

Browse files
author
nietonfir
committed
Use the Ldap factory in the ldap service definition
as LdapClient has been marked deprecated in 3.1. Refs symfony/symfony#19008
1 parent 6ff52a6 commit 2afbe31

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

security/ldap.rst

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ definition:
5959
# app/config/services.yml
6060
services:
6161
ldap:
62-
class: Symfony\Component\Ldap\LdapClient
62+
class: Symfony\Component\Ldap\Ldap
63+
factory: [Symfony\Component\Ldap\Ldap, 'create']
6364
arguments:
64-
- my-server # host
65-
- 389 # port
66-
- 3 # version
67-
- false # SSL
68-
- true # TLS
65+
- 'ext_ldap' # associated adapter - only one currently
66+
- host: '127.0.0.1' # host
67+
port: '389' # port
68+
version: 3 # version
69+
encryption: 'none' # either 'tls', 'ssl' or 'none'
70+
debug: false, # Enable debugging output
71+
referrals: false # Follow referrals returned by the server
72+
options: [] # additional PHP LDAP options
73+
# see http://php.net/manual/en/function.ldap-set-option.php
6974
7075
.. code-block:: xml
7176
@@ -76,12 +81,18 @@ definition:
7681
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
7782
7883
<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>
84+
<service id="ldap" class="Symfony\Component\Ldap\Ldap">
85+
<factory class="Symfony\Component\Ldap\Ldap" method="create" />
86+
<argument>ext_ldap</argument>
87+
<argument type="collection">
88+
<argument key="host">127.0.0.1</argument>
89+
<argument key="port">389</argument>
90+
<argument key="version">3</argument>
91+
<argument key="encryption">none</argument>
92+
<argument key="debug">false</argument>
93+
<argument key="referrals">false</argument>
94+
<argument key="options" type="collection"></argument>
95+
</argument>
8596
</service>
8697
</services>
8798
</container>
@@ -94,12 +105,16 @@ definition:
94105
95106
$container
96107
->setDefinition('ldap', new Definition(LdapClient::class, array(
97-
'my-server',
98-
389,
99-
3,
100-
false,
101-
true,
102-
108+
'ext_ldap',
109+
array(
110+
'host' => '127.0.0.1'
111+
'port' => '389'
112+
'version' => 3
113+
'encryption' => 'none'
114+
'debug' => false,
115+
'referrals' => false
116+
'options' => array()
117+
)
103118
));
104119
105120
Fetching Users Using the LDAP User Provider

0 commit comments

Comments
 (0)