0

Active Directory にカスタム属性「costCenter」を照会したいので、カスタム UserPrincipalEx クラスを使用しています。したがって、カスタム UserPrincipalEx-Class には DirectoryProperty("costCenter") が追加されています。基本的な実行時間の長い (3 分) バージョンは次のようになります。

// create domain context
PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomainController");

// define the query-by-example principal
UserPrincipal qbeUser = new UserPrincipal(context);

// create the principal searcher    
PrincipalSearcher searcher = new PrincipalSearcher(qbeUser);

// find all matches
foreach (var hit in searcher.FindAll())
{
    //do incredible stuff here
}

ここで、カスタム属性「costCenter」用に拡張されたカスタマイズされたクラス「UserPrincipalEx」を使用します。

UserPrincipalEx qbeUser = new UserPrincipalEx(context);
qbeUser.costCenter = "123";

クエリをほぼ同じ速さで実行します。しかし、私が本当に必要としているのは、costCenterを持っているだけのすべてのユーザーに対してクエリを実行することです (すべてのユーザーがそうしているわけではありません)。

私の質問は次のとおりです: 拡張された「Query-By-Example」プリンシパルを使用して、カスタム属性だけを持つプリンシパルを検索する方法は?

4

1 に答える 1

0

を使用するように戻しました

Parallel.ForEach 

全体を高速化するためです。ForEach-Loop は、関心のあるカスタム属性のすべての値を使用して IEnumerable で実行され、UserPrincipalEx 属性にこれらの値の 1 つを追加し、結果をリストに追加します。

本当に私が探していたものではありませんが、効果的です: 3 分から ~15 秒まで.

于 2013-09-26T07:30:29.013 に答える