【发布时间】:2012-11-15 19:02:48
【问题描述】:
$ldaphost = "my_host_name";
$ds=ldap_connect($ldaphost) or die("Could not connect to $ldaphost");
ldap_set_option ($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ds)
{
$basedn = 'my_dc_string';
$samaccountname = 'my_user_name';
$filters = "(samaccountname={$samaccountname})";
$result = ldap_search($ds, $basedn, $filters);
}
如何使用 PHP 从 LDAP 获取所有用户的列表?上面的代码在 ldap_search 函数上失败了,给出了这个警告
“警告:ldap_search():搜索:操作错误”
我的用户名、ldaphost 等都是正确的。不过我不确定过滤器。
【问题讨论】: