Get all users from AD domain(从 AD 域中获取所有用户)
问题描述
我需要能够识别我的 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.
谢谢!
推荐答案
如果你只需要获取用户列表你可以使用这个代码 -
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/
However if you have to more operations with AD you should consider using 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 域中获取所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 AD 域中获取所有用户
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- 使用 rss + c# 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
