Skip to content

Commit 9f34a7e

Browse files
committed
Document that the 2nd parameter of ldap_connect is deprecated
This is only a soft deprecation, since otherwise a lot of existing code would break. Still, preferably an LDAP-URI should be passed to ldap_connect(). Based on a patch provided by heiglandreas@php.net git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@347310 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 7594fc0 commit 9f34a7e

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

reference/ldap/functions/ldap-connect.xml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
<refsect1 role="description">
1010
&reftitle.description;
11+
<methodsynopsis>
12+
<type>resource</type><methodname>ldap_connect</methodname>
13+
<methodparam choice="opt"><type>string</type><parameter>ldap_uri</parameter><initializer>&null;</initializer></methodparam>
14+
</methodsynopsis>
15+
<warning>
16+
<simpara>
17+
The <emphasis>following</emphasis> signature is still supported for backwards
18+
compatibility, but is considered deprecated and should not be used anymore!
19+
</simpara>
20+
</warning>
1121
<methodsynopsis>
1222
<type>resource</type><methodname>ldap_connect</methodname>
1323
<methodparam choice="opt"><type>string</type><parameter>host</parameter><initializer>&null;</initializer></methodparam>
@@ -31,11 +41,10 @@
3141
<para>
3242
<variablelist>
3343
<varlistentry>
34-
<term><parameter>host</parameter></term>
44+
<term><parameter>ldap_uri</parameter></term>
3545
<listitem>
3646
<para>
37-
This field supports using a hostname or, with OpenLDAP 2.x.x and
38-
later, a full LDAP URI of the form <literal>ldap://hostname:port</literal>
47+
A full LDAP URI of the form <literal>ldap://hostname:port</literal>
3948
or <literal>ldaps://hostname:port</literal> for SSL encryption.
4049
</para>
4150
<para>
@@ -46,11 +55,19 @@
4655
</para>
4756
</listitem>
4857
</varlistentry>
58+
<varlistentry>
59+
<term><parameter>host</parameter></term>
60+
<listitem>
61+
<para>
62+
The hostname to connect to.
63+
</para>
64+
</listitem>
65+
</varlistentry>
4966
<varlistentry>
5067
<term><parameter>port</parameter></term>
5168
<listitem>
5269
<para>
53-
The port to connect to. Not used when using LDAP URIs.
70+
The port to connect to.
5471
</para>
5572
</listitem>
5673
</varlistentry>
@@ -61,17 +78,17 @@
6178
<refsect1 role="returnvalues">
6279
&reftitle.returnvalues;
6380
<para>
64-
Returns a positive LDAP link identifier when the provided hostname/port combination or LDAP URI
65-
seems plausible. It's a syntactic check of the provided parameters but the server(s) will not
81+
Returns a positive LDAP link identifier when the provided LDAP URI
82+
seems plausible. It's a syntactic check of the provided parameter but the server(s) will not
6683
be contacted! If the syntactic check fails it returns &false;.
67-
When OpenLDAP 2.x.x is used, <function>ldap_connect</function> will always
84+
<function>ldap_connect</function> will otherwise
6885
return a <type>resource</type> as it does not actually connect but just
6986
initializes the connecting parameters. The actual connect happens with
7087
the next calls to ldap_* funcs, usually with
7188
<function>ldap_bind</function>.
7289
</para>
7390
<para>
74-
If no arguments are specified then the link identifier of the already
91+
If no argument is specified then the link identifier of the already
7592
opened link will be returned.
7693
</para>
7794
</refsect1>
@@ -86,12 +103,11 @@
86103
<?php
87104
88105
// LDAP variables
89-
$ldaphost = "ldap.example.com"; // your ldap servers
90-
$ldapport = 389; // your ldap server's port number
106+
$ldapuri = "ldap://ldap.example.com:389"; // your ldap-uri
91107
92108
// Connecting to LDAP
93-
$ldapconn = ldap_connect($ldaphost, $ldapport)
94-
or die("Could not connect to $ldaphost");
109+
$ldapconn = ldap_connect($ldapuri)
110+
or die("That LDAP-URI was not parseable");
95111
96112
?>
97113
]]>
@@ -109,7 +125,7 @@ $ldaphost = "ldaps://ldap.example.com/";
109125
110126
// Connecting to LDAP
111127
$ldapconn = ldap_connect($ldaphost)
112-
or die("Could not connect to {$ldaphost}");
128+
or die("That LDAP-URI was not parseable");
113129
114130
?>
115131
]]>

0 commit comments

Comments
 (0)