@@ -59,13 +59,18 @@ 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
+ factory : ['Symfony\Component\Ldap\Ldap', 'create']
63
64
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
69
74
70
75
.. code-block :: xml
71
76
@@ -76,30 +81,44 @@ definition:
76
81
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
77
82
78
83
<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 >
85
96
</service >
86
97
</services >
87
98
</container >
88
99
89
100
.. code-block :: php
101
+ use Symfony\Component\Ldap\Ldap;
102
+ use Symfony\Component\DependencyInjection\Definition;
103
+ // …
90
104
91
105
// app/config/services.php
92
- $container
93
- ->register('ldap', 'Symfony\Component\Ldap\LdapClient')
94
- ->addArgument('my-server')
95
- ->addArgument(389)
96
- ->addArgument(3)
97
- ->addArgument(false)
98
- ->addArgument(true);
106
+ $definition = new Definition(Ldap::class, array(
107
+ 'ext_ldap',
108
+ array(
109
+ 'host' => '127.0.0.1'
110
+ 'port' => '389'
111
+ 'version' => 3
112
+ 'encryption' => 'none'
113
+ 'debug' => false,
114
+ 'referrals' => false
115
+ 'options' => array()
116
+ )
117
+ ));
118
+ $definition->setFactory(array(Ldap::class, 'create'));
99
119
100
120
$container
101
- ->register('newsletter_manager', 'NewsletterManager')
102
- ->addMethodCall('setMailer', array(new Reference('mailer')));
121
+ ->setDefinition('ldap', $definition);
103
122
104
123
Fetching Users Using the LDAP User Provider
105
124
-------------------------------------------
0 commit comments