Can't get LDAP functions to load in PHP

一曲冷凌霜 提交于 2019-12-06 09:51:59

You write:

When attempting to use ldap_connect(), I get this error:

Fatal error: Call to undefined function ldap_connect()

You get this error because the function ldap_connect­Docs is not defined. You can not call an undefined function in PHP, that's why you see the fatal error.

To get that function defined, you need to load a PHP module/extension called LDAP. It comes with installation intructions. You wrote:

I've recompiled php with the LDAP apache module enabled.

If you recompile PHP, ensure you enable LDAP, see:

You will need to use the --with-ldap[=DIR] configuration option when compiling PHP to enable LDAP support. DIR is the LDAP base install directory.

However, normally it's enough to just install what you need via the package manager, e.g. try:

# yum install php-ldap

If it's not enough and you actually need to edit your PHP configuration (not always necessary), do it:

$ vi /etc/php.ini

add extension=ldap.so

# service httpd restart

I hope this is helpful. Take care that .dll is windows only.

I would strongly recommend you use the PHP that you can install using yum. Depending on your RH version, you may have to specify that you want php53 (for RH < 6). So, do the install like this:

  1. yum install php53
  2. yum install php53-ldap

At this point, you should be good to go. You do not need to have any special Apache LDAP library installed at all to get PHP to work with LDAP.

If you are using RH 6, then you can skip the 53 part of the name.

Thomas Schultz

This is mostly a hunch, but have you tried downgrading to PHP 5.3.9?

There's a small amount of buzz on the internet about LDAP being broken on 5.3.10. Also, could try PHP 5.4 if you felt daring.

For CentOs. I have installed Php 7. So when I tried to execute

yum install php-ldap

there was this error

php71w-common conflicts with php-common-5.4.16-43.el7_4.1.x86_64

To solve this error and install ldap-php, execute

yum install php71w-ldap

The server will be trying to install 5.6 But we need to guide the server to install with 7.

If it is not working try adding the extension in php.ini which is mentioned in the other answer.

And don't forgot to restart the server.

Once the installation is done, the ldap-login will be done successfully.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!