category Zend
package Zend_Ldap
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Constructor.

__construct(array|\Zend_Config $options = array()) : void

Parameters

$options

array\Zend_Config

Options used in connecting, binding, etc.

Exceptions

\Zend_Ldap_Exception if ext/ldap is not installed

Destructor.

__destruct() : void

Add new information to the LDAP repository

add(string|\Zend_Ldap_Dn $dn, array $entry) : \Zend_Ldap

Parameters

$dn

string\Zend_Ldap_Dn

$entry

array

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

bind()

bind(string $username = null, string $password = null) : \Zend_Ldap

Parameters

$username

string

The username for authenticating the bind

$password

string

The password for authenticating the bind

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

To connect using SSL it seems the client tries to verify the server certificate by default. One way to disable this behavior is to set 'TLS_REQCERT never' in OpenLDAP's ldap.conf and restarting Apache. Or, if you really care about the server's cert you can put a cert on the web server.

connect(string $host = null, integer $port = null, boolean $useSsl = null, boolean $useStartTls = null) : \Zend_Ldap

Parameters

$host

string

The hostname of the LDAP server to connect to

$port

integer

The port number of the LDAP server to connect to

$useSsl

boolean

Use SSL

$useStartTls

boolean

Use STARTTLS

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Copies a LDAP entry from one DN to another DN.

copy(string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false) : \Zend_Ldap

Parameters

$from

string\Zend_Ldap_Dn

$to

string\Zend_Ldap_Dn

$recursively

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Copies a LDAP entry from one DN to another subtree.

copyToSubtree(string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false) : \Zend_Ldap

Parameters

$from

string\Zend_Ldap_Dn

$to

string\Zend_Ldap_Dn

$recursively

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Count items found by given filter.

count(string|\Zend_Ldap_Filter_Abstract $filter, string|\Zend_Ldap_Dn|null $basedn = null, integer $scope = self::SEARCH_SCOPE_SUB) : integer

Parameters

$filter

string\Zend_Ldap_Filter_Abstract

$basedn

string\Zend_Ldap_Dnnull

$scope

integer

Exceptions

\Zend_Ldap_Exception

Returns

integer

Count children for a given DN.

countChildren(string|\Zend_Ldap_Dn $dn) : integer

Parameters

$dn

string\Zend_Ldap_Dn

Exceptions

\Zend_Ldap_Exception

Returns

integer

Delete an LDAP entry

delete(string|\Zend_Ldap_Dn $dn, boolean $recursively = false) : \Zend_Ldap

Parameters

$dn

string\Zend_Ldap_Dn

$recursively

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

disconnect()

disconnect() : \Zend_Ldap

Returns

\Zend_LdapProvides a fluent interface

Check if a given DN exists.

exists(string|\Zend_Ldap_Dn $dn) : boolean

Parameters

$dn

string\Zend_Ldap_Dn

Exceptions

\Zend_Ldap_Exception

Returns

boolean

explodeDn()

explodeDn(string $dn, array $keys = null, array $vals = null) : boolean
Static
deprecated will be removed, use {@see Zend_Ldap_Dn::checkDn()}

Parameters

$dn

string

The DN to parse

$keys

array

An optional array to receive DN keys (e.g. CN, OU, DC, ...)

$vals

array

An optional array to receive DN values

Returns

booleanTrue if the DN was successfully parsed or false if the string is not a valid DN.

filterEscape()

filterEscape(string $str) : string
Static
deprecated will be removed, use {@see Zend_Ldap_Filter_Abstract::escapeValue()}

Parameters

$str

string

The string to escape.

Returns

stringThe escaped string

Gets the base DN under which objects of interest are located

getBaseDn() : string

Returns

string

Returns the base node as a Zend_Ldap_Node

getBaseNode() : \Zend_Ldap_Node

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_Ldap_Node

Get the currently bound user

getBoundUser() : false | null | string

FALSE if no user is bound to the LDAP resource NULL if there has been an anonymous bind username of the currently bound user

Returns

falsenullstring

getCanonicalAccountName()

getCanonicalAccountName(string $acctname, $form = 0) : string

Parameters

$acctname

string

The name to canonicalize

$form

Exceptions

\Zend_Ldap_Exception

Returns

stringThe canonicalized name in the desired form

Get LDAP entry by DN

getEntry(string|\Zend_Ldap_Dn $dn, array $attributes = array(), boolean $throwOnNotFound = false) : array

Parameters

$dn

string\Zend_Ldap_Dn

$attributes

array

$throwOnNotFound

boolean

Exceptions

\Zend_Ldap_Exception

Returns

array

Return the LDAP error message of the last LDAP command

getLastError(integer $errorCode = null, array $errorMessages = null) : string

Parameters

$errorCode

integer

$errorMessages

array

Returns

string

Return the LDAP error number of the last LDAP command

getLastErrorCode() : integer

Returns

integer

Returns the specified DN as a Zend_Ldap_Node

getNode(string|\Zend_Ldap_Dn $dn) : \Zend_Ldap_Node | null

Parameters

$dn

string\Zend_Ldap_Dn

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_Ldap_Nodenull

getOptions()

getOptions() : array

Returns

arrayThe current options.

getResource()

getResource() : resource

Returns

resourceThe raw LDAP extension resource.

Returns the RootDSE

getRootDse() : \Zend_Ldap_Node_RootDse

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_Ldap_Node_RootDse

Returns the schema

getSchema() : \Zend_Ldap_Node_Schema

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_Ldap_Node_Schema

Moves a LDAP entry from one DN to another DN.

move(string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false) : \Zend_Ldap

This is an alias for \rename()

Parameters

$from

string\Zend_Ldap_Dn

$to

string\Zend_Ldap_Dn

$recursively

boolean

$alwaysEmulate

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Moves a LDAP entry from one DN to another subtree.

moveToSubtree(string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false) : \Zend_Ldap

Parameters

$from

string\Zend_Ldap_Dn

$to

string\Zend_Ldap_Dn

$recursively

boolean

$alwaysEmulate

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Prepares an ldap data entry array for insert/update operation

prepareLdapEntryArray(array $entry) : void
Static

Parameters

$entry

array

Exceptions

\InvalidArgumentException

Renames a LDAP entry from one DN to another DN.

rename(string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false) : \Zend_Ldap

This method implicitely moves the entry to another location within the tree.

Parameters

$from

string\Zend_Ldap_Dn

$to

string\Zend_Ldap_Dn

$recursively

boolean

$alwaysEmulate

boolean

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Save entry to LDAP registry.

save(string|\Zend_Ldap_Dn $dn, array $entry) : \Zend_Ldap

Internally decides if entry will be updated to added by calling \exists().

Parameters

$dn

string\Zend_Ldap_Dn

$entry

array

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Search LDAP registry for entries matching filter and optional attributes

searchEntries(string|\Zend_Ldap_Filter_Abstract|array $filter, string|\Zend_Ldap_Dn|null $basedn = null, integer $scope = self::SEARCH_SCOPE_SUB, array $attributes = array(), string|null $sort = null, boolean $reverseSort = false, integer $sizelimit = 0, integer $timelimit = 0) : array

Options can be either passed as single parameters according to the method signature or as an array with one or more of the following keys

  • filter
  • baseDn
  • scope
  • attributes
  • sort
  • reverseSort
  • sizelimit
  • timelimit

Parameters

$filter

string\Zend_Ldap_Filter_Abstractarray

$basedn

string\Zend_Ldap_Dnnull

$scope

integer

$attributes

array

$sort

stringnull

$reverseSort

boolean

$sizelimit

integer

$timelimit

integer

Exceptions

\Zend_Ldap_Exception

Returns

array

Sets the options used in connecting, binding, etc.

setOptions(array|\Zend_Config $options) : \Zend_Ldap

Valid option keys: host port useSsl username password bindRequiresDn baseDn accountCanonicalForm accountDomainName accountDomainNameShort accountFilterFormat allowEmptyPassword useStartTls optRefferals tryUsernameSplit

Parameters

$options

array\Zend_Config

Options used in connecting, binding, etc.

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Update LDAP registry

update(string|\Zend_Ldap_Dn $dn, array $entry) : \Zend_Ldap

Parameters

$dn

string\Zend_Ldap_Dn

$entry

array

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_LdapProvides a fluent interface

Extension point for collection creation

_createCollection(\Zend_Ldap_Collection_Iterator_Default $iterator, string|null $collectionClass) : \Zend_Ldap_Collection

Parameters

$iterator

\Zend_Ldap_Collection_Iterator_Default

$collectionClass

stringnull

Exceptions

\Zend_Ldap_Exception

Returns

\Zend_Ldap_Collection

_getAccount()

_getAccount($acctname, array $attrs = null) : array

Parameters

$acctname

$attrs

array

An array of names of desired attributes

Exceptions

\Zend_Ldap_Exception

Returns

arrayAn array of the attributes representing the account

_getAccountCanonicalForm()

_getAccountCanonicalForm() : integer

Returns

integerEither ACCTNAME_FORM_BACKSLASH, ACCTNAME_FORM_PRINCIPAL or ACCTNAME_FORM_USERNAME indicating the form usernames should be canonicalized to.

_getAccountDn()

_getAccountDn(string $acctname) : string

Parameters

$acctname

string

The name of the account

Exceptions

\Zend_Ldap_Exception

Returns

stringThe DN of the specified account

_getAccountDomainName()

_getAccountDomainName() : string

Returns

stringThe account domain name

_getAccountDomainNameShort()

_getAccountDomainNameShort() : string

Returns

stringThe short account domain name

_getAccountFilter()

_getAccountFilter($acctname) : string

Parameters

$acctname

Returns

stringThe LDAP search filter for matching directory accounts

_getAccountFilterFormat()

_getAccountFilterFormat() : string

Returns

stringA format string for building an LDAP search filter to match an account

_getAllowEmptyPassword()

_getAllowEmptyPassword() : boolean

Returns

booleanAllow empty passwords

_getBindRequiresDn()

_getBindRequiresDn() : boolean

Returns

booleanBind requires DN

Retrieve the immediate children DNs of the given $parentDn

_getChildrenDns(string|\Zend_Ldap_Dn $parentDn) : array

This method is used in recursive methods like \delete() or \copy()

Parameters

$parentDn

string\Zend_Ldap_Dn

Returns

arrayof DNs

_getHost()

_getHost() : string

Returns

stringThe hostname of the LDAP server being used to authenticate accounts

_getOptReferrals()

_getOptReferrals() : boolean

Returns

booleanOpt. Referrals

_getPassword()

_getPassword() : string

Returns

stringThe default password for binding

_getPort()

_getPort() : integer

Returns

integerThe port of the LDAP server or 0 to indicate that no port value is set

_getTryUsernameSplit()

_getTryUsernameSplit() : boolean

Returns

booleanTry splitting the username into username and domain

_getUseSsl()

_getUseSsl() : boolean

Returns

booleanThe default SSL / TLS encrypted transport control

_getUseStartTls()

_getUseStartTls() : boolean

Returns

booleanThe default SSL / TLS encrypted transport control

_getUsername()

_getUsername() : string

Returns

stringThe default acctname for binding

_isPossibleAuthority()

_isPossibleAuthority(string $dname) : boolean

Parameters

$dname

string

The domain name to check

Returns

boolean

_splitName()

_splitName(string $name, string $dname, string $aname) : void

Parameters

$name

string

The name to split

$dname

string

The resulting domain name (this is an out parameter)

$aname

string

The resulting account name (this is an out parameter)

 Properties

 

FALSE if no user is bound to the LDAP resource NULL if there has been an anonymous bind username of the currently bound user

$_boundUser : boolean | null | string

Default

false
 

The options used in connecting, binding, etc.

$_options : array

Default

null
 

The raw LDAP extension resource.

$_resource : resource

Default

null
 

Caches the RootDSE

$_rootDse : \Zend_Ldap_Node

Default

null
 

Caches the schema

$_schema : \Zend_Ldap_Node

Default

null
 

String used with ldap_connect for error handling purposes.

$_connectString : string

Default

 Constants

 

ACCTNAME_FORM_BACKSLASH

ACCTNAME_FORM_BACKSLASH = 3 
 

ACCTNAME_FORM_DN

ACCTNAME_FORM_DN = 1 
 

ACCTNAME_FORM_PRINCIPAL

ACCTNAME_FORM_PRINCIPAL = 4 
 

ACCTNAME_FORM_USERNAME

ACCTNAME_FORM_USERNAME = 2 
 

SEARCH_SCOPE_BASE

SEARCH_SCOPE_BASE = 3 
 

SEARCH_SCOPE_ONE

SEARCH_SCOPE_ONE = 2 
 

SEARCH_SCOPE_SUB

SEARCH_SCOPE_SUB = 1