W3docs

Fatal error: Call to undefined function: ldap_connect()

This error message is indicating that the PHP function ldap_connect() is not defined or not available.

This error message is indicating that the PHP function ldap_connect() is not defined or not available. This function is used to connect to an LDAP server.

It is likely that the PHP LDAP extension is not installed or not enabled on your server. To fix this, install the extension using your system's package manager and ensure it is enabled in your php.ini file.

For Ubuntu/Debian:

sudo apt update
sudo apt install php-ldap

For RHEL/CentOS/Fedora:

sudo yum install php-ldap
# or
sudo dnf install php-ldap

If the extension is not automatically enabled, add the following line to your php.ini file:

extension=ldap

After making changes, restart your web server or PHP-FPM service (e.g., sudo systemctl restart apache2 or sudo systemctl restart php-fpm).

You can verify the extension is loaded by running:

php -m | grep ldap

Alternatively, check your phpinfo() output for the LDAP section.

Note that the LDAP extension is a core PHP module, not a separate library. Ensure your PHP version matches the package repository you are using to avoid compatibility issues.