smorken / ldapquery
LDAP Query library - helps with querying/authenticating against LDAP/AD
v2.0.2
2024-02-27 17:42 UTC
Requires
- php: ^8.1
- ext-ldap: *
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.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\Client
andLdapQuery\Contracts\Result
LdapQuery\Contracts\Builder
- query builder, usesLdapQuery\Contracts\Filter
to 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\Result
LdapQuery\Contracts\Result
- usesLdapQuery\Contracts\Builder
to create a form that is useful toLdapQuery\Contracts\Client
and returns the result from the client inLdapQuery\Contracts\Model
formLdapQuery\Contracts\Filter
- used byLdapQuery\Contracts\Builder
to 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');