Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 1285

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>ldap_connect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="LDAP functions"
HREF="ref.ldap.html"><LINK
REL="PREVIOUS"
TITLE="ldap_compare"
HREF="function.ldap-compare.html"><LINK
REL="NEXT"
TITLE="ldap_count_entries"
HREF="function.ldap-count-entries.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.ldap-compare.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ldap-count-entries.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ldap-connect"
></A
>ldap_connect</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN42746"
></A
><P
>    (PHP 3, PHP 4 )</P
>ldap_connect&nbsp;--&nbsp;Connect to an LDAP server</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN42749"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>ldap_connect</B
> ( [string hostname [, int port]])<BR
></BR
><P
>&#13;     Returns a positive LDAP link identifier on success, or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on
     error.</P
><P
> 
     <B
CLASS="function"
>ldap_connect()</B
> establishes a connection to a
     LDAP server on a specified <TT
CLASS="parameter"
><I
>hostname</I
></TT
> and
     <TT
CLASS="parameter"
><I
>port</I
></TT
>.  Both the arguments are optional. If
     no arguments are specified then the link identifier of the
     already opened link will be returned. If only
     <TT
CLASS="parameter"
><I
>hostname</I
></TT
> is specified, then the port
     defaults to 389.</P
><P
>&#13;     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 use ldaps://hostname/ as
     host parameter. The port parameter is not used when using URLs.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      URL and SSL support were added in 4.0.4.
     </P
></BLOCKQUOTE
></DIV
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN42770"
></A
><P
><B
>Example 1. Example of connecting to LDAP server.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?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}" );

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN42773"
></A
><P
><B
>Example 2. Example of connecting securely to LDAP server.</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?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}" );

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.ldap-compare.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ldap-count-entries.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>ldap_compare</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.ldap.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>ldap_count_entries</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>