[英]Load users from Active Directory using ADLDAP
I'm using the ADLDAP library ( http://adldap.sourceforge.net ) to interact with Active Directory. 我正在使用ADLDAP库( http://adldap.sourceforge.net )与Active Directory进行交互。 I am using PHP. 我正在使用PHP。 I would like to get all users from Active Directory and save them to array. 我想从Active Directory中获取所有用户并将其保存到数组。 Is there any way to do this? 有什么办法吗?
You probably want to do something like: 您可能想要执行以下操作:
$adldap = new adLDAP();
$usernames = $adldap->user()->all();
$users = array();
foreach ($usernames as $username)
{
$userInfo = $adldap->user()->infoCollection($username);
$users[$username] = $userInfo;
}
Assuming that the directory administrators would permit an LDAP client application to retrieve all entries from a directory, extract the value of the attribute namingContexts
from the root DSE. 假设目录管理员将允许LDAP客户端应用程序从目录中检索所有条目, namingContexts
从根DSE中提取属性namingContexts
的值。 The values of this attribute (it is multi-valued) are the naming contexts or suffixes that this server supports. 该属性的值(它是多值的)是该服务器支持的命名上下文或后缀。 With this information, construct a search using: 有了这些信息,可以使用以下方法构造搜索:
(objectClass=*)
or (&)
一个匹配所有条目的过滤器,例如(objectClass=*)
或(&)
subtree
一个足以发现所有条目(可能是subtree
Construct this search for each namingContext
. 为每个namingContext
构造此搜索。 Again, assuming that the directory administrators will allow an LDAP client to search the entire directory, these searches will result in responses that contain every entry. 同样,假设目录管理员将允许LDAP客户端搜索整个目录,则这些搜索将导致包含每个条目的响应。
There are many caveats such as: 有许多警告,例如:
For more information, see: 有关更多信息,请参见:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.