php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17350 ldap_bind not working for servers running on ports other than the default
Submitted: 2002-05-21 23:21 UTC Modified: 2002-06-21 15:24 UTC
Votes:4
Avg. Score:3.8 ± 1.6
Reproduced:1 of 3 (33.3%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: john dot canavan at redbrick dot dcu dot ie Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.1.2 OS: RedHat 7.3
Private report: No CVE-ID: None
 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-21 15:24 UTC] venaas@php.net
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).

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 07:01:28 2024 UTC