【发布时间】:2014-04-29 19:52:11
【问题描述】:
我正在尝试查询给定用户组成员的 Active Directory。 当我搜索特定用户的 OU 时,搜索正常。 当我尝试搜索整个目录时,结果为空。 由于我有很多用户 OU,特定用户 OU 可能会有所不同。
系统为CentOS 6.4,PHP+Apache。
代码如下:
$ldap_dn = "dc=ccc,dc=bbb,dc=aaa,dc=com";
// Active Directory user for querying
$query_user = "ldap_bind@ccc.bbb.aaa.com";
$password = "xxxx";
// Connect to AD
$ldap = ldap_connect($ldap_host, 389) or die("Could not connect to LDAP");
ldap_bind($ldap,$query_user,$password) or die("Could not bind to LDAP");
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
// Search AD
$results = ldap_search($ldap,$ldap_dn,"(sAMAccountName=$user)",array("memberof","primarygroupid"));
$entries = ldap_get_entries($ldap, $results);
if($entries['count'] == 0) {
echo "No results\n";
return false;
}
有人见过类似的结果吗?我是否缺少支持此类搜索的某些内容或任何配置?
【问题讨论】:
标签: php linux ldap ldap-query