ldap_search
Search LDAP tree.
ldap_search Function synopsis
ldap_search(
$ldap,
array|string $base,
array|string $filter,
array $attributes = [],
int $attributes_only = 0,
int $sizelimit = -1,
int $timelimit = -1,
int $deref = LDAP_DEREF_NEVER,
?array $controls = null
): LDAP\Result|array|false
Parameters
$ldap
An LDAP\Connection instance, returned by ldap_connect.
$base
Typearray|string
The base DN for the directory.
$filter
Typearray|string
The search filter can be simple or advanced, using boolean operators in the format described in the LDAP documentation (see the Netscape Directory SDK or RFC4515 for full information on filters).
$attributes
OptionalTypearrayDefault value[]
An array of the required attributes, e.g. array("mail", "sn", "cn").
Note that the "dn" is always returned irrespective of which attributes
types are requested.
$attributes_only
OptionalTypeintDefault value0
Should be set to 1 if only attribute types are wanted. If set to 0 both attributes types and attribute values are fetched which is the default behaviour.
$sizelimit
OptionalTypeintDefault value-1
Enables you to limit the count of entries fetched. Setting this to 0 means no limit.
$timelimit
OptionalTypeintDefault value-1
Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.
$deref
OptionalTypeintDefault valueLDAP_DEREF_NEVER
Specifies how aliases should be handled during the search. It can be one of the following:
$controls
OptionalType?arrayDefault valuenull
Array of LDAP Controls to send with the request.
Return value
TypeLDAP\Result|array|false
Returns an LDAP\Result instance, an array of LDAP\Result instances, or false on failure
Changes to the ldap_search Function
PHP 8.1
- Return type added:
LDAP\Result|array|false
ldap_search(
$ldap,
array|string $base,
array|string $filter,
array $attributes = [],
int $attributes_only = 0,
int $sizelimit = -1,
int $timelimit = -1,
int $deref = LDAP_DEREF_NEVER,
?array $controls = null
- )
+ ): LDAP\Result|array|false PHP 8.0
- Parameter name of parameter #1 changed:
$link_identifierto$ldap - Parameter name of parameter #2 changed:
$base_dnto$base - Parameter type added for parameter #2 (
$base):array|string - Parameter type added for parameter #3 (
$filter):array|string - Parameter type added for parameter #4 (
$attributes):array - Parameter default value added for position #4 (
$attributes):[] - Parameter name of parameter #5 changed:
$attrsonlyto$attributes_only - Parameter type added for parameter #5 (
$attributes_only):int - Parameter default value added for position #5 (
$attributes_only):0 - Parameter type added for parameter #6 (
$sizelimit):int - Parameter default value added for position #6 (
$sizelimit):-1 - Parameter type added for parameter #7 (
$timelimit):int - Parameter default value added for position #7 (
$timelimit):-1 - Parameter type added for parameter #8 (
$deref):int - Parameter default value added for position #8 (
$deref):LDAP_DEREF_NEVER - Parameter name of parameter #9 changed:
$servercontrolsto$controls - Parameter type added for parameter #9 (
$controls):?array - Parameter default value added for position #9 (
$controls):null
ldap_search(
- $link_identifier,
+ $ldap,
- $base_dn,
+ array|string $base,
- $filter,
+ array|string $filter,
- $attributes,
+ array $attributes = [],
- $attrsonly,
+ int $attributes_only = 0,
- $sizelimit,
+ int $sizelimit = -1,
- $timelimit,
+ int $timelimit = -1,
- $deref,
+ int $deref = LDAP_DEREF_NEVER,
- $servercontrols
+ ?array $controls = null
) PHP 7.3
- Optional parameter added - #9:
$servercontrols
ldap_search(
$link_identifier,
$base_dn,
$filter,
$attributes,
$attrsonly,
$sizelimit,
$timelimit,
- $deref
+ $deref,
+ $servercontrols
) ldap_search Function Availability
ldap_search Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |