Friday, April 15, 2011

LDAP Authentication Missing on Windows Moodle

Lately I've been working on putting up a countywide Moodle server.  Since we are a Windows shop I've installed it on Windows Server 2008 R2 running PHP (5.3.5) and II7.  I also installed to a Microsoft SQL 2008 database on the back end.

We've tried this many times before, but it never seemed to work.  There have been vast improvements in installing PHP on Windows and Moodle 2.0+ is compliant with using a MS SQL database.  I did they installs and everything worked perfect.  And then Murphy showed up!

This morning I navigated to Advanced features > Plugins > Authentication >  LDAP Server with the intention of setting up LDAP support.  Guess what?  Yeah that's right, it didn't work!  In fact I saw this cozy little message.

 The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled if you want to use this authentication plugin.

Drat!  So, after much searching the web here is what worked for me...
  1. Verify that your php directory is included in your system path.  (You can check this by opening up a command window and running php -m.)  If you need help of fixing this, ask Google.
  2. Navigate to http://php.net/downloads.php and click on the link listed under Windows Binaries.  As of this writing, it is located here.
  3. Download the zip file relating to your installed version.  In my case 5.3 x86 Non Thread Safe.
  4. After the download completes, open the Zip file.  Locate and copy php_ldap.dll to your extension directory.  (You can find your extension directory by running http://{your site}/admin/phpinfo.php and locating the entry for extension_dir.)
  5. Open your php.ini file.  (You can find which php.ini file your system is using by locating the entry named Loaded Configuration File on the phpinfo page.)
  6. Look for a line that matches the following.  If it exists delete the semicolon.  Otherwise, create this entry without the semicolon.
    [PHP_LDAP]
  7. ;extension=php_ldap.dll
  8. Now open up a command window and run the php -m command. If it runs successfully LDAP should be working. If not, it will reference dlls that are missing. 
  9. In my case, I was missing  libsasl.dll.  Locate and copy libsasl.dll to the root of your php directory. (In my case C:\php.)
  10. Restart IIS, just for good measure.
  11. Navigate back to Advanced features > Plugins > Authentication >  LDAP Server and you should see the setup fields available to you.