从 AD 域中获取所有用户

Get all users from AD domain(从 AD 域中获取所有用户)
本文介绍了从 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 域中获取所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Finding Active Directory users from 2 OU(从 2 个 OU 中查找 Active Directory 用户)
How to set a binary attribute when using a AccountManagement Extension Class?(使用 AccountManagement 扩展类时如何设置二进制属性?)
How to check AD user credentials when the user password is expired or quot;user must change password at next logonquot;(如何在用户密码过期或“用户下次登录时必须更改密码时检查 AD 用户凭据)
Getting last Logon Time on Computers in Active Directory(在 Active Directory 中的计算机上获取上次登录时间)
customer-configurable asp.net web site security for fine-grained control of page and button access(客户可配置的 asp.net 网站安全性,用于对页面和按钮访问进行细粒度控制)
Active Directory - Roles of a user(Active Directory - 用户的角色)