php.net |  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
Votes:1
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 - 21 = ?
Subscribe to this entry?

 
 [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 ?

Chris

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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 
$ds=ldap_connect("my.ldap.server");
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_MODULE_TYPE builtin
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] sniper@php.net
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] venaas@php.net
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
$ds=ldap_connect($CONFIG["ldap_server"]);
-> 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
$ds=ldap_connect("ldaps://my.ldap.server");
-> 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 ?

Chris
 [2002-09-24 04:15 UTC] derick@php.net
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?

Derick
 [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:
$ds=ldap_connect($CONFIG["ldap_server"]);

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] venaas@php.net
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: Sun Apr 14 23:01:27 2024 UTC