php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29651 ldap_bind doesn�t work but ldap_connect works!
Submitted: 2004-08-13 13:19 UTC Modified: 2004-08-17 09:52 UTC
From: Alex_Diedler at gmx dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.3.8 OS: Linux Suse 9.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Alex_Diedler at gmx dot de
New email:
PHP Version: OS:

 

 [2004-08-13 13:19 UTC] Alex_Diedler at gmx dot de
Description:
------------
A Login make a request to LDAP-Server for User-Authentication.
The code is very simple, but it doesn?t work on Linux.
ldap_connect works fine on both (Windows and Linux)
ldap_bind anonymous works NOT on Linux! But on Windows works!
What?s the problem?

Reproduce code:
---------------
<?php
$ldaphost = "ldapserver.diedler.com";  
$ldapport = 389;                

// Verbindung zu LDAP
$ldapconn = ldap_connect( $ldaphost, $ldapport );
if ($ldapconn) {
	echo "<li>It works!<br>";
	}else {
	echo "<li>Failed<br>";
	}
$ldapbind = ldap_bind($ldapconn);
if ($ldapbind) {
	echo "<li>anon. Bind works!<br>";
	}else {
        echo "<li>bind failed<br>";
        }


?> 

Expected result:
----------------
The same result like on windows. It should work fine!


Actual result:
--------------
I removed all packages from Linux with PHP and Apache and LDAP.
I installed Apache 1.3.28 with devel.
OpenLDAP Client V2 and ldap_devel.
PHP 4.3.8 from Homepage php.net.
Install with ./configure --with-mysql --with=apxs --with-ldap

Important: remember that the connect to LDAP Server works! So it is not a maschine problem!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-17 00:18 UTC] iliaa@php.net
Cannot reproduce with my ldap servers, the specified 
hostname for your ldap server cannot be resolved. 
 [2004-08-17 07:26 UTC] Alex_Diedler at gmx dot de
Hello!
This URL is NOT A PUBLIC URL! Nobody can connect to it from outside!
 [2004-08-17 08:16 UTC] derick@php.net
No need to shout here and how do you expect us to reproduce the problem without an LDAP server?
 [2004-08-17 09:35 UTC] Alex_Diedler at gmx dot de
Hello,
The problem doesn?t seems to be in PHP. It?s a problem with the LDAP and SASL.
From the bug-database:
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.

This thread can be closed.
Thanks and greetings 
Alexander
 [2004-08-17 09:42 UTC] derick@php.net
Not a bug in PHP, it is something for the docs though
 [2004-08-17 09:52 UTC] vrana@php.net
This is already documented: "When OpenLDAP 2.x.x is used, ldap_connect() will always return a resource as it does not actually connect but just initializes the connecting parameters.  The actual connect happens with the next calls to ldap_* funcs, usually with ldap_bind()."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 04 17:01:30 2024 UTC