C# 给定DirectoryEntry,如何获取林对象?
假设我想实现一个扩展方法,它允许我为每个DirectoryEntry对象获取林对象 我的基本代码:C# 给定DirectoryEntry,如何获取林对象?,c#,active-directory,C#,Active Directory,假设我想实现一个扩展方法,它允许我为每个DirectoryEntry对象获取林对象 我的基本代码: public static Forest GetForest(DirectoryEntry de) { string forestDnsName = //DoSomethingWith(de.Path); ? DirectoryContext context = new DirectoryContext(DirectoryContextType.Forest, forestDnsN
public static Forest GetForest(DirectoryEntry de) {
string forestDnsName = //DoSomethingWith(de.Path); ?
DirectoryContext context = new DirectoryContext(DirectoryContextType.Forest, forestDnsName);
return Forest.GetForest(context)
}
但是我不确定我怎样才能到达森林。有人知道如何获取它吗?没有示例代码,只是一些常规步骤:
林
对象Forest
对象映射构建一个域名,以减少广告流量(跳过步骤4-7)