我正在尝试通过 PHP 连接到我的 LDAP 服务器,但出现以下错误:
I'm trying to connect to my LDAP server via PHP, but I get the following error:
致命错误:调用未定义函数 ldap_connect()
Fatal error: Call to undefined function ldap_connect()
任何帮助将不胜感激.
提前致谢,肉山
确保 LDAP 扩展 已安装并启用.这个答案假设你有 PHP5,但是,对于 PHP7,事情也应该类似地工作.
Make sure the LDAP extension is installed and enabled. This answer assumes you have PHP5, however, things should work similarly for PHP7 as well.
安装 LDAP 扩展
应该有一个类似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
如果您不使用 apt-get
,请使用您使用的包管理器的等效命令.
If you do not use apt-get
, use the equivalent command for the package manager you use.
启用 LDAP 扩展
要在安装后启用包,可以使用以下命令:
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.
注意: 启用包后,通常需要重启/重新加载服务才能识别新启用的模块.对于 apache,您可以通过以下方式执行此操作:
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
如果您不使用 apache,请为您的服务器使用等效命令.
If you do not use apache, please use the equivalent command for your server.
这篇关于致命错误:在 ubuntu 中调用未定义函数 ldap_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!