ldap_search not working with base=NULL after php7.1
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
$ds = ldap_connect(); // <-- URI from /etc/openldap/ldap.conf
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$sr = ldap_search($ds, NULL, "(uid=dab)", array("dn")); // <-- BASE from /etc/openldap/ldap.conf
$entry = ldap_first_entry($ds, $sr);
var_dump($entry);
Resulted in this output:
Warning: ldap_search(): Search: No such object in test.php on line 5
But I expected this output instead:
resource(6) of type (ldap result entry)
/etc/openldap/ldap.conf:
BASE c=ru
URI ldap://localhost
slapd.log:
version <=php7.1
slapd[14091]: conn=4230904 op=0 SRCH base="c=ru" scope=2 deref=0 filter="(uid=dab)"
version >php7.1
slapd[14091]: conn=4230791 op=0 SRCH base="" scope=2 deref=0 filter="(uid=dab)"
related bug&commit:
https://bugs.php.net/bug.php?id=77958
https://github.com/php/php-src/commit/5d2fe48785b6d24102ff53e78631cba7f2aefbef
PHP Version
PHP 8.0.12
Operating System
gentoo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ldap_search entry point and compare the behavior shown in the reproduction with the linked bug and commit 5d2fe48785b6d24102ff53e78631cba7f2aefbef. Run the provided PHP script against the stated LDAP configuration and inspect slapd.log; done means a NULL base uses the configured BASE and the search returns the expected entry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100