简体   繁体   中英

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

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

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.

sudo apt-get install php5-ldap

并且不要害怕google。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM