Php ldap как включить

Enable PHP LDAP Module (XAMPP)

Connection to LDAP in PHP isn’t that easy task by itself. Things get even more complicated, if you’re working in XAMPP environment under Windows. It hope this article will help you in getting un-stuck, if you’re stuck on the similar things.

As in our experience, on a very rare situation, we were required to use Windows Active Directory or OpenLdap as our user database in WordPress. We need to enable php ldap module in XAMPP. By default this php ldap module is not enable in XAMPP as most web servers are not using ldap as their database or directory. Follow these simple steps to enable this module.

To use LDAP support in PHP served under Windows you need to have three libraries:

libsasl.dll ssleay32.dll libeay32.dll

You have to put them into system32 folder, if you’re serving your PHP through XAMPP.

You need to have libsasl.dll library not only for very old PHP 4.3 or older. Even newest versions of PHP 5.3 and above require this lib.

What is even more strange, I had this library (along with required ssleay32.dll and libeay32.dll) in my PHP’s directory and my PHP’s directory was listed in Windows’ PATH variable. And even so, I’m facing the problem of Apache failing to start. The only workaround, I found, was to copy libsasl.dll to system32 system directory.

Enable support

You have to edit your php.ini file and uncomment extension=php_ldap.dll line. Then you have to restart your Apache / XAMPP server.

Читайте также:  Шаблон готовая страница на php

If you don’t have above mentioned libraries, next run of server will fail with information, which directory is missing. Newest XAMPP brings these libraries in XAMPP’s php folder, so you only have to copy them to system32 folder, because for some strange reason, libraries in XAMPP’s php are not loaded, though all of them are in PATH system environment variable.

Copy all of these libraries (or just libsasl.dll, as many other programs are using ssleay32.dll and libeay32.dll libraries and one of them could already put these two libs) to your system32 folder.

Procedure

To enable php ldap module in XAMPP, find the following files and copy them to C:\Windows\system32\.

libsasl.dll ssleay32.dll libeay32.dll

Enable PHP LDAP Module (XAMPP)

Find and edit C:\xampp\php\php.ini and uncomment «extension=php_ldap.dll» around line 965.

Enable PHP LDAP Module (XAMPP)

Enable PHP LDAP Module (XAMPP)

Restart XAMPP (restart Apache service) and you should now have access to the PHP LDAP functions.

Источник

Php ldap как включить

LDAP support in PHP is not enabled by default. You will need to use the —with-ldap[=DIR] configuration option when compiling PHP to enable LDAP support. DIR is the LDAP base install directory. To enable SASL support, be sure —with-ldap-sasl[=DIR] is used, and that sasl.h exists on the system.

Note: Note to Win32 Users

In order for this extension to work, there are DLL files that must be available to the Windows system PATH . For information on how to do this, see the FAQ entitled «How do I add my PHP directory to the PATH on Windows». Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system’s PATH ), this is not recommended. This extension requires the following files to be in the PATH : libeay32.dll and ssleay32.dll , or, as of OpenSSL 1.1 libcrypto-*.dll and libssl-*.dll

In order to use Oracle LDAP libraries, proper Oracle environment has to be set.

User Contributed Notes 14 notes

I found not only «Versions before PHP 4.3.0 additionally require libsasl.dll.».

If you use php-5.3.3-Win32-VC9-x86 or later Versions that
It’s require libsasl.dll.

Running under Windows & Apache 2.2.8
PHP file is download from http://windows.php.net/downloads/releases/archives/

When I use php-5.2.x-Win32-VC6-x86 and php-5.3.x-Win32-VC6-x86

1.just uncomment extension=php_ldap.dll in php.ini
2.Restart apache,it’s ok

When I use php-5.3.x-Win32-VC9-x86 and php-5.4.x-Win32-VC9-x86

1.just uncomment extension=php_ldap.dll in php.ini
2.Restart apache,always fail.
(only php-5.3.1-Win32-VC9-x86 & php-5.3.2-Win32-VC9-x86 is ok. )

[php-5.3.3-Win32-VC9-x86 or later Versions]1.just uncomment extension=php_ldap.dll in php.ini
2.copy libsasl.dll to [apache folder]\bin
3.Restart apache,it’s ok

On newer versions of Windows and Windows Server, if you’ve installed PHP from the Microsoft Web Platform Installer (PI) then all you have to do is add extension=php_ldap.dll to the extensions section and restart IIS.

If using a debian machine (debian or ubuntu variants) just do apt-get install php5-ldap, that’s all to get ldap work on php. No need to get sources, try to compiling them and so on.

OCI client from Oracle distributes un ldap.h which may collision with the SO ldap.h.
You can, remove the Oracle ldap.h and build or configure php without oci8 and then add OCI8 later as a shared extension.
This latter step is easiest using PECL: pecl install oci8. You will then need to add ‘extension=oci8.so’ to your php.ini.

If you’re running on Windows XP with Apache, and you installed PHP 5 from the windows installer rather than the full zipped version — you may not have the php_ldap.dll file.

I had to follow the steps above, making sure PHP was added to my Windows Path, adding the 2 dll files to the system32 directory, also making sure the php.ini extensions directory was set correctly (in my case: C:\Program Files\PHP\ext).

Still was a getting a message about not being able to locate the «php_lamp.dll» file. I finally went back, downloaded the full .zip file of latest PHP version, and that missing dll file is included there — along with many others.

Remember to restart Apache server after you do all this.

To enable PHP LDAP for IIS, I installed PHP Manager which integrates with IIS. Open this up and you can enable/disable extensions. Enable php_ldap.dll and it works straight away.

The easiest way to install ldap extension on Ubuntu 12.04 is:

sudo apt-get install php5-ldap

Also don’t forget to laod the extension.

I can confirm Frank’s note (made 1 year ago, see below) about requirement of «libsasl.dll» library. I have «PHP Version 5.4.7» and my Apache fails to restart with error saying, that «libsasl.dll» is missing, once I enable php_ldap.dll extension in PHP configuration.

What is even more strange, I DO HAVE this library (along with required «ssleay32.dll» and «libeay32.dll» in my PHP’s directory and my PHP’s directory IS listed in Windows’ PATH variable and even so, I’m facing the problem of Apache failing to start.

The only workaround, I found is to copy «libsasl.dll» to «system32» system directory. Solution, that PHP documentation here discourages.

So, to summarize, section «Note to Win32 users» is twice wrong. You DO have to have «libsasl.dll» directory and you have to place it in your system folder.

Running under IIS, I did not find the need to download and compile libraries.

1. Edit PHP.INI (which should be in windows directory)
2. Uncomment the line extension=php_ldap.dll
3. Restart IIS

Running under IIS, I found php_ldap would not load even though d:\php contained libeay32.dll and ssleay32.dll, and d:\php was in the PATH environment variable.

I finally tracked this down to the position of d:\php in the PATH. If d:\php is near the head of the PATH, everything works fine. If d:\php is near the end of the PATH, apparently it gets ignored by IIS (even though it works fine from the command line, e.g., with php -m). Have no idea why this is.

Runing in IIS 8.5 on Server 2012 R2 I tried to install PHP Manager same as nesbittp needed to install Dot Net 3.5 and HTTP Activation first then installed without issue.

Источник

Установка поддержки LDAP в PHP на сервере LAMP Ubuntu

Чтобы включить поддержку LDAP на существующем веб-сервере Ubuntu Apache, вам необходимо установить пакет php5-ldap.

# sudo apt-get install php5-ldap

Это должно быть так, но в моей конкретной ситуации после запуска sudo apt-get install php5-ldap я получил следующую ошибку:

Reading package lists. Done Building dependency tree Reading state information. Done The following NEW packages will be installed php5-ldap 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 19.6 kB of archives. After this operation, 115 kB of additional disk space will be used. Err http://gb.archive.ubuntu.com/ubuntu/ natty-updates/main php5-ldap amd64 5.3.5-1ubuntu7.2 404 Not Found Err http://security.ubuntu.com/ubuntu/ natty-security/main php5-ldap amd64 5.3.5-1ubuntu7.2 404 Not Found [IP: 91.189.92.166 80] Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/php5/php5-ldap_5.3.5-1ubuntu7.2_amd64.deb 404 Not Found [IP: 91.189.92.166 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Чтобы решить эту проблему, мне пришлось запустить:

(это обновляет ваш локальный индекс пакета с последними изменениями, внесенными в репозитории).
и повторите приведенные выше команды.

Когда ldap установлен и включен, phpinfo () отобразит раздел ldap:

Пример использования функций PHP LDAP для поиска в Windows Active Directory.

Источник

Оцените статью