在 Active Directory 搜索结果中确定用户的域

Determine the domain of a user in an Active Directory search result(在 Active Directory 搜索结果中确定用户的域)
本文介绍了在 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 搜索结果中确定用户的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

What#39;s the difference between retrieving WindowsPrincipal from WindowsIdentity and Thread.CurrentPrincipal?(从 WindowsIdentity 和 Thread.CurrentPrincipal 检索 WindowsPrincipal 之间有什么区别?)
How do I find a user#39;s Active Directory display name in a C# web application?(如何在 C# Web 应用程序中查找用户的 Active Directory 显示名称?)
How can I authenticate against Active Directory in Nancy?(如何在 Nancy 中对 Active Directory 进行身份验证?)
How to get a username in Active Directory from a display name in C#?(如何从 C# 中的显示名称获取 Active Directory 中的用户名?)
Working with DirectoryServices in ASP.NET Core(在 ASP.NET Core 中使用 DirectoryServices)
Create Active Directory user in .NET (C#)(在 .NET (C#) 中创建 Active Directory 用户)