2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2009-01-13 12:47:53 +00:00
|
|
|
<!-- $Revision: 1.9 $ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.ldap-connect" xmlns="http://docbook.org/ns/docbook">
|
2007-02-04 22:46:33 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>ldap_connect</refname>
|
|
|
|
<refpurpose>Connect to an LDAP server</refpurpose>
|
|
|
|
</refnamediv>
|
2007-02-04 22:48:23 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-02-04 22:46:33 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>resource</type><methodname>ldap_connect</methodname>
|
2009-01-13 12:47:53 +00:00
|
|
|
<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>
|
2007-02-04 22:46:33 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2007-02-04 22:48:23 +00:00
|
|
|
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. Defaults to 389.
|
|
|
|
</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
|
2007-02-04 22:46:33 +00:00
|
|
|
<function>ldap_bind</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
2007-02-04 22:48:23 +00:00
|
|
|
If no arguments are specified then the link identifier of the already
|
|
|
|
opened link will be returned.
|
2007-02-04 22:46:33 +00:00
|
|
|
</para>
|
2007-02-04 22:48:23 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
2007-02-04 22:46:33 +00:00
|
|
|
<para>
|
2007-02-04 22:48:23 +00:00
|
|
|
<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>
|
2007-02-04 22:46:33 +00:00
|
|
|
</para>
|
2007-02-04 22:48:23 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2007-02-04 22:46:33 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Example of connecting to LDAP server.</title>
|
|
|
|
<programlisting role="php">
|
2002-12-02 15:13:07 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// LDAP variables
|
|
|
|
$ldaphost = "ldap.example.com"; // your ldap servers
|
|
|
|
$ldapport = 389; // your ldap server's port number
|
|
|
|
|
|
|
|
// Connecting to LDAP
|
2007-02-04 22:46:33 +00:00
|
|
|
$ldapconn = ldap_connect($ldaphost, $ldapport)
|
2003-12-15 16:55:22 +00:00
|
|
|
or die("Could not connect to $ldaphost");
|
2002-12-02 15:13:07 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
2007-02-04 22:46:33 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
<example>
|
|
|
|
<title>Example of connecting securely to LDAP server.</title>
|
|
|
|
<programlisting role="php">
|
2002-12-02 15:13:07 +00:00
|
|
|
<![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
|
2007-02-04 22:46:33 +00:00
|
|
|
$ldapconn = ldap_connect($ldaphost)
|
2003-12-15 16:55:22 +00:00
|
|
|
or die("Could not connect to {$ldaphost}");
|
2002-12-02 15:13:07 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
2007-02-04 22:46:33 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2007-02-04 22:48:23 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2007-02-04 22:46:33 +00:00
|
|
|
<para>
|
2007-02-04 22:48:23 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>ldap_bind</function></member>
|
|
|
|
</simplelist>
|
2007-02-04 22:46:33 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-02-04 22:48:23 +00:00
|
|
|
|
2007-02-04 22:46:33 +00:00
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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:"../../../../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
|
|
|
|
-->
|