确定用户的域在Active Directory搜索结果 [英] Determine the domain of a user in an Active Directory search result

查看:90
本文介绍了确定用户的域在Active Directory搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/941002/how-can-i-get-domain-user-from-an-ad-directoryentry">How我可以得到域\用户从AD的DirectoryEntry?

下面是我现在所拥有的:

Here is what I have right now:

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();

注意组名(其中传递到方法重新presenting该组的名称来搜索参数)可以是一个通用组,这意味着它可能包含来自其他域的帐户。

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搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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