|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10325 Opening database connection breaks ldap
Submitted: 2001-04-14 06:50 UTC Modified: 2001-05-07 01:04 UTC
From: dan at fatal dot net Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.0.4pl1 OS: Linux 2.4.3
Private report: No CVE-ID: None
 [2001-04-14 06:50 UTC] dan at fatal dot net
Opening a database connection breaks LDAP's link index.

Example code:

$dbcon = pg_connect("host=localhost port=5432 dbname=testdb user=testuser password=testpass");

$ds = ldap_connect("localhost");
$ldapcon = ldap_bind($ds);

// This always returns 1
echo $ldapcon;

// This errors out
ldap_search($ldapcon, "dc=test,dc=com", "cn=*");

This generates the error:
PHP Warning: 1 is not a LDAP link index

If you comment out the pg_connect() line, LDAP works fine.
If you pg_close($dbcon) right after the pg_connect(), you still get the PHP error.

This is a definite show stopper considering some people use a database for sessions, which means you can't use LDAP
after you start your session.

I'm using the latest openldap 2.0.7 & postgres 7.0.3,
php compiled into apache:
./configure --enable-memory-limit --enable-track-vars --enable-sysvsem --enable-sysvshm --with-gd --with-pgsql --with-freetype --with-ldap=/usr/local/openldap --with-xml --with-mhash --enable-trans-sid --with-kerberos --with-mcrypt --with-apache=../apache_1.3.19 --enable-bcmath --with-zlib --with-sockets --enable-inline-optimizations

Please fix soon :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-06 23:32 UTC]
Does this happen with PHP 4.0.5 ??
And if so, does it happen with the latest CVS? 
(snapshots: )


 [2001-05-07 00:57 UTC] dan at fatal dot net
User error :)

I was using the integer result from the ldap_bind() operation as the link index. ldap_bind() always returned 1 for true, which just happened to be the link index zend assigned to the ldap_connect(). The reason it "broke" when I connected to postgres was because zend apparantly keeps only 1 link index pool, assigns 1 to the postgres connection, then the ldap connection got 2. Also of interest was that the ldap connection always got a link index of 2 even after
executing a pg_close(), which I would of assumed would clear the first link index of 1 for ldap to use.

 [2001-05-07 01:04 UTC]
closed. (you imply that there was nothing wrong other than your error)

- James
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 22:01:32 2024 UTC