\Hazaar\Net
LDAP
LDAP access class

LDAP is the Lightweight Directory Access Protocol, and is a protocol used to access “Directory Servers”. The Directory is a special kind of database that holds information in a tree structure.

The concept is similar to your hard disk directory structure, except that in this context, the root directory is “The world” and the first level subdirectories are “countries”. Lower levels of the directory structure contain entries for companies, organisations or places, while yet lower still we find directory entries for people, and perhaps equipment or documents.

Tags

Since

2.0.1

@module ldap

Summary
Methods Properties Constants
add
No constants
Properties
$conn
$conn
$suffix
$suffix
Methods
__construct()
__construct($host, $port = 389, $version = 3)
LDAP constructor.

Parameters

$hoststring

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/.

$portint

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

$versionint

The LDAP protocol version used to communicate with the server.

add()
add($dn, $entry) : bool
Add entries to LDAP directory

Parameters

$dnstring

The distinguished name of an LDAP entity.

$entryarray

An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0.

Returns

\Hazaar\Net\bool
bind()
bind($user, $secret)

Parameters

$user

No description

$secret

No description

delete()
delete($dn) : bool
Delete an entry from a directory

Parameters

$dnstring

The distinguished name of an LDAP entity.

Returns

\Hazaar\Net\bool
mod_add()
mod_add($dn, $entry) : bool
Add attribute values to current attributes

Adds one or more attributes to the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level additions are done by the Hazaar\LDAP::add() function.

Parameters

$dnstring

The distinguished name of an LDAP entity.

$entryarray

No description

Returns

\Hazaar\Net\bool
mod_del()
mod_del($dn, $entry) : bool
Delete attribute values from current attributes

Removes one or more attributes from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level deletions are done by the Hazaar\LDAP::delete() function.

Parameters

$dnstring

The distinguished name of an LDAP entity.

$entryarray

No description

Returns

\Hazaar\Net\bool
mod_replace()
mod_replace($dn, $entry) : bool
Replace attribute values to current attributes

Replaces one or more attributes from the specified dn. It performs the modification at the attribute level as opposed to the object level. Object-level modifications are done by the Hazaar\LDAP::modify() function.

Parameters

$dnstring

The distinguished name of an LDAP entity.

$entryarray

No description

Returns

\Hazaar\Net\bool
modify()
modify($dn, $entry) : bool
Modify the existing entries in the LDAP directory.

The structure of the entry is same as in Hazaar\LDAP::add().

Parameters

$dnstring

The distinguished name of an LDAP entity.

$entryarray

An array that specifies the information about the entry. The values in the entries are indexed by individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0.

Returns

\Hazaar\Net\bool
search()
search($filter, $base = null, $attributes = null, $attrsonly = null, $sizelimit = null, $timelimit = null, $deref = null) : array
Search LDAP tree

Performs the search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory.

Parameters

$filterstring

The search filter can be simple or advanced, using boolean operators in the format described in the LDAP documentation (see the ยป Netscape Directory SDK for full information on filters).

$basestring

The base DN for the directory.

$attributesnull

An array of the required attributes, e.g. array(“mail”, “sn”, “cn”). Note that the “dn” is always returned irrespective of which attributes types are requested.

Using this parameter is much more efficient than the default action (which is to return all attributes and their associated values). The use of this parameter should therefore be considered good practice.
$attrsonlynull

Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour.

$sizelimitnull

Enables you to limit the count of entries fetched. Setting this to 0 means no limit.

p(notice). This parameter can NOT override server-side preset sizelimit. You can set it lower though. Some directory server hosts will be configured to return no more than a preset number of entries. If this occurs, the server will indicate that it has only returned a partial results set. This also occurs if you use this parameter to limit the count of fetched entries.
$timelimitnull

Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.

p(notice). This parameter can NOT override server-side preset timelimit. You can set it lower though.
$derefnull

Specifies how aliases should be handled during the search. It can be one of the following: * LDAP_DEREF_NEVER – (default) aliases are never dereferenced. * LDAP_DEREF_SEARCHING – aliases should be dereferenced during the search but not when locating the base object of the search. * LDAP_DEREF_FINDING – aliases should be dereferenced when locating the base object but not during the search. * LDAP_DEREF_ALWAYS – aliases should be dereferenced always.

Returns

array
setBaseSuffix()
setBaseSuffix($base)
Sets the BaseDN suffix to apply to method calls

This suffix is applied to methods that require a baseDN parameter, such as Hazaar\LDAP::search().

Parameters

$basestring

The base DN to append