$_search
$_search : resource
Search result identifier.
Result set of an LDAP search
Copyright 2009 Jan Wagner, Benedikt Hallinger Copyright 2010-2017 Horde LLC (http://www.horde.org/)
$_ldap : \Horde_Ldap
Horde_Ldap object.
A reference of the Horde_Ldap object for passing to Horde_Ldap_Entry.
$_errorCode : integer
The errorcode from the search.
Some errorcodes might be of interest that should not be considered errors, for example:
__construct(resource $search, \Horde_Ldap|resource $ldap, array $attributes = array())
Constructor.
resource | $search | Search result identifier. |
\Horde_Ldap|resource | $ldap | Horde_Ldap object or a LDAP link resource |
array | $attributes | The searched attribute names, see {@link $_searchedAttrs}. |
shiftEntry() : \Horde_Ldap_Entry|false
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.
Reference to Horde_Ldap_Entry object or false if no more entries exist.
popEntry() : \Horde_Ldap_Entry|false
Retrieve the next entry in the search result, but starting from last entry.
This is the opposite to \shiftEntry() and is also very useful to be used inside a while loop.
sortedAsArray(array $attrs = array('cn'), integer $order = SORT_ASC) : 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 \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);
array | $attrs | Attribute names as sort criteria. |
integer | $order | Ordering direction, either constant SORT_ASC or SORT_DESC |
Sorted entries.
sorted(array $attrs = array('cn'), integer $order = SORT_ASC) : array
Returns entries sorted as objects.
This returns a array with sorted Horde_Ldap_Entry objects. The sorting is actually done with \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:
// To sort entries first by location, then by surname, but descending:
$entries = $search->sorted(array('locality', 'sn'), SORT_DESC);
array | $attrs | Attribute names as sort criteria. |
integer | $order | Ordering direction, either constant SORT_ASC or SORT_DESC |
Sorted entries.
asArray() : 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')))
Associative result array as described above.
current() : \Horde_Ldap_Entry|false
SPL Iterator interface: Returns the current element.
The SPL Iterator interface allows you to fetch entries inside
a foreach() loop: foreach ($search as $dn => $entry) { ...
Of course, you may call \current(), \key(), \next(), \rewind() and \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.