Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Updated code example for LDAP integration #7917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 40 additions & 24 deletions 64 security/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ The providers are configured to use a default service named ``ldap``,
but you can override this setting in the security component's
configuration.

An LDAP client can be simply configured, using the following service
definition:
An LDAP client can be simply configured using the built-in ``ldap`` PHP
extension with the following service definition:

.. configuration-block::

Expand All @@ -59,13 +59,17 @@ definition:
# app/config/services.yml
services:
ldap:
class: Symfony\Component\Ldap\LdapClient
arguments:
- my-server # host
- 389 # port
- 3 # version
- false # SSL
- true # TLS
class: Symfony\Component\Ldap\Ldap
arguments: ['@ext_ldap_adapter']
ext_ldap_adapter:
class: Symfony\Component\Ldap\Adapter\ExtLdap\Adapter
arguments:
- host: my-server
port: 389
encryption: tls
options:
protocol_version: 3
referrals: false

.. code-block:: xml

Expand All @@ -76,31 +80,43 @@ definition:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="ldap" class="Symfony\Component\Ldap\LdapClient">
<argument>my-server</argument>
<argument>389</argument>
<argument>3</argument>
<argument>false</argument>
<argument>true</argument>
<service id="ldap" class="Symfony\Component\Ldap\Ldap">
<argument type="service" id="ext_ldap_adapter" />
</service>
<service id="ext_ldap_adapter" class="Symfony\Component\Ldap\Adapter\ExtLdap\Adapter">
<argument type="collection">
<argument key="host">my-server</argument>
<argument key="port">389</argument>
<argument key="encryption">tls</argument>
<argument key="options" type="collection">
<argument key="protocol_version">3</argument>
<argument key="referrals">false</argument>
</argument>
</argument>
</service>
</services>
</container>

.. code-block:: php

// app/config/services.php
use Symfony\Component\Ldap\LdapClient;
use Symfony\Component\Ldap\Ldap;
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
use Symfony\Component\DependencyInjection\Definition;

$container->register('ldap', Ldap::class)
->addArgument(new Reference('ext_ldap_adapter'));

$container
->setDefinition('ldap', new Definition(LdapClient::class, array(
'my-server',
389,
3,
false,
true,

));
->setDefinition('ext_ldap_adapter', new Definition(Ldap::class, array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be Adapter::class instead of Ldap::class here

'host' => 'my-server',
'port' => 389,
'encryption' => 'tls',
'options' => array(
'protocol_version' => 3,
'referrals' => false
)
)));

Fetching Users Using the LDAP User Provider
-------------------------------------------
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.