kaystrobach / ldap
该包最新版本(dev-master)没有提供许可证信息。
用于处理ldap操作(无认证,但可读写)的包
dev-master
2015-11-19 16:54 UTC
Requires
- typo3/flow: *
This package is auto-updated.
Last update: 2024-09-06 08:53:59 UTC
README
设置
设置的部分继承自TYPO3.LDAP,所有其他内容都需要通过Settings.yaml进行配置。
KayStrobach: Ldap: host: port: admin: dn: password:
使用方法
如果你使用TYPO3.Flow,你可以使用依赖注入,因为工厂负责初始化连接。
/** * @var \KayStrobach\Ldap\Service\LdapInterface * @Flow\Inject */ protected $ldapConnection;
要更改LDAP密码,这在纯PHP中可能非常困难,你可以使用以下代码示例
$account = $this->ldapConnection->search('dc=example,dc=com', '(uid=' . $this->username . ')'); if($account->count() === 1) { $account->next(); $this->ldapConnection->bindAsAdmin(); $account->current()->modify( array('userpassword' => KayStrobach\Ldap\Service\Ldap\PasswordUtility::getPasswordArray($newPassword) ) ); $this->ldapConnection->unbind(); $this->userSession->setPassword($newPassword); } // else ... show some error messages
密码工具将为你生成所有典型需要的密码散列(SHA、SSHA、MD4 / NTLM、MD5、SHA256、SHA512)
在LDAP中搜索
只需使用 $this->ldapConnection->search 方法签名与php直接的方法类似,不同之处在于,所有操作都是面向对象的,因此你可以省略连接和结果资源。