smorken / ldapquery
LDAP Query library - helps with querying/authenticating against LDAP/AD
v2.1.0
2025-05-01 15:00 UTC
Requires
- php: ^8.1
- ext-ldap: *
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^11.0
- smorken/docker: *
README
License
This software is open-sourced software licensed under the MIT license
Requirements
- PHP 7.1+
- Composer
Pieces
LdapQuery\Contracts\Backend- handles setting up defaults for the connection and returning query results, usesLdapQuery\Contracts\ClientandLdapQuery\Contracts\ResultLdapQuery\Contracts\Builder- query builder, usesLdapQuery\Contracts\Filterto create backend specific query/filterLdapQuery\Contracts\Client- proxy to actual ldap_ functions (or whatever the lower level backend is)LdapQuery\Contracts\Model- simple object to represent ldap entry, returned fromLdapQuery\Contracts\ResultLdapQuery\Contracts\Result- usesLdapQuery\Contracts\Builderto create a form that is useful toLdapQuery\Contracts\Clientand returns the result from the client inLdapQuery\Contracts\ModelformLdapQuery\Contracts\Filter- used byLdapQuery\Contracts\Builderto set up the possible filters
LdapQuery\Opinionated\ActiveDirectory is an example of how the LdapQuery can be wired for AD. It can all be
done manually or through DI as well.
Examples
$o = new ActiveDirectory([
'host' => 'foo.bar.com',
]);
$lq = $o->getLdapQuery();
if ($lq->authenticate('user', 'password')) {
//do something when the user is successfully authenticated
}
$user = $lq->findUser('user');
$another = $lq->one('uid', 'some_user');
$many = $lq->many('l', 'some_location');