Cradle  0.3.3
Simple library for creating Web-based applications
Ldap Class Reference

LDAP request wrapper. More...

Static Public Member Functions

static connect ($connection=null)
 
static request ($query, $data=null, $connection=null, $type="select", $returnStatment=false)
 
static getLastError ()
 
static destroy ()
 

Static Public Attributes

static $default
 

Detailed Description

LDAP request wrapper.

A simple LDAP request wrapper class. Designed to make simple LDAP requests more easy and short.

Version
3.0
Author
Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru

Example of usage:

<?php
//--- Set the connection params:
$conn = [
"type" => "ldal",
"host" => "ldapserver",
"base" => "dc=...,dc=...,dc=...",
"user" => "username@domain",
"pass" => "password"
];
//--- Open connection (option):
if ( $dbh = Ldap::connect($conn) ) {
echo "Connected. ";
} else {
die (print_r(Ldap::getLastError(), true));
}
//--- Get some data from LDAP server:
print_r( Ldap::request( "(|(sn=$person*)(givenname=$person*))", array("cn","title","memberOf"), $conn) );
print_r( Ldap::request( "sn=some body*", "cn,title,memberOf" ) );
print_r( Ldap::request( "cn=John S*", "cn,title,department,l,co,memberOf,mail,mailNickname,telephoneNumber", $conn) );
print_r( Ldap::request( "cn=John S*" ) );

Member Function Documentation

static connect (   $connection = null)
static

Connect to LDAP server (option)

Parameters
array$connectionAn array of connection params:
[
"host" => "...",
"base" => "...",
"user" => "...",
"pass" => "...",
"attributes" => "...",
]
Returns
false | LDAP_resource_id
static destroy ( )
static

Destructor

static getLastError ( )
static

Returns the last error of request

Returns
array An array contains: [code, message, query]
static request (   $query,
  $data = null,
  $connection = null,
  $type = "select",
  $returnStatment = false 
)
static

Execute LDAP request (LDAP search)

Parameters
string$queryLDAP filter
array$dataLDAP attributes ()
array$connection(option) An array of connection params (see a method connect)
string$typetype of request [ not used ] default = "select"
boolean$returnStatmentTRUE = return raw data (LDAP response entries)
Returns
false | array | rowCount

Field Documentation

$default
static
Initial value:
= array(
"type" => "ldap",
"host" => "localhost",
"base" => "",
"user" => "",
"pass" => "",
"attributes" => "cn",
)

The documentation for this class was generated from the following file: