Result set of an LDAP search
Copyright 2009 Jan Wagner, Benedikt Hallinger
Copyright 2010-2012 Horde LLC (http://www.horde.org/)
Methods summary
public
|
#
__construct( resource $search, Horde_Ldap |resource $ldap, array $attributes = array() )
Constructor.
Parameters
- $search
- Search result identifier.
- $ldap
- <p>Horde_Ldap object or a LDAP link
resource</p>
- $attributes
- <p>The searched attribute names,
see $_searchedAttrs.</p>
|
public
|
|
public
array
|
#
entries( )
Returns all entries from the search result.
Returns all entries from the search result.
Returns
array All entries.
Throws
|
public
Horde_Ldap_Entry |false
|
#
shiftEntry( )
Get the next entry from the search result.
Get the next entry from the search result.
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.
Returns
Horde_Ldap_Entry |false
Reference to Horde_Ldap_Entry object or
false if no more entries exist.
Throws
|
public
Horde_Ldap_Entry |false
|
#
popEntry( )
Retrieve the next entry in the search result, but starting from last
entry.
Retrieve the next entry in the search result, but starting from last
entry.
This is the opposite to Horde_Ldap_Search::shiftEntry() and is also very useful to
be used inside a while loop.
Returns
Throws
|
public
array
|
#
sortedAsArray( array $attrs = array('cn'), integer $order = SORT_ASC )
Return entries sorted as array.
Return entries sorted as array.
This returns a array with sorted entries and the values. Sorting is done
with PHPs array_multisort().
This method relies on Horde_Ldap_Search::asArray() to fetch the raw data of the
entries.
Please note that attribute names are case sensitive!
Usage example:
$entries = $search->sortedAsArray(array('locality', 'sn'), SORT_DESC);
Parameters
- $attrs
- Attribute names as sort criteria.
- $order
- <p>Ordering direction, either constant SORT_ASC or
SORT_DESC</p>
Returns
array Sorted entries.
Throws
|
public
array
|
#
sorted( array $attrs = array('cn'), integer $order = SORT_ASC )
Returns entries sorted as objects.
Returns entries sorted as objects.
This returns a array with sorted Horde_Ldap_Entry objects. The sorting
is actually done with Horde_Ldap_Search::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 http://www.ietf.org/rfc/rfc2891.txt
Usage example:
$entries = $search->sorted(array('locality', 'sn'), SORT_DESC);
Parameters
- $attrs
- Attribute names as sort criteria.
- $order
- <p>Ordering direction, either constant SORT_ASC or
SORT_DESC</p>
Returns
array Sorted entries.
Throws
|
public
array
|
#
asArray( )
Returns entries as array.
Returns entries as array.
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')))
Returns
array Associative result array as described above.
Throws
|
public
|
#
setSearch( resource $search )
Sets the search objects resource link
Sets the search objects resource link
Parameters
- $search
- Search result identifier.
|
public
|
#
setLink( resource $link )
Sets the LDAP resource link.
Sets the LDAP resource link.
Parameters
- $link
- LDAP link identifier.
|
public
integer
|
#
count( )
Returns the number of entries in the search result.
Returns the number of entries in the search result.
Returns
integer Number of found entries.
|
public
integer
|
#
getErrorCode( )
Returns the errorcode from the search.
Returns the errorcode from the search.
Returns
integer The LDAP error number.
|
public
boolean
|
#
sizeLimitExceeded( )
Returns wheter this search exceeded a sizelimit.
Returns wheter this search exceeded a sizelimit.
Returns
boolean True if the size limit was exceeded.
|
public
Horde_Ldap_Entry |false
|
#
current( )
SPL Iterator interface: Returns the current element.
|
public
string|false
|
#
key( )
SPL Iterator interface: Returns the identifying key (DN) of the current
entry.
SPL Iterator interface: Returns the identifying key (DN) of the current
entry.
Returns
string|false DN of the current entry; false in case no entry is
returned by current().
See
Implementation of
Iterator::key()
|
public
|
#
next( )
SPL Iterator interface: Moves forward to next entry.
|
public
boolean
|
#
valid( )
SPL Iterator interface: Checks if there is a current element after calls
to Horde_Ldap_Search::rewind() or Horde_Ldap_Search::next() .
Used to check if we've iterated to the end of the collection.
Returns
boolean False if there's nothing more to iterate over.
See
Implementation of
Iterator::valid()
|
public
|
#
rewind( )
SPL Iterator interface: Rewinds the Iterator to the first element.
SPL Iterator interface: Rewinds the Iterator to the first element.
After rewinding, Horde_Ldap_Search::current() will return the first entry in the
result set.
See
Implementation of
Iterator::rewind()
|