Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
* This file shows you how to connect to a ldap server  using Net_LDAP2.
4
*
5
* It also establishes connections for the other examples;
6
* they include this file to get a ldap link.
7
*/
8
 
9
// Class includes; this assumes Net_LDAP2 installed in PHPs include path
10
// or under subfolder "Net" in the local directory.
11
require_once 'Net/LDAP2.php';
12
 
13
// Configuration
14
// host can be a single server (string) or multiple ones - if we define more
15
// servers here (array), we can implement a basic fail over scenario.
16
// If no credentials (binddn and bindpw) are given, Net_LDAP2 establishes
17
// an anonymous bind.
18
// See the documentation for more information on the configuration items!
19
$ldap_config = array(
20
// 'host'    => 'ldap.example.org',
21
    'host'    => array('ldap1.example.org', 'ldap2.example.org'),
22
// 'binddn'  => 'cn=admin,o=example,dc=org',
23
// 'bindpw'  => 'your-secret-password',
24
    'tls'     => false,
25
    'base'    => 'o=example,dc=org',
26
    'port'    => 389,
27
    'version' => 3,
28
    'filter'  => '(cn=*)',
29
    'scope'   => 'sub'
30
);
31
 
32
// Connect to configured ldap server
33
$ldap = Net_LDAP2::connect($ldap_config);
34
 
35
// It is important to check for errors.
36
// Nearly every method of Net_LDAP2 returns a Net_LDAP2_Error object
37
// if something went wrong. Through this object, you can retrieve detailed
38
// information on what exactly happened.
39
//
40
// Here we drop a die with the error message, so the other example
41
// files will not be calles unless we have a valid link.
42
if (Net_LDAP2::isError($ldap)) {
43
    die('BIND FAILED: '.$ldap->getMessage());
44
}