|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-05-21 23:21 UTC] john dot canavan at redbrick dot dcu dot ie
When running OpenLdap on a port other than the default 389, ldap_bind fails to function - giving the following error message -
Warning: LDAP: Unable to bind to server: Can't contact LDAP server in /var/www/html/connext.phtml on line 29
The related php section of connext.phtml being -
<?php
echo "begin php block code .....<br><br>\n";
$host = "ldap://ip.goes.here";
$port = 37337;
$binddn = "cn=Manager, o=netfaves, c=ie";
$bindpw = "secret";
$check = ldap_connect( $host, $port );
echo "check = " ;print("$check <br>");
if($check)
{
echo "Connected successfully <br><br>\n";
$bindcheck = ldap_bind( $check, "cn=Manager, o=netfaves, c=ie", "secret" );
print("bindcheck = '$bindcheck'<br>");
if ($bindcheck)
echo "Succesfully Bound<br><br>\n";
else
echo "No luck this time buddy...<br><br>\n";
}
else
echo "Error! Could not connect to ldap host $host<br>\n";
echo "....end php block code <br><br>\n";
?>
ldap_connect functions as expected here and returns "Resource id #1".
When I restart slapd, this time running on port 389, ldap_bind has no problem connecting and returning "1". I tried running slapd on various other high ports, each time getting the same error message. This pretty much means that you need to run slapd as root to be able to interact with it via php.
I had a quick look through the source but couldn't pinpoint anything that might be at fault - but my C isn't the best anyway.
I had the same problem with php 4.2.1 aswell, but haven't had the chance to try reproduce it.
Regards,
John Canavan
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 13:00:02 2025 UTC |
If you use URL syntax, you must supply the port number in the URL. This is noted in the manual for ldap_connect(). So try either ldap_connect("ip.goes.here", "37337") or ldap_connect("ldap://ip.goes.here:37337"). I'm closing this case then, reopen or let me know if for some reason this doesn't help (I'm pretty sure it does).