2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 07:50:41 +00:00
|
|
|
<!-- $Revision$ -->
|
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>
|
2016-01-30 12:57:21 +00:00
|
|
|
<methodparam choice="opt"><type>string</type><parameter>host</parameter><initializer>&null;</initializer></methodparam>
|
2009-01-13 12:47:53 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>389</initializer></methodparam>
|
2007-02-04 22:46:33 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2016-01-30 12:57:21 +00:00
|
|
|
Creates an LDAP link identifier and checks whether the given
|
|
|
|
<parameter>host</parameter> and <parameter>port</parameter> are plausible.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Note: This function does <emphasis>not</emphasis> open a connection.
|
|
|
|
It checks whether the given parameters are plausibe and can be used
|
|
|
|
to open a connection as soon as one is needed.
|
2007-02-04 22:48:23 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2016-01-30 12:57:21 +00:00
|
|
|
<term><parameter>host</parameter></term>
|
2007-02-04 22:48:23 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2016-01-30 12:57:21 +00:00
|
|
|
This field supports using a hostname or, with OpenLDAP 2.x.x and
|
|
|
|
later, a full LDAP URI of the form <literal>ldap://hostname:port</literal>
|
|
|
|
or <literal>ldaps://hostname:port</literal> for SSL encryption.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
You can also provide multiple LDAP-URIs separated by a space as one string
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Note that <literal>hostname:port</literal> is not a supported LDAP URI as the schema is missing.
|
2007-02-04 22:48:23 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>port</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2016-01-30 12:57:21 +00:00
|
|
|
The port to connect to. Not used when using LDAP URIs.
|
2007-02-04 22:48:23 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2016-01-30 12:57:21 +00:00
|
|
|
Returns a positive LDAP link identifier when the provided hostname/port combination or LDAP URI
|
|
|
|
seems plausible. It's a syntactic check of the provided parameters but the server(s) will not
|
|
|
|
be contacted! If the syntactic check fails it returns &false;.
|
2007-02-04 22:48:23 +00:00
|
|
|
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="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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
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
|
|
|
|
-->
|