DirectorySearcher FindOne()を実行してからLDAPサーバーに送信される最初のネットワークパケットが送信されるまでに2〜5秒の初期遅延があります。最初の実行後、後続の実行は約45秒間即座に完了します。高速実行の期間が過ぎると、次の実行が遅れ、その後のすべての実行が即座に完了します。何らかのキャッシュが行われているようですが、それを確認したり、何が初期の遅延を引き起こしているかを説明するリソースは見つかりませんでした。DirectorySearcher FindOne()初期実行時の遅延
私たちはクライアントのWindows 2008サーバーでこれを認識し、独自のWindows 2008およびWindows 7のボックスに再現しました。
私の単純な.NET 4.0 C#アプリの外観は次のとおりです。この遅延は、「Started」と「Finished」の間に発生します。
FindOne()の最初の実行でこの遅延が発生する理由は何ですか?どんな助けでも大歓迎です!
using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;
namespace LdapTest
{
class Program
{
static void Main(string[] args)
{
string[] fetchAttributes;
fetchAttributes = new string[] { "{string[0]}" };
using (DirectoryEntry searchRoot = new DirectoryEntry("LDAP://localserver/ou=lab,dc=ourdomain,dc=com", "cn=binduser,ou=Services,dc=ourdomain,dc=com", "Password", AuthenticationTypes.ReadonlyServer))
{
using (DirectorySearcher searcher = new DirectorySearcher(searchRoot, "(sAMAccountName=UserName)", fetchAttributes, SearchScope.Subtree))
{
Console.WriteLine("Started");
SearchResult result = searcher.FindOne();
Console.WriteLine("Finished");
}
}
}
}
http://stackoverflow.com/questions/1846436/system-directoryservices-is-slow – orange
神の母!これは私が何週間も解決策を探していた問題でした!!ありがとうございました –