获得从AD域中的所有用户 [英] Get all users from AD domain
问题描述
我有一个需要能够识别的所有用户对我的AD(Active Directory)的域。我有域名,也差不多了。这将动摇,如果我能得到它作为UserPrincipal名单什么的,但如果它只是一个字符串,然后我可以得到我需要从那里的信息的其余部分。
I have a need to be able to identify all of the users on my AD (Active Directory) domain. I have the domain name and that is about it. It would rock if i could get it as a list of UserPrincipal or something but if its just a string then i can get the rest of the info i need from there.
谢谢!
推荐答案
如果你只需要获得用户列表,你可以使用这个code -
If you just have to get the users list you can use this code -
var dirEntry = new DirectoryEntry(string.Format("LDAP://{0}/{1}", "x.y.com", "DC=x,DC=y,DC=com"));
var searcher = new DirectorySearcher(dirEntry)
{
Filter = "(&(&(objectClass=user)(objectClass=person)))"
};
var resultCollection = searcher.FindAll();
不过,如果你有更多的操作与AD你应该考虑使用LINQ to AD API 的http:// linqtoad 。codeplex.com /
这是一个LINQ的API与AD的工作。易于使用,我已经得到了一些不错的成绩吧。
It is a Linq based API to work with AD. Easy to use and I have got some good results with it.
这篇关于获得从AD域中的所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!