Ldap Authentication Issue

Situation
ldap authentication Issue.

OpenEMR Version
I’m using OpenEMR version

Browser:
I’m using: Google Chrome

Operating System
I’m using: 24.04

Search
Did you search the forum for similar questions?

Logs
[Mon Apr 14 15:55:33.044154 2025] [php:error] [pid 145041] [client 183.82.115.44:20393] PHP Fatal error: Uncaught Error: Call to undef
ined function OpenEMR\Common\Auth\ldap_connect() in /var/www/html/smartemr/src/Common/Auth/AuthUtils.php:835\nStack trace:\n#0 /var/
www/html/smartemr/src/Common/Auth/AuthUtils.php(1273): OpenEMR\Common\Auth\AuthUtils->activeDirectoryValidation()\n#1 /var/www/html/
smartemr/src/Common/Auth/AuthUtils.php(332): OpenEMR\Common\Auth\AuthUtils->preventTimingAttack()\n#2 /var/www/html/smartemr/src/Com
mon/Auth/AuthUtils.php(130): OpenEMR\Common\Auth\AuthUtils->confirmUserPassword()\n#3 /var/www/html/smartemr/library/auth.inc.php(63
): OpenEMR\Common\Auth\AuthUtils->confirmPassword()\n#4 /var/www/html/smartemr/interface/globals.php(630): require_once(‘…’)\n#5 /
var/www/html/smartemr/interface/main/main_screen.php(19): require_once(‘…’)\n#6 {main}\n thrown in /var/www/html/smartemr/src/Common
/Auth/AuthUtils.php on line 835, referer: OpenEMR Login

This page isn’t working
smart-emr.com is currently unable to handle this request.
HTTP ERROR 500

Use following the steps, It would be work.
The error you’re encountering in OpenEMR:

PHP Fatal error: Uncaught Error: Call to undefined function OpenEMR\Common\Auth\ldap_connect()

:mag: Root Cause:

The error means that the function ldap_connect() is not available in your PHP environment — likely because the LDAP PHP extension is not installed or enabled.

Shape

:white_check_mark: Solution: Install and Enable PHP LDAP Extension

Since you’re on Ubuntu 24.04, follow these steps:

  1. Install the PHP LDAP extension

Depending on the PHP version OpenEMR is using, run one of the following:

For PHP 8.1 (commonly used in OpenEMR 7.x+)

sudo apt install php8.1-ldap

If you’re unsure about the PHP version:

php -v

You can adapt the version (php8.x-ldap) accordingly.

Shape

  1. Restart Apache

Once installed, restart the Apache web server:

sudo systemctl restart apache2

Shape

  1. Verify Extension is Enabled

You can confirm LDAP is now enabled by running:

php -m | grep ldap

It should return:

ldap

Shape

:pushpin: Additional Checks

Make sure php.ini has not disabled LDAP:

; Ensure this line is not commented out

extension=ldap

Check that your php.ini is being loaded from the correct path:

php --ini

Shape

:test_tube: After Fixing

Go back to your OpenEMR login page, and the HTTP 500 error should be gone. LDAP login should now work properly.

Let me know your PHP version if you need the exact extension command, or I can help verify your Apache/PHP config.

If you face any difficulties, feel free to contact us