smorken/ldapquery

LDAP 查询库 - 帮助查询/验证 LDAP/AD

v2.0.2 2024-02-27 17:42 UTC

README

许可证

本软件是开源软件,采用 MIT 许可证

要求

组件

  • LdapQuery\Contracts\Backend - 处理设置连接默认值和返回查询结果,使用 LdapQuery\Contracts\ClientLdapQuery\Contracts\Result
  • LdapQuery\Contracts\Builder - 查询构建器,使用 LdapQuery\Contracts\Filter 创建后端特定的查询/过滤器
  • LdapQuery\Contracts\Client - 实际 ldap_ 函数(或任何底层后端)的代理
  • LdapQuery\Contracts\Model - 简单对象,用于表示 ldap 条目,由 LdapQuery\Contracts\Result 返回
  • LdapQuery\Contracts\Result - 使用 LdapQuery\Contracts\Builder 创建对 LdapQuery\Contracts\Client 有用的形式,并将客户端返回的结果以 LdapQuery\Contracts\Model 形式返回
  • LdapQuery\Contracts\Filter - 由 LdapQuery\Contracts\Builder 使用来设置可能的过滤器

LdapQuery\Opinionated\ActiveDirectory 是 LdapQuery 如何用于 AD 的一个示例。所有这些都可以手动完成,也可以通过 DI 完成。

示例

$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');