|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19494 ldap_bind() fails and doesnt use bind-dn
Submitted: 2002-09-19 05:02 UTC Modified: 2002-10-10 01:39 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cm at financial dot com Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.2.2 and 4.3.0-dev OS: Linux 2.4.17
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: cm at financial dot com
New email:
PHP Version: OS:


 [2002-09-19 05:02 UTC] cm at financial dot com
Alos Tested with 4.3.0-dev.

$ds=ldap_connect("myserver") works var_dump($ds) gives "resource(X) of type (ldap link)"
ldap_bind returns "Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server".
The LDAP Server (OpenLdap) always shows an anonymous bind no matter if i bind with user or not. After each bind i get a mysql-service-lookup on that connection. Maybe something 
like in bug #17350 with oracle ?



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 05:37 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2002-09-19 06:44 UTC] cm at financial dot com
My script calls 
ldap_bind($ds); // or ldap_bind($ds,$my_user_dn,$my_user_pass)

I expected PHP to return TRUE on ldap_connect()

It gave me: "Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server"

PHP Version 4.3.0-dev
Configure Command  './configure' '--with-mysql' '--with-apxs=/usr/local/apache/bin/apxs' '--with-ldap'

MySQL Support enabled
Active Persistent Links 1
Active Links 1
Client API version 3.23.49
MYSQL_SOCKET /tmp/mysql.sock

LDAP Support enabled
RCS Version $Id: ldap.c,v 1.128 2002/09/05 11:22:20 hyanantha Exp $
Total Links 0/unlimited
API Version 2004
Vendor Name OpenLDAP
Vendor Version 20015
 [2002-09-19 07:00 UTC]
It's most likely some problem with your ldap server.
Have you tried to connect to some public ldap server?

Also, try adding 'echo ldap_error($ds);' after the ldap_connect() call.

 [2002-09-19 07:14 UTC] cm at financial dot com
>It's most likely some problem with your ldap server.
>Have you tried to connect to some public ldap server?

unlikely because i use it for nss_ldap and pam_ldap login on several machines also as i wrote in the very beginning it binds but without the given bind-dn

>Also, try adding 'echo ldap_error($ds);' after the >ldap_connect() call.
this prints "Success"
 [2002-09-20 13:47 UTC]
I'm not so sure this is the problem, but are you running
OpenLDAP 2.1 server? By default it only accepts LDAPv3
binds, and the API by default do LDAPv2 binds. IF you do,
try to tell the API to use v3 binds using ldap_set_option().
 [2002-09-23 01:43 UTC] cm at financial dot com
thought that too after i read that on some other bug here. i tried with ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3) still no change.
 [2002-09-23 08:54 UTC] cm at financial dot com
very funny, when i use URL-syntax in ldap_connect it works. the state after the ldap_connect seems to be identical except that the ldap_bind now works with and without bind-dn
 [2002-09-24 04:12 UTC] cm at financial dot com
Well it seems like ldap_connect has some problem.
1. Scenario
-> echo $ldap_error($ds) say "Success" but ldap_bind fails
(also $ds is true and var_dump says "ressource (X) of type (ldap link)")
2. Scenario
-> echo $ldap_error($ds) say success and ldap_bind works.

of course $CONFIG["ldap-server"] is defined as "ldaps://my.ldap.server" i checked that 3 times.

So is this right that ldap_connect says everything is OK though it is not really ?

 [2002-09-24 04:15 UTC]
If $CONFIG["ldap-server"] is defined as "ldaps://my.ldap.server" then it's exactly the same for PHP.
There is NO way that this could be a problem. Are you very sure there isn't a trailing newline or a \0 somehwere?

 [2002-09-24 04:26 UTC] cm at financial dot com
this is what the config line looks like:
$CONFIG["ldap_server"] = "ldaps://my.ldap.server";
and then i do:

even if there would be a difference shouldnt be the result of ldap_connect be FALSE.
and ldap_error($ds) give an error

From the docs:

 Returns a positive LDAP link identifier on success, or FALSE on error.
 [2002-10-10 01:39 UTC]
When you use OpenLDAP 2 or other libraries that use the
new LDAP API, ldap_connect() will only create some state
on the client, the server is not contacted until you later
do an LDAP operation like search or bind. There are no DNS
lookups either, so ldap_connect("jlkdsfjsdk") will be
successful. This means that ldap_connect() will almost
always return true, while later operations might very well fail.

Another difference worth noting, is that for anonymous
access there is no more need for ldap_bind(). You just
do your search.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC