在 Active Directory 搜索结果中确定用户的域
- 作者: 妳的訫只屬於我
- 来源: 51数据库
- 2022-10-28
问题描述
可能的重复:
如何从 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.
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
