简体   繁体   中英

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.

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

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.

  • [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!

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

My server is Windows Server 2016 with Apache 24, and too was error. Move the file: libsasl.dll, from c:\\php to c:\\apache\\bin Restart Apache. Success!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM