0

グローバル カタログに対してクエリを実行する場合 (SDS.P を使用する予定です)、GC 全体を検索できるようにするには、開始パスをどのようにする必要がありますか?

たとえば、GC ですべてのユーザーを列挙したいとします。私の gc に 3 つのドメイン (1 つの親、2 つの子) のユーザーがいるとします。

TEST.COM
   ONE.TEST.COM
   TWO.TEST.COM

私は ONE.TEST.COM のコンピューターを使用しています。DC=XXX,DC=yyy をハードコーディングしたくありません。実行時に判断したいと思います。

ティア!-意思

4

1 に答える 1

0

グローバル カタログをクエリする関数の例を次に示します。

class Program
    {

        static void Main()
        {

            DirectoryEntry entry = new DirectoryEntry("GC://dcserver.domain.local",
                                                       "utility",
                                                       "somepassword",
                                                       AuthenticationTypes.Secure );

            const string searchString = "(&(objectCategory=person)(objectClass=user))";

            DirectorySearcher searcher = new DirectorySearcher(entry, 
                                                               searchString, 
                                                               new string[] { "sAMAccountName", "cn" } );

            SearchResultCollection resultCollection = searcher.FindAll( );

            foreach ( SearchResult result in resultCollection )
            {
                Console.WriteLine( result.Path + "\n" + 
                                   result.Properties["cn"][0] + "\n" + 
                                   result.Properties["samaccountname"][0]  );
            }

            Console.ReadLine( );

        }
   }
于 2010-03-30T13:11:22.683 に答える