ldap_count_entries
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Count the number of entries in a search
Description
ldap_count_entries(LDAP\Connection $ldap, LDAP\Result $result): int
Returns the number of entries stored in the result of previous search operations.
Parameters
ldapLdap
resultResult
Return Values
Returns the number of entries in the result, or -1 on error.
Changelog
| Version | Description |
|---|
Examples
ldap_count_entries() example
Retrieve number of entries in the result.
php
// $ds is a valid LDAP\Connection instance for a directory server
$dn = 'ou=example,dc=org';
$filter = '(|(sn=Doe*)(givenname=John*))';
$justthese = array('ou', 'sn', 'givenname', 'mail');
$sr = ldap_search($ds, $dn, $filter, $justthese);
var_dump(ldap_count_entries($ds, $sr));
The above example will output something similar to:
output
int(1)