3

私はLDAPの初心者です。すべてのNTドメイン名を一覧表示しようとしています。NTドメイン名とは、LANネットワーク上にあるドメインの名前です。Windows XPマシンでそのマシンにログオンしようとすると、これを確認できます(つまり、ctrl + alt + delを押した後に表示されるログオンダイアログ)。通常、資格情報を入力した後、最後のドロップダウンでドメイン名を選択します。

私はこの投稿を見てみましたが、何もできませんでした。何なのかわかりませんrootDSE。投稿で与えられたコードはrootdseでそれを行います。ただし、ヒットしてクエリを実行する特定のサーバーがあり、そのサーバーはドメインコントローラーだと思います。(私はこれについて間違っているかもしれません)。私たちは次のようなものを書きます

LDAP://<domain_name>/dc=<domain>,dc=org

投稿で与えられているように、私はという名前のプロパティを探しようとしましたrootDomainNamingContext。しかし、私はそれを見つけることができませんでした。次に、以下のコードを試しました。

Sub Main()
        Dim oRoot As DirectoryEntry = Nothing
        'Dim oSearcher As DirectorySearcher
        'Dim oResults As SearchResultCollection

        Try

            oRoot = New DirectoryEntry("LDAP://<domain_name>/dc=<domain>,dc=org")
            For Each obj As String In oRoot.Properties.PropertyNames
                Console.Write(obj + ", ")
            Next
        Catch ex As Exception
            Console.Write(ex.Message)
        Finally
            oRoot.Dispose()
        End Try

        Console.Read()
    End Sub

得られた出力で具体的に何を探すべきかわかりません。私が得た出力は次のとおりです。

objectClass, description, distinguishedName, instanceType, whenCreated, whenChan
ged, subRefs, uSNCreated, dSASignature, repsTo, repsFrom, uSNChanged, name, obje
ctGUID, replUpToDateVector, creationTime, forceLogoff, lockoutDuration, lockOutO
bservationWindow, lockoutThreshold, maxPwdAge, minPwdAge, minPwdLength, modified
CountAtLastProm, nextRid, pwdProperties, pwdHistoryLength, objectSid, uASCompat,
 modifiedCount, auditingPolicy, nTMixedDomain, rIDManagerReference, fSMORoleOwne
r, systemFlags, wellKnownObjects, objectCategory, isCriticalSystemObject, gPLink
, gPOptions, masteredBy, ms-DS-MachineAccountQuota, msDS-Behavior-Version, msDS-
PerUserTrustQuota, msDS-AllUsersTrustQuota, msDS-PerUserTrustTombstonesQuota, ms
Ds-masteredBy, dc, nTSecurityDescriptor,

ここで本当にガイダンスが必要です。

アップデート

以下のコードを使用してドメインを取得しました。

    Dim dc As New DirectoryContext(DirectoryContextType.DirectoryServer, DcIpAddr)
    Dim domc As DomainController = DomainController.GetDomainController(dc)
    For Each dmn As Domain In domc.Forest.Domains
        Console.WriteLine(dmn.Name)
    Next

現在、問題は2つあります。まず、ドメイン名の不一致。私のDCのDNS名がprod.domain.comであり、予想されるドメイン名がたとえばであるとしdev, domain, etcます。代わりに私は得るdev.domain.org, domain.org, etc。Windowsログインダイアログに表示される名前の一部は、照会されると、接尾辞domain.org;が付いて表示されます。接尾辞が付いているものもあります.org

2番目の問題は、すべてのドメイン名(Windowsのログインダイアログに表示される3番目のドロップダウン)が表示されないことです。なぜそうなのかしら?

アップデート

他のドメイン(表示されていない)が別のドメインコントローラーサーバーの一部である可能性があるか、適切な資格情報を使用してDCにアクセスする必要があることを確認してください。

4

3 に答える 3

2

RootDSEは、LDAP用語集で定義されています。ルートDSEは、あなたの場合、である可能性がありますLDAP://<domain_name>/dc=<domain>,dc=org

ADサーバーでrootDomainNamingContextが定義されている場合は、他のStackOverflowの質問のコードを使用してドメインを取得できるはずです。そのプロパティがないように見えるので、適切なプロパティを見つけるためにレコードを反復処理する必要があります。物理的またはリモートデスクトップ経由でドメインコントローラーに移動し、ADディレクトリを開いてエントリとそのプロパティを探し、VBからクエリする必要があるものをよく確認することをお勧めします。アクセスできない場合は、システム管理者に問い合わせてください。

于 2010-07-30T09:42:36.167 に答える
1

私はあなたのための解決策を見つけたようです男!Interop.ActiveDs.dll(アクティブDSタイプライブラリ)のCOM参照をインポートしてみたところ、それらの名前を好みの名前に変換できます。

これが私のコードです。

using System.DirectoryServices.ActiveDirectory;
using ActiveDs;

private void ListDomains()
{
    string sUserName = "xxxx";
    string sPassword = "xxxx";

    DirectoryContext oDirectoryContext = new DirectoryContext(DirectoryContextType.Domain, sUserName, sPassword);

    Domain oCurrentDomain = Domain.GetDomain(oDirectoryContext);
    Forest oForest = oCurrentDomain.Forest;
    DomainCollection oAddDomainsInForest = oForest.Domains;

    foreach (Domain oDomain in oAddDomainsInForest)
    {
        Console.WriteLine(GetFriendlyName(oDomain.ToString()));
    }           
}

private string GetFriendlyName(string sDomainName)
{
    try
    {
        IADsADSystemInfo oSysInfo = new ADSystemInfoClass();
        IADsNameTranslate oNameTranslate = new NameTranslateClass();
        oNameTranslate.Init((int)ADS_NAME_INITTYPE_ENUM.ADS_NAME_INITTYPE_DOMAIN, sDomainName);

        string[] aSplitDN = sDomainName.Split(new Char[] { '.' });
        string sDistinguishedName = "";

        //Convert Domain Name to Distinguished Name
        foreach (string sDomainPart in aSplitDN)
        {
            sDistinguishedName = sDistinguishedName + "DC=" + sDomainPart + ",";
        }

        oNameTranslate.Set((int)ADS_NAME_TYPE_ENUM.ADS_NAME_TYPE_UNKNOWN, sDistinguishedName.Remove(sDistinguishedName.Length - 1));//Remove the last comma
        string sFriendlyName = oNameTranslate.Get((int)ADS_NAME_TYPE_ENUM.ADS_NAME_TYPE_NT4);
        return sFriendlyName(@"\", "");
    }
    catch
    {
        return "Access Denied";
    }
}

詳細については、こちらの記事をご覧 くださいhttp://anyrest.wordpress.com/2010/08/06/how-to-get-domain-name-pre-windows-2000-from-fqdn-fully-qualified-domain -name-using-c /

于 2010-08-06T03:38:05.753 に答える
0

LINQを少し使用した@Raymundのコード:

    private static string GetFriendlyName(string names)
    {
        try
        {
            string[] arr = names.Split('.');
            //Convert Domain Name to Distinguished Name
            string distinguishedName = String.Join(",", arr.Select(d => "DC=" + d));

            IADsADSystemInfo info = new ADSystemInfo();
            IADsNameTranslate nameTranslate = new NameTranslate();
            nameTranslate.Init((int)ADS_NAME_INITTYPE_ENUM.ADS_NAME_INITTYPE_DOMAIN, names);
            nameTranslate.Set((int)ADS_NAME_TYPE_ENUM.ADS_NAME_TYPE_UNKNOWN, distinguishedName);

            string friendlyName = nameTranslate.Get((int)ADS_NAME_TYPE_ENUM.ADS_NAME_TYPE_DOMAIN_SIMPLE);
            return friendlyName.Replace("\\", String.Empty);
        }
        catch
        {
            return "Access Denied";
        }
    }
于 2010-08-09T13:36:30.930 に答える