Расширение ldap для php

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

License

FreeDSx/LDAP

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

FreeDSx LDAP is a pure PHP LDAP library. It has no requirement on the core PHP LDAP extension. This library currently implements most client functionality described in RFC 4511 and some very limited LDAP server functionality. It also implements some other client features from various RFCs:

  • Paging Control Support (RFC 2696)
  • VLV Control Support (draft-ietf-ldapext-ldapv3-vlv-09)
  • Server Side Sort Control (RFC 2891)
  • Password Modify Request (RFC 3062)
  • String Representation of Search Filters (RFC 4515)
  • SASL authentication / integrity layer support for certain mechanisms (RFC 4513)

It supports encryption of the LDAP connection through TLS via the OpenSSL extension if available.

composer require freedsx/ldap

Use the LdapClient class and the helper classes:

use FreeDSx\Ldap\LdapClient; use FreeDSx\Ldap\Operations; use FreeDSx\Ldap\Search\Filters; $ldap = new LdapClient([ # Servers are tried in order until one connects 'servers' => ['dc1', 'dc2'], # The base_dn is used as the default for searches 'base_dn' => 'dc=example,dc=local' ]); # Encrypt the connection prior to binding $ldap->startTls(); # Bind to LDAP with a specific user. $ldap->bind('user@example.local', '12345'); # Build up a LDAP filter using the helper methods $filter = Filters::and( Filters::equal('objectClass', 'user'), Filters::startsWith('cn', 'S'), # Add a filter object based off a raw string filter. Filters::raw('(telephoneNumber=*)') ); # Create a search operation to be used based on the above filter $search = Operations::search($filter, 'cn'); # Create a paged search, 100 results at a time $paging = $ldap->paging($search, 100); while ($paging->hasEntries()) < $entries = $paging->getEntries(); var_dump(count($entries)); foreach ($entries as $entry) < echo "Entry: ".$entry->getDn().PHP_EOL; > >
use FreeDSx\Ldap\Entry\Entry; use FreeDSx\Ldap\Exception\OperationException; # Create a new LDAP entry object $entry = (new Entry('cn=foo,dc=domain,dc=local')) ->set('objectClass','top', 'group') ->set('sAMAccountName', 'foo'); # Create the entry with the LDAP client try < $ldap->create($entry); > catch (OperationException $e) < echo sprintf('Error adding entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL; >
# Use the read() method of the LDAP client to search for a specific entry. # Optionally pass an array of attributes to select as the second argument. $entry = $ldap->read('cn=foo,dc=domain,dc=local'); # Entry will be null if it doesn't exist if ($entry) < echo $entry.PHP_EOL; var_dump($entry->toArray()); >
use FreeDSx\Ldap\Exception\OperationException; # Search for an entry object to get its current attributes / values $entry = $ldap->read('cn=foo,dc=domain,dc=local'); # Add a value to an attribute if (!$entry->get('telephoneNumber')) < $entry->add('telephoneNumber', '555-5555'); > # Remove any values an attribute may have if ($entry->has('title')) < $entry->reset('title'); > # Delete a specific value for an attribute if ($entry->get('ipPhone')->has('12345')) < $entry->delete('ipPhone', '12345'); > # Set a value for an attribute. This replaces any value it may, or may not, have. $entry->set('description', 'Employee'); # Send the built up changes back to LDAP to update the entry via the LDAP client update method. try < $ldap->update($entry); > catch (OperationException $e) < echo sprintf('Error modifying entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL;; >
use FreeDSx\Ldap\Exception\OperationException; # Search for the entry object to delete $entry = $ldap->read('cn=foo,dc=domain,dc=local'); # Pass the entry object to the delete method of the LDAP client if it was found. # You could also pass a DN object or a simple DN as a string. if ($entry) < try < $ldap->delete($entry); > catch (OperationException $e) < echo sprintf('Error deleting entry (%s): %s', $e->getCode(), $e->getMessage()).PHP_EOL;; > >

About

Источник

Читайте также:  Html input upload files

Расширение ldap для php

Поддержка LDAP в PHP не доступна по умолчанию. Для активации нужно использовать опцию —with-ldap[=DIR] при компиляции PHP, где DIR — это каталог установки базы LDAP. Для включения поддержки SASL, убедитесь что использована опция —with-ldap-sasl[=DIR], и что sasl.h существует в системе.

Замечание: Примечание для пользователей Win32

Для работы этого модуля системной переменной Windows PATH должны быть доступны DLL -файлы. Чтобы узнать как этого достичь, обратитесь к разделу FAQ «Как добавить мою директорию с PHP в переменную Windows PATH». Хотя копирование DLL-файлов из директории PHP в системную папку Windows также решает проблему (потому что системная директория по умолчанию находится в переменной PATH ), это не рекомендуется. Этому модулю требуются следующие файлы в переменной PATH : libeay32.dll и ssleay32.dll , либо, начиная с OpenSSL 1.1, libcrypto-*.dll и libssl-*.dll .

Для того чтобы использовать библиотеки Oracle LDAP, должны быть установлены надлежащие параметры окружающей среды Oracle.

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.

Читайте также:  Скрывать адресную строку html

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.

Читайте также:  Java list type argument

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.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A PHP LDAP Package for humans.

License

Adldap2/Adldap2

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

readme.md

👋 Hey there! Looking for something even easier to use for LDAP integration in your PHP applications?

LdapRecord is the successor to Adldap2 — and comes with a ton of new features.
Adldap2 will continue to be supported with bug fixes, but will not receive new features.

Adldap2 is a PHP package that provides LDAP authentication and directory management tools using the Active Record pattern.

  • Up and running in minutes. Effortlessly connect to your LDAP servers and start running queries & operations in a matter of minutes.
  • Fluent query builder. Building LDAP queries has never been so easy. Find the records you’re looking for in a couple lines or less with a fluent interface.
  • Supercharged Active Record. Create and modify LDAP records with ease. All LDAP records are individual models. Simply modify the attributes on the model and save it to persist the changes to your LDAP server.

If you discover a security vulnerability within Adldap2, please send an e-mail to Steve Bauman via steven_bauman@outlook.com.

All security vulnerabilities will be promptly addressed.

About

A PHP LDAP Package for humans.

Источник

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