Skip to content

Commit b57c669

Browse files
committed
minor #6982 [Ldap] Updated Ldap component documentation for 3.1 (csarrazi, javiereguiluz)
This PR was submitted for the 3.1 branch but it was merged into the 3.3 branch instead (closes #6982). Discussion ---------- [Ldap] Updated Ldap component documentation for 3.1 | Q | A | | --- | --- | | Doc fix? | no | | New docs? | yes | | Applies to | 3.1, 3.2 | | Fixed tickets | #5756 | Unfortunately, I didn't have the time to update the docs since I have been pretty busy these last months, but like people say, better late than never! The documentation has been updated for version 3.1 of the Ldap component, which no longer uses the same class, and now provides an LdapManager which can create new LDAP entries, or manipulate existing ones (update or delete). I didn't add a documentation section regarding the legacy classes, but I figure that they should no longer be described as the main entry points for the Ldap component. Commits ------- 066f5be Minor fixes 78ed43d Updated LDAP documentation for Symfony 3.1
2 parents baab8dc + 066f5be commit b57c669

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

components/ldap.rst

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ and query against an LDAP server.
2525

2626
The ``Ldap`` class uses an :class:`Symfony\\Component\\Ldap\\Adapter\\AdapterInterface`
2727
to communicate with an LDAP server. The :class:`adapter <Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\Adapter>`
28-
for PHP's built-in LDAP extension, for example, can be configured
29-
using the following options:
28+
for PHP's built-in LDAP extension, for example, can be configured using the
29+
following options:
3030

3131
``host``
3232
IP or hostname of the LDAP server
@@ -38,31 +38,39 @@ using the following options:
3838
The version of the LDAP protocol to use
3939

4040
``encryption``
41-
The encryption protocol : ``ssl``, ``tls`` or ``none`` (default)
41+
The encryption protocol: ``ssl``, ``tls`` or ``none`` (default)
42+
43+
``connection_string``
44+
  You may use this option instead of ``host`` and ``port`` to connect to the
45+
LDAP server
46+
47+
``optReferrals``
48+
Specifies whether to automatically follow referrals returned by the LDAP server
4249

4350
``options``
44-
LDAP server's options as defined in :class:`ConnectionOptions <Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\ConnectionOptions>`
51+
LDAP server's options as defined in
52+
:class:`ConnectionOptions <Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\ConnectionOptions>`
4553

4654
For example, to connect to a start-TLS secured LDAP server::
4755

48-
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
4956
use Symfony\Component\Ldap\Ldap;
5057

51-
$adapter = new Adapter(array(
58+
$ldap = Ldap::create('ext_ldap', array(
5259
'host' => 'my-server',
53-
'port' => 389,
54-
'encryption' => 'tls',
55-
'options' => array(
56-
'protocol_version' => 3,
57-
'referrals' => false,
58-
),
60+
'encryption' => 'ssl',
5961
));
60-
$ldap = new Ldap($adapter);
62+
63+
Or you could directly specify a connection string::
64+
65+
use Symfony\Component\Ldap\Ldap;
66+
67+
$ldap = Ldap::create('ext_ldap', array('connection_string' => 'ldaps://my-server:636'));
6168

6269
The :method:`Symfony\\Component\\Ldap\\Ldap::bind` method
6370
authenticates a previously configured connection using both the
6471
distinguished name (DN) and the password of a user::
6572

73+
use Symfony\Component\Ldap\Ldap;
6674
// ...
6775

6876
$ldap->bind($dn, $password);
@@ -71,6 +79,7 @@ Once bound (or if you enabled anonymous authentication on your
7179
LDAP server), you may query the LDAP server using the
7280
:method:`Symfony\\Component\\Ldap\\Ldap::query` method::
7381

82+
use Symfony\Component\Ldap\Ldap;
7483
// ...
7584

7685
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
@@ -85,19 +94,21 @@ all entries in a single call and do something with the results'
8594
array, you may use the
8695
:method:`Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\Collection::toArray` method::
8796

97+
use Symfony\Component\Ldap\Ldap;
8898
// ...
8999

90100
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
91101
$results = $query->execute()->toArray();
92102

93103
// Do something with the results array
94104

95-
Creating or updating entries
105+
Creating or Updating Entries
96106
----------------------------
97107

98-
Since version 3.1, The Ldap component provides means to create
99-
new LDAP entries, update or even delete existing ones::
108+
The Ldap component provides means to create new LDAP entries, update or even
109+
delete existing ones::
100110

111+
use Symfony\Component\Ldap\Ldap;
101112
use Symfony\Component\Ldap\Entry;
102113
// ...
103114

0 commit comments

Comments
 (0)