Determine the domain of a user in an Active Directory search result(在 Active Directory 搜索结果中确定用户的域)
问题描述
可能的重复:
如何从 AD DirectoryEntry 获取 DOMAINUSER?
这是我现在所拥有的:
DirectoryEntry de = new DirectoryEntry("LDAP://" + domain);
SearchResult result;
DirectorySearcher search = new DirectorySearcher(de);
search.Filter = String.Format("(cn={0})", groupName);
search.PropertiesToLoad.Add("member");
result = search.FindOne();
请注意,groupName(传递给方法的参数表示要搜索的组的名称)可以是通用组,这意味着它可能包含来自其他域的帐户.
Note that groupName (which a parameter passed into the method representing the name of the group to search in) can be a universal group, which means it might contain accounts from other domains.
我应该使用 searchresultcollection 中的哪个属性来查找帐户源自的域,或者更好的是,是否有一个网页包含此特定集合可用的所有属性的列表?>
Which property in the searchresultcollection should I use to find the domain the account originates from, or even better is there a webpage that has a list of all the properties available to this particular collection?
推荐答案
任何 AD 对象的 distinguishedName 属性应始终包含该对象的完整 LDAP 兼容路径,例如
The distinguishedName property of any AD object should always contain the full LDAP compatible path to that object, e.g.
CN=John Doe,OU=Marketing,OU=IntlSales,DC=YourMegaCorp,DC=com
根据该 DN,您可以找出该用户来自的域 (DC=YourMegaCorp,DC=com).不过,我认为没有任何其他(默认)AD 属性可以只为您提供域 - 您需要破解并解析"该 DN 以获取您需要的信息.
Based on that DN you can figure out the domain (DC=YourMegaCorp,DC=com) that this user came from. I don't think there's any other (default) AD attribute that would give you just the domain, though - you'll need to "crack and parse" that DN to get the info you need.
这篇关于在 Active Directory 搜索结果中确定用户的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Active Directory 搜索结果中确定用户的域
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
