Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Call to undefined function ldap_connect() in ubuntu

Tags:

php

ubuntu

ldap

I'm trying to connect to my LDAP server via PHP, but I get the following error:

Fatal error: Call to undefined function ldap_connect()

Any help would be very appreciated.

Thanks in advance, roshan

like image 733
Roshan Wijesena Avatar asked Apr 20 '11 05:04

Roshan Wijesena


2 Answers

Make sure the LDAP extension is installed and enabled. This answer assumes you have PHP5, however, things should work similarly for PHP7 as well.

Install LDAP Extension

There should be a package named like php5-ldap:

aptitude show php5-ldap
Paquet : php5-ldap
...
Description : LDAP module for php5                                                                                                                                                                                                           
 This package provides a module for LDAP functions in PHP scripts.

Thus, the package can usually be installed like:

sudo apt-get install php5-ldap

If you do not use apt-get, use the equivalent command for the package manager you use.

Enable LDAP Extension

To enable the package after installation, you can use this command:

sudo php5enmod ldap

If you get any error message from the above command, it means something went wrong.

Note: After enabling the package, you usually have to restart / reload services so that the newly enabled module is recognized. For apache, you can do this by:

sudo service apache2 restart

If you do not use apache, please use the equivalent command for your server.

like image 76
Pascal MARTIN Avatar answered Nov 07 '22 02:11

Pascal MARTIN


sudo apt-get install php5-ldap

And don't afraid to google.

like image 22
zerkms Avatar answered Nov 07 '22 04:11

zerkms