在C#中枚举林和构建域树的快速方法? [英] Fast way to enumerate forest and build domain trees in C#?

查看:85
本文介绍了在C#中枚举林和构建域树的快速方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 域中构建一个树森林 的。到目前为止,我使用了以下代码:

I need to build a trees of domains in a forest. So far I have used the following code:

using System.DirectoryServices.ActiveDirectory;

...

List<Domain> domains = new List<Domain>(); // flat list of domains
foreach (Domain dom in Forest.GetCurrentForest().Domains)
{
    try
    {
        domains.Add(dom);
        var de = dom.GetDirectoryEntry();
        // Here I have de.Guid and de.Parent.Guid, so using them I can build a tree
    }
    catch () {} // for simplicity left it blank.
}



代码效果很好。但是当某些域变得不可用时,响应( Domain.GetDirectoryEntry() )可能需要一段时间(15-20秒)。但是使用Active Directory域和信任,可以使用问题域快速检索所有林树,所以我想在某处有一些域缓存。



问:



如果此缓存位于全局目录中,我想知道 - 是否可以在没有GC的情况下使用AD结构?



我如何执行更快的森林域枚举,并构建树结构?


The code works well. But when some of the domain becomes unavailable, the response (Domain.GetDirectoryEntry()) can take a while (15-20 sec.) before exception throwing. But using Active Directory Domains and Trusts, it is possible to retrieve all forest trees pretty fast with problem domains, so I suppose that there is some cache of domains somewhere.

Q:

If this cache is in the Global Catalog, I wonder - is it possible to have AD structure without GC?

And how can I perform a faster enumeration of forest domains, and build a tree structure?

推荐答案

这篇关于在C#中枚举林和构建域树的快速方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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