从 AD 域中获取所有用户 [英] Get all users from AD domain

查看:68
本文介绍了从 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 域中获取所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆