class Ldaph (View source)

ldaph: poor man's php ldap class

Methods

__construct(string $server, int $port = 389)

Constructor method

base(string $dcs)

Set ldap base

dn(string $dn)

Set ldap distinguished name (used in ldap bind)

version(int $mode = 3)

Set ldap version: 2 or 3 (default)

ssl(bool $mode = true)

Enable/disable ssl for connection

tls(bool $mode = true)

Enable/disable tls for connection

sso(bool $mode = true)

Enable/disable single sign on

account(string $user, string $pass)

Set user/pass for bind and search

searchbase(string $s)

Set ldap search base

fields(mixed $f)

Set fields to query ldap for

bool
auth(string $userName, string $userPass)

Authenticate an user via LDAP

array
search(string $what = "*", bool $clean = false)

Search ldap directory for $what

Details

__construct(string $server, int $port = 389)

Constructor method

Prepare environment for connection (bind)

Parameters

string $server ldap server (ip or FQDN)
int $port port to connect to

Exceptions

LdaphException

final Ldaph base(string $dcs)

Set ldap base

Parameters

string $dcs ldap base, comma separated, not spaced

Return Value

Ldaph

Exceptions

LdaphException

final Ldaph dn(string $dn)

Set ldap distinguished name (used in ldap bind)

Before bind, special word USERNAME will be substituted by real username

Parameters

string $dn ldap DN, comma separated, not spaced

Return Value

Ldaph

Exceptions

LdaphException

final Ldaph version(int $mode = 3)

Set ldap version: 2 or 3 (default)

Parameters

int $mode ldap protocol version

Return Value

Ldaph

final Ldaph ssl(bool $mode = true)

Enable/disable ssl for connection

Parameters

bool $mode

Return Value

Ldaph

final Ldaph tls(bool $mode = true)

Enable/disable tls for connection

Parameters

bool $mode

Return Value

Ldaph

final Ldaph sso(bool $mode = true)

Enable/disable single sign on

Parameters

bool $mode

Return Value

Ldaph

Exceptions

LdaphException

final Ldaph account(string $user, string $pass)

Set user/pass for bind and search

Parameters

string $user
string $pass

Return Value

Ldaph

Exceptions

LdaphException

final Ldaph searchbase(string $s)

Set ldap search base

During search, special word PATTERN will be sbstituted by provided pattern

Parameters

string $s

Return Value

Ldaph

final Ldaph fields(mixed $f)

Set fields to query ldap for

Parameters

mixed $f

Return Value

Ldaph

bool auth(string $userName, string $userPass)

Authenticate an user via LDAP

Parameters

string $userName The user to auth
string $userPass The password for user

Return Value

bool

Exceptions

LdaphException
Exception

Search ldap directory for $what

Parameters

string $what The pattern to search for (will replace the searcbase PATTERN special word)
bool $clean If true, raw ldap_get_entries result will be normalized as plain array

Return Value

array

Exceptions

LdaphException
Exception