Josh M
Josh M

Reputation: 992

Fatal error: Call to undefined function: ldap_connect()

I get this error when using WAMP:

Fatal error: Call to undefined function: ldap_connect()

I have already edited the php.ini folder and enabled php_ldap.dll.

For some reason only some of the extensions show up in phpinfo() when I turn them on. I have restarted Apache and restarted my computer.

Upvotes: 48

Views: 158283

Answers (6)

Napets
Napets

Reputation: 11

Thank you all for your contributions. For my part, I needed to act on the 3 following points to make ldap_connect() work in PHP8.2.3 :

  1. add php_ldap.dll to php.ini
  2. copy libsasl.dll from PHP to APACHE
  3. add the PHP path to the PATH environment variable then restart APACHE

Upvotes: 1

True.x
True.x

Reputation: 1

My server is Windows Server 2016 with Apache 2.4, and I was having this error too. Move the file libsasl.dll, from C:\php to C:\apache\bin and Restart Apache.

Upvotes: 0

Robert Karamagi
Robert Karamagi

Reputation: 97

Open the XAMMP php.ini file (the default path is C:\xammp\php\php.ini) and change the code (;extension=ldap) to extension=php_ldap.dll and save. Restart XAMMP and save.

php.ini

; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
extension=php_ldap.dll

Upvotes: 0

sushant-hiray
sushant-hiray

Reputation: 1898

If you are a Windows user, this is a common error when you use XAMPP since LDAP is not enabled by default.

You can follow this steps to make sure LDAP works in your XAMPP:

  • [Your Drive]:\xampp\php\php.ini: In this file uncomment the following line:

     extension=php_ldap.dll
    
  • Move the file: libsasl.dll, from [Your Drive]:\xampp\php to [Your Drive]:\xampp\apache\bin (Note: moving the file is needed only for XAMPP prior to version: 5.6.28)

  • Restart Apache.

  • You can now use functions of the LDAP Module!

If you use Linux:

For php5:

sudo apt-get install php5-ldap

For php7:

sudo apt-get install php7.0-ldap

If you are using the latest version of PHP you can do

sudo apt-get install php-ldap

running the above command should do the trick.

if for any reason it doesn't work check your php.ini configuration to enable ldap, remove the semicolon before extension=ldap to uncomment, save and restart Apache

Upvotes: 128

Sakawa Bob
Sakawa Bob

Reputation: 17

  • [Your Drive]:\xampp\php\php.ini: In this file uncomment the following line:

    extension=php_ldap.dll

  • Move the file: libsasl.dll, from [Your Drive]:\xampp\php to [Your Drive]:\xampp\apache\bin Restart Apache. You can now use functions of the LDAP Module!

Upvotes: 0

HimalayanCoder
HimalayanCoder

Reputation: 9850

Add path of your PHP to Windows System Path. The path should contain php.exe.

After adding the path open a new command prompt and make sure php.exe is in path by typing

C:\>php --help

Once you see proper help message from above, enable the php_ldap.dll extension in php.ini

Also copy php_ldap.dll from php/ext directory to apache/bin folder

Restart wamp and phpinfo() will now show ldap enabled.

Upvotes: 3

Related Questions