我正在使用 WMI 创建不同类型的 DNS 记录,但 SRV 记录有问题。每当我传递 DomainName 参数时,我都会收到“未找到”错误。域名在我看来不错。
有没有人成功地做到这一点?
这是我的代码:
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);
}