Object oriented interface for searching and manipulating LDAP entries & filters
Go to file
Benjamin Renard 8dad96ee32 Complete tests on Entry and improve php2ldap() method 2023-03-26 16:33:56 +02:00
src Complete tests on Entry and improve php2ldap() method 2023-03-26 16:33:56 +02:00
tests Complete tests on Entry and improve php2ldap() method 2023-03-26 16:33:56 +02:00
.gitignore Initial commit 2023-03-13 02:13:21 +01:00
.pre-commit-config.yaml Initial commit 2023-03-13 02:13:21 +01:00
README.md Add README.md file 2023-03-13 02:42:09 +01:00
composer.json Add tests on Ldap class and fix some related bugs 2023-03-24 02:48:12 +01:00
phpstan.neon Complete tests on Entry and improve php2ldap() method 2023-03-26 16:33:56 +02:00
phpunit.xml Initial commit 2023-03-13 02:13:21 +01:00

README.md

EesyLDAP (PHP)

PHP object oriented interface for searching and manipulating LDAP entries & filters.

Notes:

  • work in progress. Start by implementing LDAP filter abstraction class.
  • freely inspired by some other open-source projects and notably PEAR Net_LDAP2 (abandoned).

Installation

composer require brenard/eesyldap

Usage

Manipulating LDAP filter strings

To create a new filter:

// Match objects with uid equals 'admin'
// (uid=admin)
$filter = new \EesyLDAP\Filter('uid', 'equals', 'admin');

// Match objects with uid equals 'admin' and mail equals 'admin@example.com'
// (&(uid=admin)(mail=admin@example.com))
$filter = new \EesyLDAP\Filter(
  'and',
  new \EesyLDAP\Filter('uid', '=', 'admin'),
  'mail=admin@example.com'
);

// Match objects with uid different than admin
// (!(uid=admin))
$filter = new \EesyLDAP\Filter('not', 'uid=admin');

// Match objects with uid attribute present
// (uid=*)
$filter = new \EesyLDAP\Filter('uid', 'present');

By default, all pattern value are automatically escape. To control it, add a boolean as last Filter constructor argument:

// Disable automatic escaping
// (uid=admin-*)
$filter = new \EesyLDAP\Filter('uid', '=', 'admin-*', false);

You also could escape/unescape value manually:

$escaped = \EesyLDAP\Filter::escape('Administrator (admin)');
$unescaped = \EesyLDAP\Filter::unescape('Administrator \28admin\29');

You also could parse an existing filter string with the parse() method:

$filter = \EesyLDAP\Filter::parse('(&(uid=admin)(mail=admin@example.com))');

License

GNU Lesser General Public License v3 (or later).