Installing LDAP support in PHP on Ubuntu LAMP server

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
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 natty-updates/main php5-ldap amd64 5.3.5-1ubuntu7.2
404  Not Found
Err natty-security/main php5-ldap amd64 5.3.5-1ubuntu7.2
404  Not Found [IP: 80]
Failed to fetch  404  Not Found [IP: 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:
LDAP support in PHP
For an example of how to use PHP LDAP functionality to search Windows Active Directory check here.


sanoj Hettige
+1 # sanoj Hettige 2014-12-05 11:01
Thanks very much , its working perfectly
+1 # hakim 2014-12-02 14:30
thanks. twas helpful ))
+1 # rer 2014-09-04 04:23
Quoting Martin:
Wonderful!! Thanks very much. (Bulgaria)

+5 # Martin 2012-09-13 15:06
Wonderful!! Thanks very much. (Bulgaria)


Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait