PHP Class Horde_Ldap_Search, horde

Copyright 2009 Jan Wagner, Benedikt Hallinger Copyright 2010-2016 Horde LLC (http://www.horde.org/)
Author: Tarjej Huse ([email protected])
Author: Benedikt Hallinger ([email protected])
Author: Jan Schneider ([email protected])
Inheritance: implements Iterator
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство Type Description
$_entry resource Result entry identifier.
$_entry_cache array This currently is only used by {@link pop_entry()}.
$_errorCode integer Some errorcodes might be of interest that should not be considered errors, for example: - 4: LDAP_SIZELIMIT_EXCEEDED - indicates a huge search. Incomplete results are returned. If you just want to check if there is anything returned by the search at all, this could be catched. - 32: no such object - search here returns a count of 0.
$_iteratorCache array Cache for all entries already fetched from iterator interface.
$_ldap Horde_Ldap A reference of the Horde_Ldap object for passing to Horde_Ldap_Entry.
$_link resource LDAP resource link.
$_search resource Search result identifier.
$_searchedAttrs array This variable gets set from the constructor and can be retrieved through {@link searchedAttributes()}.

Méthodes publiques

Méthode Description
__construct ( resource $search, Horde_Ldap | resource $ldap, array $attributes = [] ) Constructor.
__destruct ( ) Destructor.
asArray ( ) : array Returns entries as array.
count ( ) : integer Returns the number of entries in the search result.
current ( ) : Horde_Ldap_Entry | false SPL Iterator interface: Returns the current element.
entries ( ) : array Returns all entries from the search result.
getErrorCode ( ) : integer Returns the errorcode from the search.
key ( ) : string | false SPL Iterator interface: Returns the identifying key (DN) of the current entry.
next ( ) SPL Iterator interface: Moves forward to next entry.
popEntry ( ) : Horde_Ldap_Entry | false Retrieve the next entry in the search result, but starting from last entry.
rewind ( ) SPL Iterator interface: Rewinds the Iterator to the first element.
setLink ( resource $link ) Sets the LDAP resource link.
setSearch ( resource $search ) Sets the search objects resource link
shiftEntry ( ) : Horde_Ldap_Entry | false Get the next entry from the search result.
sizeLimitExceeded ( ) : boolean Returns wheter this search exceeded a sizelimit.
sorted ( array $attrs = ['cn'], integer $order = SORT_ASC ) : array Returns entries sorted as objects.
sortedAsArray ( array $attrs = ['cn'], integer $order = SORT_ASC ) : array Return entries sorted as array.
valid ( ) : boolean SPL Iterator interface: Checks if there is a current element after calls to {@link rewind()} or {@link next()}.

Méthodes protégées

Méthode Description
searchedAttributes ( ) : array Returns the attribute names this search selected.

Method Details

__construct() public méthode

Constructor.
public __construct ( resource $search, Horde_Ldap | resource $ldap, array $attributes = [] )
$search resource Search result identifier.
$ldap Horde_Ldap | resource Horde_Ldap object or a LDAP link resource
$attributes array The searched attribute names, see {@link $_searchedAttrs}.

__destruct() public méthode

Destructor.
public __destruct ( )

asArray() public méthode

The first array level contains all found entries where the keys are the DNs of the entries. The second level arrays contian the entries attributes such that the keys is the lowercased name of the attribute and the values are stored in another indexed array. Note that the attribute values are stored in an array even if there is no or just one value. The array has the following structure: array( 'cn=foo,dc=example,dc=com' => array( 'sn' => array('foo'), 'multival' => array('val1', 'val2', 'valN')), 'cn=bar,dc=example,dc=com' => array( 'sn' => array('bar'), 'multival' => array('val1', 'valN')))
public asArray ( ) : array
Résultat array Associative result array as described above.

count() public méthode

Returns the number of entries in the search result.
public count ( ) : integer
Résultat integer Number of found entries.

current() public méthode

The SPL Iterator interface allows you to fetch entries inside a foreach() loop: foreach ($search as $dn => $entry) { ... Of course, you may call {@link current()}, {@link key()}, {@link next()}, {@link rewind()} and {@link valid()} yourself. If the search throwed an error, it returns false. False is also returned, if the end is reached. In case no call to next() was made, we will issue one, thus returning the first entry.
public current ( ) : Horde_Ldap_Entry | false
Résultat Horde_Ldap_Entry | false

entries() public méthode

Returns all entries from the search result.
public entries ( ) : array
Résultat array All entries.

getErrorCode() public méthode

Returns the errorcode from the search.
public getErrorCode ( ) : integer
Résultat integer The LDAP error number.

key() public méthode

SPL Iterator interface: Returns the identifying key (DN) of the current entry.
See also: current()
public key ( ) : string | false
Résultat string | false DN of the current entry; false in case no entry is returned by current().

next() public méthode

After a call to {@link next()}, {@link current()} will return the next entry in the result set.
See also: current()
public next ( )

popEntry() public méthode

This is the opposite to {@link shiftEntry()} and is also very useful to be used inside a while loop.
public popEntry ( ) : Horde_Ldap_Entry | false
Résultat Horde_Ldap_Entry | false

rewind() public méthode

After rewinding, {@link current()} will return the first entry in the result set.
See also: current()
public rewind ( )

searchedAttributes() protected méthode

Returns the attribute names this search selected.
protected searchedAttributes ( ) : array
Résultat array

setSearch() public méthode

Sets the search objects resource link
public setSearch ( resource $search )
$search resource Search result identifier.

shiftEntry() public méthode

This will return a valid Horde_Ldap_Entry object or false, so you can use this method to easily iterate over the entries inside a while loop.
public shiftEntry ( ) : Horde_Ldap_Entry | false
Résultat Horde_Ldap_Entry | false Reference to Horde_Ldap_Entry object or false if no more entries exist.

sizeLimitExceeded() public méthode

Returns wheter this search exceeded a sizelimit.
public sizeLimitExceeded ( ) : boolean
Résultat boolean True if the size limit was exceeded.

sorted() public méthode

This returns a array with sorted Horde_Ldap_Entry objects. The sorting is actually done with {@link sortedAsArray()}. Please note that attribute names are case sensitive! Also note that it is (depending on server capabilities) possible to let the server sort your results. This happens through search controls and is described in detail at {@link http://www.ietf.org/rfc/rfc2891.txt} Usage example: To sort entries first by location, then by surname, but descending: $entries = $search->sorted(array('locality', 'sn'), SORT_DESC);
public sorted ( array $attrs = ['cn'], integer $order = SORT_ASC ) : array
$attrs array Attribute names as sort criteria.
$order integer Ordering direction, either constant SORT_ASC or SORT_DESC
Résultat array Sorted entries.

sortedAsArray() public méthode

This returns a array with sorted entries and the values. Sorting is done with PHPs {@link array_multisort()}. This method relies on {@link asArray()} to fetch the raw data of the entries. Please note that attribute names are case sensitive! Usage example: To sort entries first by location, then by surname, but descending: $entries = $search->sortedAsArray(array('locality', 'sn'), SORT_DESC);
public sortedAsArray ( array $attrs = ['cn'], integer $order = SORT_ASC ) : array
$attrs array Attribute names as sort criteria.
$order integer Ordering direction, either constant SORT_ASC or SORT_DESC
Résultat array Sorted entries.

valid() public méthode

Used to check if we've iterated to the end of the collection.
See also: current()
public valid ( ) : boolean
Résultat boolean False if there's nothing more to iterate over.

Property Details

$_entry protected_oe property

Result entry identifier.
protected resource $_entry
Résultat resource

$_entry_cache protected_oe property

This currently is only used by {@link pop_entry()}.
protected array $_entry_cache
Résultat array

$_errorCode protected_oe property

Some errorcodes might be of interest that should not be considered errors, for example: - 4: LDAP_SIZELIMIT_EXCEEDED - indicates a huge search. Incomplete results are returned. If you just want to check if there is anything returned by the search at all, this could be catched. - 32: no such object - search here returns a count of 0.
protected int $_errorCode
Résultat integer

$_iteratorCache protected_oe property

Cache for all entries already fetched from iterator interface.
protected array $_iteratorCache
Résultat array

$_ldap protected_oe property

A reference of the Horde_Ldap object for passing to Horde_Ldap_Entry.
protected Horde_Ldap $_ldap
Résultat Horde_Ldap

$_searchedAttrs protected_oe property

This variable gets set from the constructor and can be retrieved through {@link searchedAttributes()}.
protected array $_searchedAttrs
Résultat array