从 Active Directory 组中获取所有用户
我正在尝试从 Active Directory 读取一些用户帐户。我可以很好地连接和验证。但无论我对这个东西进行什么搜索,我都会收到“操作错误”。有什么想法吗?
我正在使用 PHP 5.3.8 CLI 的 Windows 2k8 服务器计算机上运行该脚本。 (我不是 AD 专家:)dsa.mcs 告诉我 AD 主机的 DC 类型 = GC 和 DC 版本 W2K8。
// $ds = ldap_connect($host, $port);
// $db = ldab_bind($ds, $user, $password);
// $ds and $db are verified, connected and authenticated!
$dn = "CN=All users in Some City,OU=Some Group,OU=Some City,OU=Company Name,DC=bar,DC=foo,DC=com";
//$filter = 'sAMAccountName=' . $username;
//$filter = "(&(&(&(objectCategory=person)(objectClass=user))))";
$filter = "(objectClass=user)";
$attributes = array('sn', 'givenName', 'memberOf');
$res = ldap_search($ds, $dn, $filter, $attributes);
// results in
// ldap_errno(): 1
// ldap_error(): Operations error
在“终端”(dos box thingie)中运行以下命令可以很好地返回用户列表。
dsget group "CN=All users in Some City,OU=Some Group,OU=Some City,OU=Company Name,DC=bar,DC=foo,DC=com" -members
WTF 我在这里失踪了吗?
I'm trying to read some user accounts from Active Directory. I can connect and authenticate just fine. But whatever search I throw at the thing, I get an »Operations error«. Any ideas what this could be?
I'm running the script on a Windows 2k8 server machine with PHP 5.3.8 CLI. (I'm no AD expert:) dsa.mcs tells me the AD host has DC Type = GC and DC Version W2K8.
// $ds = ldap_connect($host, $port);
// $db = ldab_bind($ds, $user, $password);
// $ds and $db are verified, connected and authenticated!
$dn = "CN=All users in Some City,OU=Some Group,OU=Some City,OU=Company Name,DC=bar,DC=foo,DC=com";
//$filter = 'sAMAccountName=' . $username;
//$filter = "(&(&(&(objectCategory=person)(objectClass=user))))";
$filter = "(objectClass=user)";
$attributes = array('sn', 'givenName', 'memberOf');
$res = ldap_search($ds, $dn, $filter, $attributes);
// results in
// ldap_errno(): 1
// ldap_error(): Operations error
running the follwing in the "terminal" (that dos box thingie) returns the list of users just fine.
dsget group "CN=All users in Some City,OU=Some Group,OU=Some City,OU=Company Name,DC=bar,DC=foo,DC=com" -members
WTF am I missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以在 SBS 2003 盒子上重复您的问题。
尝试在对
ldap_connect()
和ldap_bind()
的调用之间添加以下两行:这可以解决我的问题。
I can repeat your problem on an SBS 2003 box.
Try adding the following two lines between your calls to
ldap_connect()
andldap_bind()
:This resolves the problem for me.