From e38e58c6047c2e17c604c4836b54582b15c6329d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 26 May 2017 17:59:13 +0200 Subject: [PATCH 1/2] use Ldap instead of the deprecated LdapClient --- components/ldap.rst | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/components/ldap.rst b/components/ldap.rst index b1f51043dd4..455207bff75 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -20,10 +20,12 @@ You can install the component in 2 different ways: Usage ----- -The :class:`Symfony\\Component\\Ldap\\LdapClient` class provides methods -to authenticate and query against an LDAP server. +The :class:`Symfony\\Component\\Ldap\\Ldap` class provides methods to authenticate +and query against an LDAP server. -The :class:`Symfony\\Component\\Ldap\\LdapClient` class can be configured +The ``Ldap`` class uses an :class:`Symfony\\Component\\Ldap\\Adapter\\AdapterInterface` +to communicate with an LDAP server. The :class:`adapter ` +for PHP's built-in LDAP extension, for example, can be configured using the following options: ``host`` @@ -47,24 +49,32 @@ using the following options: For example, to connect to a start-TLS secured LDAP server:: - use Symfony\Component\Ldap\LdapClient; - - $ldap = new LdapClient('my-server', 389, 3, false, true); - -The :method:`Symfony\\Component\\Ldap\\LdapClient::bind` method + use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter; + use Symfony\Component\Ldap\Ldap; + + $adapter = new Adapter(array( + 'host' => 'my-server', + 'port' => 389, + 'encryption' => 'tls', + 'options' => array( + 'protocol_version' => 3, + 'referrals' => false, + ), + )); + $ldap = new Ldap($adapter); + +The :method:`Symfony\\Component\\Ldap\\Ldap::bind` method authenticates a previously configured connection using both the distinguished name (DN) and the password of a user:: - use Symfony\Component\Ldap\LdapClient; // ... $ldap->bind($dn, $password); Once bound (or if you enabled anonymous authentication on your LDAP server), you may query the LDAP server using the -:method:`Symfony\\Component\\Ldap\\LdapClient::find` method:: +:method:`Symfony\\Component\\Ldap\\Ldap::find` method:: - use Symfony\Component\Ldap\LdapClient; // ... $ldap->find('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))'); From 2b990f4bdb3e05eec6ac31cd4c74f3673c13df3c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 28 May 2017 13:45:54 +0200 Subject: [PATCH 2/2] Fixed code indentation --- components/ldap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/ldap.rst b/components/ldap.rst index 455207bff75..ac676cd5934 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -55,11 +55,11 @@ For example, to connect to a start-TLS secured LDAP server:: $adapter = new Adapter(array( 'host' => 'my-server', 'port' => 389, - 'encryption' => 'tls', - 'options' => array( - 'protocol_version' => 3, - 'referrals' => false, - ), + 'encryption' => 'tls', + 'options' => array( + 'protocol_version' => 3, + 'referrals' => false, + ), )); $ldap = new Ldap($adapter);