Domanda

Sto usando WMI per creare diversi tipi di record DNS, ma sto avendo un problema con i record SRV. Continuo a ricevere un errore "Non trovato" ogni volta che passo il parametro DomainName. Il nome di dominio sembra buono per me.

chiunque

ha fatto mai successo questo?

Ecco il mio codice:

internal static void CreateSrvRecordInDns(string Zone, string OwnerName, string DomainName, UInt16 Weight, UInt16 Priority, UInt16 Port)
    {
        DnsProvider dns = new DnsProvider();
        ManagementClass mClass = new ManagementClass(dns.Session, new ManagementPath("MicrosoftDNS_SrvType"), null);
        ManagementBaseObject inParams = mClass.GetMethodParameters("CreateInstanceFromPropertyData");
        inParams["DnsServerName"] = dns.Server;
        inParams["ContainerName"] = Zone;
        inParams["OwnerName"] = OwnerName;
        inParams["DomainName"] = DomainName; //Error occurs here
        inParams["Port"] = Port;
        inParams["Priority"] = Priority;
        inParams["Weight"] = Weight;
        mClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null);
        dns.Dispose(ref inParams);
        dns.Dispose(ref mClass);
    }
È stato utile?

Soluzione

Basta sostituire la linea problematico con:

inParams["SRVDomainName"] = DomainName;

Non so il motivo, ma quando ottiene l'elenco annunci per:

PropertyData[] pd = new PropertyData[inParams.Properties.Count];
inParams.Properties.CopyTo(pd,0);

Questo è stato il nome di questo campo (bug di Microsoft?)

HTH.

P.S. Per vedere il formato giusto per ogni campo, utilizzare wbemtest strumento (wbemtest dal prompt dei comandi), collegarsi al root \ MicrosoftDNS namespace ed eseguire la seguente query:

Select * from MicrosoftDNS_SRVType

Si dovrebbe usare lo stesso formato le istanze elencate nella risposta).

Altri suggerimenti

Vorrei aggiungere un po 'di dettagli qui per coloro che sono ancora in grado di farlo ...

Se il nome di dominio google.com e se il Record è: _finger._tcp.google.com che punta verso host di destinazione : hello.google.com , quindi le variabili ed i loro valori saranno come sotto:

    inParams["DnsServerName"] = dns.Server;
    inParams["ContainerName"] = Zone; //google.com
    inParams["OwnerName"] = OwnerName; //_finger._tcp.google.com
    // Can't set domain name like this, leave this field
    //inParams["DomainName"] = DomainName; //_tcp.google.com
    //Set Target SRV Host here which is providing the service,,,
    inParams["SRVDomainName"] = DomainName; //target Host : hello.google.com

    inParams["Port"] = Port;
    inParams["Priority"] = Priority;
    inParams["Weight"] = Weight;

Ho testato in creando un'applicazione di esempio e creando zone google.com e fissando un record SRV ei suoi valori come menzionato sopra. Spero che aiuta a coloro ai quali le altre risposte possono suonare è po 'meno evidente.

Il record SRV corretta sarebbe _finger._tcp.example.com.

Non so WMI, ma il sistema può essere che richiede di creare il nodo "vuoto non terminale" per _tcp.example.com prima.

Modifica

Credo che vedo il problema ora - OwnerName dovrebbe essere quello di contenere _finger._tcp.example.com. Il DomainName si suppone che contengono la obiettivo del record SRV.

http://msdn.microsoft .com / it-it / library / ms682736% 28v = VS.85% 29.aspx

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top