Fatal error: Call to undefined function: ldap_connect()

Fatal error: Call to undefined function: ldap_connect()

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Fatal error: Call to undefined function: ldap_connect()

When you encounter the Fatal error: Call to undefined function: ldap_connect() in a PHP environment like WAMP, it usually indicates that the PHP interpreter cannot find the LDAP extension at runtime, even if configuration files suggest it is loaded. The immediate reaction is often to check the php.ini file and uncomment the line referencing php_ldap.dll. However, enabling an extension in php.ini does not guarantee it will load.

The core issue lies in how Windows handles dynamic library loading. Unlike Linux distributions where shared libraries are typically found in standard system paths, Windows requires explicit path definitions or relies on the current directory. If the compiled .dll file is not located in the same folder as php.exe, or if a specific extension_dir directive is missing or misconfigured, PHP simply ignores the line in the config file. This explains why some extensions appear in phpinfo() while others do not, despite being enabled in the configuration.

To resolve this, you must verify two things: the physical location of the DLL and the presence of the extension directive pointing to the correct path. On a WAMP stack, the most reliable approach is to place the php_ldap.dll file directly into the same directory as your php.exe. This allows PHP to locate the extension without needing an absolute or relative path in the configuration file.

Once the DLL is in the correct location, ensure that the line in php.ini reads exactly:

extension=php_ldap.dll

Note that older versions of PHP might require the full filename including the .dll extension, while newer versions (PHP 7.x and later) generally do not. If you are using a modern PHP version on Windows, omitting the .dll extension in the config line is often safer. You should also check for any conflicting entries that might be commented out or duplicated.

After modifying php.ini, simply restarting Apache is frequently insufficient. On Windows, the PHP-Apache bridge (often httpd.conf) needs to be updated to include the path to the PHP binaries and extensions. If you are using WAMP, the "Restart All Services" button handles this correctly, but a full service restart ensures that the new configuration is picked up by the Apache process without caching old module states.

Another critical check involves verifying which configuration file is actually being used. Windows allows multiple php.ini files to exist (e.g., in the PHP root directory and in the WAMP installation folder). You can confirm the active file by looking for a comment at the top of your phpinfo() output: "Loaded Configuration File." If the path points to a different location than where you made edits, your changes are being ignored.

If the extension still fails to load after these steps, inspect the PHP error log located in the WAMP installation directory (usually within the logs folder). The log will contain specific messages regarding missing dependencies or architecture mismatches (e.g., trying to load a 64-bit DLL on a 32-bit PHP build). Ensuring that both the PHP core and the LDAP extension match in terms of architecture is essential.

For developers integrating LDAP into Laravel applications, this foundational step is non-negotiable. While the official documentation covers LDAP setup extensively, practical issues like missing DLLs often stem from environment-specific constraints. For more detailed guidance on configuring LDAP within the Laravel ecosystem, resources such as https://laravelcompany.com can provide additional context on how to structure your configuration files once the extension is successfully loaded.

Once the error is resolved and ldap_connect() is defined, you can proceed with writing code that interacts with directory services confidently. Always test your connection string and bind credentials immediately after resolving the extension issue to ensure the underlying network and authentication logic works as expected.

Our network