I'm trying to write some LDAP authentication code on my WAMP server.
I'm using this:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$ldapconfig['host'] = 'my.server.province.country';
$ldapconfig['port'] = 389;
$ldapconfig['basedn'] = 'DC=x,DC=y,DC=z,DC=x1';
$ldapconfig['authrealm'] = 'My Realm';
ldap_connect($ldapconfig['host'], $ldapconfig['port']) or die ('Could not connect');
echo 'connected';
?>
I'm getting this error:
Fatal error: Call to undefined function ldap_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\oplweb\index.php on line 10
From some basic Googling, it looks like I need to turn on mod_ldap. Seems simple. I've done the following:
The problem still persists. Does the ldap_connect() function in php have any other dependencies? Am I missing a step?
Cheers
I ran into this same issue with my Windows Server 2008 - Have you added the php.ini file to your windows path?
Go to Control Panel and open the System icon (Start -> Settings -> Control Panel -> System, or just Start -> Control Panel -> System for Windows XP/2003+)
Go to the Advanced tab
Click on the 'Environment Variables' button
Look into the 'System Variables' pane
Find the Path entry (you may need to scroll to find it)
Double click on the Path entry
Enter your PHP directory at the end, including ';' before (e.g. ;C:\php)
Press OK
Check your phpinfo to make sure ldap is enabled. You should see an LDAP section, and
Support | enabled
You may have php set to auto-enable anything in your extension dir, or you may have to manually enable it by uncommenting a line that looks like:
extension=php_ldap.dll
in your php.ini file
Remember to restart apache after you enable it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With