LDAP Auth on WAMP

17,969

Solution 1

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

Solution 2

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.

Solution 3

for WAMP, the working version of php.ini is located at apache\bin. i was experienced same problem before until i change php.ini setting inside apache\bin and finally it works.

Solution 4

If you're connecting to an Active Directory, you can use this class which doesn't require any special PHP extension: http://sourceforge.net/projects/adldap/

Solution 5

I ran into the same problem recently and I searched for php.ini on my disk and found that there are two php.ini files there -- one under the php directory and the other under the apache\bin directory. I uncommented the extension=php_ldap.dll line in both files and the problem is solved.

Share:
17,969
Cory Dee
Author by

Cory Dee

I'm pretty much awesome - but then, I'm a bit biased here as well.

Updated on June 04, 2022

Comments

  • Cory Dee
    Cory Dee almost 2 years

    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