質問

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

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

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

そして私はONE.TEST.COMのコンピューターにいます。 DC = XXX、DC = yyyをハードコードしたくありません。実行時に決定したいです。

TIA! -ウィル

役に立ちましたか?

解決

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

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( );

        }
   }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top