mithun3010
mithun3010

Reputation: 41

LDAP connection bind not successful

I am trying to make a LDAP connection to a test server from apache2(Ubuntu) with PHP. I have php-ldap installed. And this is my connection code snippet.

$ldap_dn = "cn=read-only-admin,dc=example,dc=com";
$ldap_password = "password";

$ldap_con = ldap_connect("ldap.forumsys.com", "389") or die("Not connected");

ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);

if(ldap_bind($ldap_con, $ldap_dn, $ldap_password)) {

  echo "Bind successful!";

} else {
    echo "Invalid user/pass or other errors!";
}

Log: [:error] [pid 7332] [client 10.9.114.7:47852] PHP Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in /var/www/html/connect_test.php

This code works on my localhost. But in the apache2 server, ldap_connect is successful but ldap_bind is not. Can I know what I am doing wrong? Newbie here! Thanks in advance! :)

Upvotes: 0

Views: 1534

Answers (1)

mithun3010
mithun3010

Reputation: 41

For anyone who looks this up later. The problem is - there was a firewall blocking all other LDAP connections except our own. That's the reason why the test LDAP server from forumsys didn't work. Once you install php-ldap, you are good to go ahead and connect to any LDAP server if your firewall allows it. Hope this helps! :)

Upvotes: 1

Related Questions