PHP: ldap_connect - Manual in Deutsh
PHP: ldap_connect - Manual in French
PHP: ldap_connect - Manual in Polish

You Are At PHP: ldap_connect - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

ldap_connect

(PHP 3, PHP 4, PHP 5)

ldap_connect -- Connect to an LDAP server

Description

resource ldap_connect ( [string hostname [, int port]] )

Establishes a connection to a LDAP server on a specified hostname and port.

Parameters

hostname

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 ldaps://hostname/.

port

The port to connect to. Not used when using URLs. Defaults to 389.

Return Values

Returns a positive LDAP link identifier on success, or FALSE on error. When OpenLDAP 2.x.x is used, ldap_connect() will always return a resource 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 ldap_bind().

If no arguments are specified then the link identifier of the already opened link will be returned.

ChangeLog

VersionDescription
4.0.4 URL and SSL support was added.

Examples

Example 1. Example of connecting to LDAP server.

<?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");

?>

Example 2. Example of connecting securely to LDAP server.

<?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}");

?>

See Also

ldap_bind()

Najlepsza ochrona mienia na rynku
tłumaczenia
opakowania z nadrukiem
Najlepsza organizacja eventów Gorąco Polecamy!
Strony internetowe

Another Useful functions:


function.ldap-unbind | function.ldap-t61-to-8859 | function.ldap-start-tls | function.ldap-sort | function.ldap-set-rebind-proc | function.ldap-set-option | function.ldap-search | function.ldap-sasl-bind | function.ldap-rename | function.ldap-read | function.ldap-parse-result | function.ldap-parse-reference | function.ldap-next-reference | function.ldap-next-entry | function.ldap-next-attribute | function.ldap-modify | function.ldap-mod-replace | function.ldap-mod-del | function.ldap-mod-add | function.ldap-list | function.ldap-get-values | function.ldap-get-values-len | function.ldap-get-option | function.ldap-get-entries | function.ldap-get-dn | function.ldap-get-attributes | function.ldap-free-result | function.ldap-first-reference | function.ldap-first-entry | function.ldap-first-attribute | function.ldap-explode-dn | function.ldap-error | function.ldap-errno | function.ldap-err2str | function.ldap-dn2ufn | function.ldap-delete | function.ldap-count-entries | function.ldap-connect | function.ldap-compare | function.ldap-close | function.ldap-bind | function.ldap-add | function.ldap-8859-to-t61 |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.