获取 Zend LDAP 身份验证的显示名称 [英] Get display name for Zend LDAP Authentication
问题描述
我已经成功实现了 Zend Framework LDAP 适配器Zend_Auth
模块,并且可以登录我的 Active Directory 控制器.但是, getIdentity()
方法只返回用户名(适用于数据库外键使用),而我想(另外)获取用户对象的cn"或displayname"属性用于在网页本身上显示.
I have successfully implemented the Zend Framework LDAP adapter for the Zend_Auth
module, and can login against my Active Directory controller. However, the getIdentity()
method returns just the username (good for database foreign key usage), while I'd like to (additionally) get the "cn" or "displayname" property of the user object for display on the webpage itself.
我在 Zend_Auth_Adapter_Ldap
对象上看到了一个 getLdap()
方法,但是在针对 Zend_Auth 进行身份验证的结果对象上.有没有办法获取用户验证的 LDAP 连接并获取他们的数据?
I see a getLdap()
method on the Zend_Auth_Adapter_Ldap
object, but on the result object from authenticating against Zend_Auth. Is there a way to get at the LDAP connection that the user authenticated with and get their data?
推荐答案
Zend_Auth_Adapter_Ldap 定义了一个方法 getAccountObject
可以做你想做的事.
Zend_Auth_Adapter_Ldap defines a method getAccountObject
that will do what you want.
例如;
$adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$user_data = $adapter->getAccountObject();
}
该方法还允许您有选择地设置要检索的属性.
The method allows you to optionally set which attributes you want to retrieve, too.
这篇关于获取 Zend LDAP 身份验证的显示名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!