【发布时间】:2013-11-07 14:11:15
【问题描述】:
我正在尝试检索 ldap 上存在的所有用户的列表,以便在 jquery 中创建一个自动完成框。但是,我无法得到它。我可以连接并绑定到 ldap 服务器,然后我尝试使用ldap_list()。我在过滤器中留一个空白,不过滤任何东西并获取整个列表。然而ldap_list() 设置了一个警告(Search: Can't contact LDAP server)并返回FALSE,这使得一切都出错了,因为它是一个布尔值并且不是预期的(Warning: ldap_get_entries() expects parameter 2 to be resource, boolean given)。这是我的代码示例:
$identifier = ldap_connect(sfConfig::get('sf_ldap_host'));
if (!ldap_bind($identifier,
sfConfig::get('sf_ldap_generic_user').sfConfig::get('sf_ldap_usr_domain'),
sfConfig::get('sf_ldap_generic_password')))
{
throw new sfException('could not bind to the Active Directory');
}
$list = ldap_list($identifier, sfConfig::get('sf_ldap_dn'), '', array('mail'));
$list_user = ldap_get_entries($identifier, $list);
【问题讨论】:
-
感谢编辑,不知道如何缩进
标签: php ldap symfony-1.4 ldap-client