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

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

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