Skip to content

ldap_search not working with base=NULL after php7.1 #7998

Open
@dab18

Description

@dab18

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
5d2fe48

PHP Version

PHP 8.0.12

Operating System

gentoo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions