LDAP support in PHP is not enabled by default. To enable LDAP support on an existing Ubuntu Apache web server you need to install php5-ldap package.
Install php5-lda:
sudo apt-get install php5-ldap
Reboot apache
/etc/init.d/apache2 restart
That should be it, but in my particular situation after running sudo apt-get install php5-ldap I got following error:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed
php5-ldap
0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded.
Need to get 19.6 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Err http://gb.archive.ubuntu.com/ubuntu/ natty-updates/main php5-ldap amd64 5.3.5-1ubuntu7.2
404 Not Found
Err http://security.ubuntu.com/ubuntu/ natty-security/main php5-ldap amd64 5.3.5-1ubuntu7.2
404 Not Found [IP: 91.189.92.166 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php5/php5-ldap_5.3.5-1ubuntu7.2_amd64.deb 404 Not Found [IP: 91.189.92.166 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
To resolve this I had to run:
apt-get update (this updates your local package index with the latest changes made in repositories.)
and repeat the commands above.
When ldap is installed and enabled, phpinfo() will display ldap section:
For an example of how to use PHP LDAP functionality to search Windows Active Directory check here.
Leave a Reply