@@ -25,8 +25,8 @@ and query against an LDAP server.
25
25
26
26
The ``Ldap `` class uses an :class: `Symfony\\ Component\\ Ldap\\ Adapter\\ AdapterInterface `
27
27
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:
30
30
31
31
``host ``
32
32
IP or hostname of the LDAP server
@@ -38,31 +38,39 @@ using the following options:
38
38
The version of the LDAP protocol to use
39
39
40
40
``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
42
49
43
50
``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> `
45
53
46
54
For example, to connect to a start-TLS secured LDAP server::
47
55
48
- use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
49
56
use Symfony\Component\Ldap\Ldap;
50
57
51
- $adapter = new Adapter( array(
58
+ $ldap = Ldap::create('ext_ldap', array(
52
59
'host' => 'my-server',
53
- 'port' => 389,
54
- 'encryption' => 'tls',
55
- 'options' => array(
56
- 'protocol_version' => 3,
57
- 'referrals' => false,
58
- ),
60
+ 'encryption' => 'ssl',
59
61
));
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'));
61
68
62
69
The :method: `Symfony\\ Component\\ Ldap\\ Ldap::bind ` method
63
70
authenticates a previously configured connection using both the
64
71
distinguished name (DN) and the password of a user::
65
72
73
+ use Symfony\Component\Ldap\Ldap;
66
74
// ...
67
75
68
76
$ldap->bind($dn, $password);
@@ -71,6 +79,7 @@ Once bound (or if you enabled anonymous authentication on your
71
79
LDAP server), you may query the LDAP server using the
72
80
:method: `Symfony\\ Component\\ Ldap\\ Ldap::query ` method::
73
81
82
+ use Symfony\Component\Ldap\Ldap;
74
83
// ...
75
84
76
85
$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'
85
94
array, you may use the
86
95
:method: `Symfony\\ Component\\ Ldap\\ Adapter\\ ExtLdap\\ Collection::toArray ` method::
87
96
97
+ use Symfony\Component\Ldap\Ldap;
88
98
// ...
89
99
90
100
$query = $ldap->query('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))');
91
101
$results = $query->execute()->toArray();
92
102
93
103
// Do something with the results array
94
104
95
- Creating or updating entries
105
+ Creating or Updating Entries
96
106
----------------------------
97
107
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::
100
110
111
+ use Symfony\Component\Ldap\Ldap;
101
112
use Symfony\Component\Ldap\Entry;
102
113
// ...
103
114
0 commit comments