导言
什么是Adldap 2?
Adldap 2是一个PHP LDAP包,允许您:
- 轻松地同时管理多个ldap连接
- 执行认证
- 使用一个流畅且易于使用的查询生成器搜索您的ldap目录。
- 轻松创建/更新/删除LDAP实体
- 还有更多
Adldap的历史2
Adldap 2最初是作为原始ldap库的分支创建的。adLDAP因为虫子,它被完全抛弃了。
Adldap 2与原始存储库完全没有任何相似之处,构建它是为了尽可能方便地访问,有很好的文档和易于理解的语法。
这个API的大部分构建都考虑到了Ruby的ActiveRecord和Laravel的雄辩,并回答了这个问题:
为什么我们不能像使用数据库一样使用LDAP呢?
为什么要使用Adldap 2?
在PHP中使用LDAP可能会造成混乱和混乱,特别是在使用多个连接、创建和管理实体、执行移动、重置密码和对用户帐户执行ACL修改时。
LDAP的包装类通常都是在PHP应用程序中创建的。
Adlda 2允许您轻松地管理上述问题,而无需为每个项目重新设计轮子。
实现
快速启动
通过composer
:
composer require adldap2/adldap2
使用Adldap 2:
// Construct new Adldap instance.
$ad = new \Adldap\Adldap();
// Create a configuration array.
$config = [
// An array of your LDAP hosts. You can use either
// the host name or the IP address of your host.
'hosts' => ['ACME-DC01.corp.acme.org', '192.168.1.1'],
// The base distinguished name of your domain to perform searches upon.
'base_dn' => 'dc=corp,dc=acme,dc=org',
// The account to use for querying / modifying LDAP records. This
// does not need to be an admin account. This can also
// be a full distinguished name of the user account.
'username' => 'admin@corp.acme.org',
'password' => 'password',
];
// Add a connection provider to Adldap.
$ad->addProvider($config);
try {
// If a successful connection is made to your server, the provider will be returned.
$provider = $ad->connect();
// Performing a query.
$results = $provider->search()->where('cn', '=', 'John Doe')->get();
// Finding a record.
$user = $provider->search()->find('jdoe');
// Creating a new LDAP entry. You can pass in attributes into the make methods.
$user = $provider->make()->user([
'cn' => 'John Doe',
'title' => 'Accountant',
'description' => 'User Account',
]);
// Setting a model's attribute.
$user->cn = 'John Doe';
// Saving the changes to your LDAP server.
if ($user->save()) {
// User was saved!
}
} catch (\Adldap\Auth\BindException $e) {
// There was an issue binding / connecting to the server.
}
版本化
Adldap 2在语义版本化尽可能多的指导方针。
各版本将按下列格式编号:
<major>.<minor>.<patch>
并以下列准则建造:
- 破坏向后兼容性,主要和重置次要和补丁。
- 新的添加,而不打破向后兼容性,碰撞次要和重置修补程序。
- 错误修复和MISC更改会使修补程序颠簸。
次要版本不是单独维护的,因此鼓励您升级到下一个次要版本。
主要版本通过不同的分支单独维护。