0

利用可能なドメインのリストを照会するために LDAP を使用しています。1 つの NIC カードが利用可能で、ドメインのリストを正常にクエリしているマシンでこれを実行すると、私のロジックは正常に動作します。ドメイン B、例外の理由は単純です。つまり、DirectoryEntry() バインディングが失敗しています。

このためにのみ LDAP プロバイダーを使用する必要があります。

以下はコード スニペットです。

using (DirectoryEntry RootDSE = new DirectoryEntry("LDAP://rootDSE"))
    {
        // Retrieve the Configuration Naming Context from RootDSE
        string configNC = RootDSE.Properties["configurationNamingContext"].Value.ToString();

        // Connect to the Configuration Naming Context
        using (DirectoryEntry configSearchRoot = new DirectoryEntry("LDAP://" + configNC))
        {
            // Search for all partitions where the NetBIOSName is set.
            using (DirectorySearcher configSearch = new DirectorySearcher(configSearchRoot))
            {
                configSearch.Filter = ("(NETBIOSName=*)");

                // Configure search to return dnsroot and ncname attributes
                configSearch.PropertiesToLoad.Add("dnsroot");
                configSearch.PropertiesToLoad.Add("ncname");
                using (SearchResultCollection forestPartitionList = configSearch.FindAll())
                {
4

1 に答える 1

0

のように、サーバーまたはドメインなしで LDAP バインディング文字列を使用する場合LDAP://rootDSE、既定のドメインは、コンピューターが参加しているドメインになります。コンピューターがドメインに参加していない場合、バインドは失敗します (ユーザー名とパスワードも指定する必要があります)。アプリを実行しているユーザー、または Web サイト/サービスのスレッド、またはバインディング中に指定された場合はユーザーは、ターゲット ドメインで読み取ることができる必要があります。そうでない場合、バインディングは失敗します。

これで問題が解決しない場合は、2 つのドメインに関する詳細情報を提供する必要があります。たとえば、彼らは同じ森にいますか?

于 2012-11-26T16:00:52.670 に答える