php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29587 ldap_read cannot read RootDSE
Submitted: 2004-08-09 16:31 UTC Modified: 2005-03-09 01:47 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:5 (62.5%)
Same OS:3 (37.5%)
From: DavidSmith at byu dot net Assigned:
Status: Not a bug Package: LDAP related
PHP Version: 4.3.8 OS: Fedora Core 1
Private report: No CVE-ID: None
 [2004-08-09 16:31 UTC] DavidSmith at byu dot net
Description:
------------
With PHP 4.3.8, I get a "No such object" error when attempting to read the LDAP RootDSE. The code works fine with previous versions of PHP. I tested with both OpenLDAP 2.1.22 and Novell eDirectory. phpLDAPadmin (all versions) relies on this functionality.

Reproduce code:
---------------
$ds = ldap_connect( "localhost" );
ldap_bind( $ds );

// Problem is here:
$r = @ldap_read( $ds, '', 'objectClass=*', array('+') );

var_dump( $r );
var_dump( ldap_error( $ds ) );


Expected result:
----------------
resource(2) of type (ldap result)
string(7) "Success"

Actual result:
--------------
bool(false)
string(14) "No such object"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-16 10:44 UTC] sniper@php.net
With what previous PHP version? And do you use the same openldap library version as you did with the previous PHP version?
 [2004-09-24 05:54 UTC] DavidSmith at byu dot net
I'm not sure what version of the OpenLDAP client libs I was using. It's whatever ships with FC1.

--Dave
 [2004-09-24 05:54 UTC] DavidSmith at byu dot net
By the way, I doubt it's an LDAP client lib problem, as ldapsearch worked consistently in all cases.
 [2004-09-24 14:32 UTC] derick@php.net
Then please dig into which library FC1 uses.
 [2004-09-24 15:23 UTC] DavidSmith at byu dot net
Does this help:

$ rpm -qi openldap
Name        : openldap                     Relocations: (not relocateable)
Version     : 2.1.22                            Vendor: Red Hat, Inc.
Release     : 8                             Build Date: Thu 23 Oct 2003 10:26:42 AM EDT
Install Date: Sat 22 Nov 2003 01:03:19 PM EST      Build Host: bugs.devel.redhat.com
Group       : System Environment/Daemons    Source RPM: openldap-2.1.22-8.src.rpm
Size        : 1584111                          License: OpenLDAP
Signature   : DSA/SHA1, Tue 28 Oct 2003 06:49:57 PM EST, Key ID b44269d04f2a6fd2
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.openldap.org/
Summary     : The configuration files, libraries, and documentation for OpenLDAP.
Description :
OpenLDAP is an open source suite of LDAP (Lightweight Directory Access
Protocol) applications and development tools. LDAP is a set of
protocols for accessing directory services (usually phone book style
information, but other information is possible) over the Internet,
similar to the way DNS (Domain Name System) information is propagated
over the Internet. The openldap package contains configuration files,
libraries, and documentation for OpenLDAP.



$ rpm -ql openldap
/usr/lib/liblber.so.2
/usr/lib/liblber.so.2.0.122
/usr/lib/libldap.so.2
/usr/lib/libldap.so.2.0.122
/usr/lib/libldap_r.so.2
/usr/lib/libldap_r.so.2.0.122
 [2004-09-28 00:17 UTC] DavidSmith at byu dot net
In response to you inquiry, a peer of mine reports the following:

> I have just tested the same code on Mandrake 10, php 4.3.7, and it works
> fine.
> 
> The system that I was having the problem on is RHEL3, php 4.3.4.   I will
> do a little recompiled of PHP
> and see how it goes.
> 
> It appears that, on the system with the problem.  when  this bit of code
> runs
> 
> // Fetch basic RootDSE attributes using the + and *.
> $r = @ldap_read( $ds, '', 'objectClass=*', array( '+', '*' ) );
> 
> 
> The ldap server receives a search, with base "dc=example,dc=com", which is
> a little strange,
> as I can't find the string "dc=example" anywhere in the php or ldap server
> source. Guess it must be comming from somwhere however.
> 
> I would be happy fix the problem, except it appears to be nothing to do
> with the PHP code, but rather PHP, or the openldap libraries it's compiled
> against. Do you know about the Monitor back end for openldap?  I found
> that
> when I was looking around at this problem, and that backend appears to
> provide some usful information also.
> 
> It may not be very ustul, but here is a list of the system libaries
> versions that does not work.
> 
> [nelg@cub nelg]$ rpm -qi openldap
> Name        : openldap                     Relocations: (not relocatable)
> Version     : 2.0.27                            Vendor: Red Hat, Inc.
> Release     : 11                            Build Date: Sat 20 Sep 2003
> 09:23:05 NZST
> Install Date: Fri 29 Aug 2003 00:37:34 NZST      Build Host:
> bugs.devel.redhat.com
> Group       : System Environment/Daemons    Source RPM:
> openldap-2.0.27-11.src.rpm
> Size        : 1153098                          License: OpenLDAP
> Signature   : DSA/SHA1, Thu 25 Sep 2003 05:41:52 NZST, Key ID
> 219180cddb42a60e
> Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
> URL         : http://www.openldap.org/
> Summary     : The configuration files, libraries, and documentation for
> OpenLDAP.
> 
> [nelg@cub nelg]$ rpm -qi php-ldap
> Name        : php-ldap                     Relocations: (not relocatable)
> Version     : 4.3.4                             Vendor: (none)
> Release     : 1mdk                          Build Date: Mon 17 May 2004
> 08:44:12 NZST
> Install Date: Mon 17 May 2004 08:44:35 NZST      Build Host:
> 10-1-3-251.tcs.ac.nz
> Group       : Development/Languages         Source RPM:
> php-ldap-4.3.4-1mdk.src.rpm
> Size        : 70198                            License: PHP License
> Signature   : (none)
> URL         : http://www.php.net
> Summary     : A module for PHP applications that use LDAP.
>
 [2004-10-01 10:08 UTC] sniper@php.net
Search for ldap.conf (your filesystem and google)..
That's where the example.com comes from. 

 [2004-10-01 15:26 UTC] DavidSmith at byu dot net
ldap.conf has nothing to do with this bug. I am performing an ldap_read() and explicitly specificying my own search base (the empty string, ""). In this case, PHP and the LDAP libraries should not be reading the "base" directive in ldap.conf.

Despite this glaringly obvious fact, I tried removing the "base" directive from ldap.conf to see if that fixed it. It had no effect on the bug. So I tried changing the "base" directive from dc=example,dc=com to the correct one, dc=phpldapadmin,dc=com, but PHP still searches with base dc=example,dc=com (yes I restarted my web server and LDAP server). So then I tried creating ~apache/.ldaprc and setting the base to dc=phpldapadmin,dc=com there. Still no effect on the bug.

This is a bug. No matter what setting I have for my base in ldap.conf, PHP should is NOT using the base I specify in my call to ldap_read().

Perhaps PHP is interpreting a base of "" to mean "the default base DN specified somewhere else". This is NOT the desired behavior. The RFCs state that when searching with a base DN set to the empty string and a scope of "base", that the RootDSE entry should be returned. Note also that other versions of PHP work just fine with no changes to the LDAP libraries. See comments from other users as well.

Also note that ldapsearch works just fine, so it's obviously not the LDAP client libraries. This is a PHP bug.

--Dave
 [2005-02-16 22:58 UTC] deon at wurley dot net
I'm seeing this problem in Fedora Core 3 - which is using php 4.3.10.

Withouth having to create my own php - any tips on how this can be resolved?

Is there a fix in the code available?
 [2005-03-08 00:51 UTC] DavidSmith at byu dot net
After installing the new PHP version, and commenting out the BASE line in both my ldap.conf files (one in /etc and one in /etc/openldap), it now works as expected!

Good work!

--Dave
 [2005-03-09 01:06 UTC] sniper@php.net
Considering we didn't change anything in ext/ldap between this period and that I did mention ldap.conf once before -> bogus.
(it wasn't PHP bug after all, was it? :)

 [2005-03-09 01:43 UTC] DavidSmith at byu dot net
Indeed. Please accept my humble apology.

--Dave
 [2005-03-09 01:47 UTC] DavidSmith at byu dot net
Whatever the case, it may be worth investigating why PHP's ldap_read() failed in this case while the command line ldapsearch continued to function properly despite the ldap.conf settings.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC