I am trying to bind to an LDAP server using php without success. I have a linux server running php compiled with open ldap. I am using the following code taken right from php.net:
Code: ( php )
1.
echo "<h3>LDAP query test</h3>";
2.
echo "Connecting ...";
3.
$ds=ldap_connect("ldap.berkeley.edu"); // must be a valid LDAP server!
4.
echo "connect result is ".$ds."<p>";
5.
6.
if ($ds) {
7.
echo "Binding ...";
8.
$r=ldap_bind($ds); // this is an "anonymous" bind, typically
9.
// read-only access
10.
echo "Bind result is ".$r."<p>";
I get a result from ldap_connect, but an error with ldap_bind. I get the following error:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in /home/eric/public_html/academic-senate-test/authenticate/login_action.php on line 26
Here is the readout from phpinfo under the ldap section:
LDAP Support enabled
RCS Version $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $
Total Links 0/unlimited
API Version 3001
Vendor Name OpenLDAP
Vendor Version 20213
Appreciate any advice, thanks!
I can access ldap.berkeley.edu from other ldap browsers just fine. The php code is on a server separate from the ldap directory. Is there a specific way to compile php with ldap so that it knows to access a server that is not local, could this be the problem?
I have googled, found a fair number of people reporting this problem but no answers. I appreciate any advice, thanks!
Eric