[PHP-NOTES] note 130565 added to function.ldap-search

[email protected] ("[email protected]") Fri, 05 Dec 2025 07:55:26 +0000
Newsgroups php.notes
Message-ID <[email protected]>
A big warning sign must be placed on `$filter` field.

The filter MUST be present and it MUST NOT be empty.

Else you will receive mysterious "Can't contact LDAP server" error and no help from google.

The single clue could be found when running `ldapsearch` CLI tool to verify your code - in verbose mode, it clearly states that, in absence of user-specified filters, it adds an `(objectclass=*)` filter to avoid an error.

```
$ ldapsearch -H ldaps://dc2.ads.darkdragon.lan -vvv -b 'CN=Users,DC=ads,DC=darkdragon,DC=lan
filter: (objectclass=*)
requesting: All userApplication attributes
# extended LDIF
#
# LDAPv3
# base <CN=Users,DC=ads,DC=darkdragon,DC=lan> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
…
```
----
Server IP: 206.189.2.9
Probable Submitter: 95.165.144.62
----
Manual Page -- https://php.net/manual/en/function.ldap-search.php
Edit        -- https://main.php.net/note/edit/130565
Del: integrated  -- https://main.php.net/note/delete/130565/integrated
Del: useless     -- https://main.php.net/note/delete/130565/useless
Del: bad code    -- https://main.php.net/note/delete/130565/bad+code
Del: spam        -- https://main.php.net/note/delete/130565/spam
Del: non-english -- https://main.php.net/note/delete/130565/non-english
Del: in docs     -- https://main.php.net/note/delete/130565/in+docs
Del: other reasons-- https://main.php.net/note/delete/130565
Reject      -- https://main.php.net/note/reject/130565
Search      -- https://main.php.net/manage/user-notes.php