php-doc-en/reference/ldap/functions/ldap-connect.xml
Daniel Egeberg 2b587ab01f Normalized initializer NULL-values to use the &null; entity:
for file in `find -name '*.xml'`; do sed -i -e 's/<initializer>null<\/initializer>/<initializer>\&null;<\/initializer>/i' $file; done



git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@298918 c90b9560-bf6c-de11-be94-00142212c4b1
2010-05-03 17:10:04 +00:00

161 lines
4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.ldap-connect" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ldap_connect</refname>
<refpurpose>Connect to an LDAP server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>ldap_connect</methodname>
<methodparam choice="opt"><type>string</type><parameter>hostname</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>389</initializer></methodparam>
</methodsynopsis>
<para>
Establishes a connection to a LDAP server on a specified
<parameter>hostname</parameter> and <parameter>port</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>hostname</parameter></term>
<listitem>
<para>
If you are using OpenLDAP 2.x.x you can specify a URL instead of the
hostname. To use LDAP with SSL, compile OpenLDAP 2.x.x with SSL
support, configure PHP with SSL, and set this parameter as
<literal>ldaps://hostname/</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>port</parameter></term>
<listitem>
<para>
The port to connect to. Not used when using URLs.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a positive LDAP link identifier on success, or &false; on error.
When OpenLDAP 2.x.x is used, <function>ldap_connect</function> will always
return a <type>resource</type> as it does not actually connect but just
initializes the connecting parameters. The actual connect happens with
the next calls to ldap_* funcs, usually with
<function>ldap_bind</function>.
</para>
<para>
If no arguments are specified then the link identifier of the already
opened link will be returned.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>4.0.4</entry>
<entry>
URL and SSL support was added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Example of connecting to LDAP server.</title>
<programlisting role="php">
<![CDATA[
<?php
// LDAP variables
$ldaphost = "ldap.example.com"; // your ldap servers
$ldapport = 389; // your ldap server's port number
// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost");
?>
]]>
</programlisting>
</example>
<example>
<title>Example of connecting securely to LDAP server.</title>
<programlisting role="php">
<![CDATA[
<?php
// make sure your host is the correct one
// that you issued your secure certificate to
$ldaphost = "ldaps://ldap.example.com/";
// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost)
or die("Could not connect to {$ldaphost}");
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>ldap_bind</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->