Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LDAP Auth on WAMP [closed]

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:

  • Went to C:\Program Files\Apache Software Foundation\Apache2.2\modules and made sure that mod_ldap.so exists.
  • I've gone into C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf and made sure that this line is not commented out: LoadModule ldap_module modules/mod_ldap.so
  • I've gone into C:\Program Files\PHP\php.ini and made sure this line is not commented out: extension=php_ldap.dll
  • Restart apache

The problem still persists. Does the ldap_connect() function in php have any other dependencies? Am I missing a step?

Cheers

like image 933
Cory Dee Avatar asked Feb 23 '11 16:02

Cory Dee


2 Answers

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

like image 74
Slukehart Avatar answered Sep 20 '22 12:09

Slukehart


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.

like image 29
dobrien Avatar answered Sep 20 '22 12:09

dobrien