PHP Класс Horde_Ldap_Search, horde

Copyright 2009 Jan Wagner, Benedikt Hallinger Copyright 2010-2016 Horde LLC (http://www.horde.org/)
Автор: Tarjej Huse ([email protected])
Автор: Benedikt Hallinger ([email protected])
Автор: Jan Schneider ([email protected])
Наследование: implements Iterator
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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()}.

Открытые методы

Метод Описание
__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()}.

Защищенные методы

Метод Описание
searchedAttributes ( ) : array Returns the attribute names this search selected.

Описание методов

__construct() публичный Метод

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() публичный Метод

Destructor.
public __destruct ( )

asArray() публичный Метод

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
Результат array Associative result array as described above.

count() публичный Метод

Returns the number of entries in the search result.
public count ( ) : integer
Результат integer Number of found entries.

current() публичный Метод

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
Результат Horde_Ldap_Entry | false

entries() публичный Метод

Returns all entries from the search result.
public entries ( ) : array
Результат array All entries.

getErrorCode() публичный Метод

Returns the errorcode from the search.
public getErrorCode ( ) : integer
Результат integer The LDAP error number.

key() публичный Метод

SPL Iterator interface: Returns the identifying key (DN) of the current entry.
См. также: current()
public key ( ) : string | false
Результат string | false DN of the current entry; false in case no entry is returned by current().

next() публичный Метод

After a call to {@link next()}, {@link current()} will return the next entry in the result set.
См. также: current()
public next ( )

popEntry() публичный Метод

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
Результат Horde_Ldap_Entry | false

rewind() публичный Метод

After rewinding, {@link current()} will return the first entry in the result set.
См. также: current()
public rewind ( )

searchedAttributes() защищенный Метод

Returns the attribute names this search selected.
protected searchedAttributes ( ) : array
Результат array

setSearch() публичный Метод

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

shiftEntry() публичный Метод

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
Результат Horde_Ldap_Entry | false Reference to Horde_Ldap_Entry object or false if no more entries exist.

sizeLimitExceeded() публичный Метод

Returns wheter this search exceeded a sizelimit.
public sizeLimitExceeded ( ) : boolean
Результат boolean True if the size limit was exceeded.

sorted() публичный Метод

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
Результат array Sorted entries.

sortedAsArray() публичный Метод

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
Результат array Sorted entries.

valid() публичный Метод

Used to check if we've iterated to the end of the collection.
См. также: current()
public valid ( ) : boolean
Результат boolean False if there's nothing more to iterate over.

Описание свойств

$_entry защищенное свойство

Result entry identifier.
protected resource $_entry
Результат resource

$_entry_cache защищенное свойство

This currently is only used by {@link pop_entry()}.
protected array $_entry_cache
Результат array

$_errorCode защищенное свойство

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
Результат integer

$_iteratorCache защищенное свойство

Cache for all entries already fetched from iterator interface.
protected array $_iteratorCache
Результат array

$_ldap защищенное свойство

A reference of the Horde_Ldap object for passing to Horde_Ldap_Entry.
protected Horde_Ldap $_ldap
Результат Horde_Ldap

$_searchedAttrs защищенное свойство

This variable gets set from the constructor and can be retrieved through {@link searchedAttributes()}.
protected array $_searchedAttrs
Результат array