2

I provide windows application with this code and able to add DNS zone on windows server 2019.

string site = "domain.com";
ConnectionOptions co = new ConnectionOptions();
ManagementScope _scope =new ManagementScope(String.Format(@"\\{0}\root\MicrosoftDNS", System.Net.Dns.GetHostName()), co);
_scope.Connect();
ManagementObject mc = new ManagementClass(_scope, new ManagementPath("MicrosoftDNS_Zone"), null);
mc.Get();
ManagementBaseObject parameters = mc.GetMethodParameters("CreateZone");
parameters["ZoneName"] = site;
parameters["ZoneType"] = (UInt32) DNSServer.NewZoneType.Primary;
parameters["DsIntegrated"] = 0; //false
ManagementBaseObject createdEntry = mc.InvokeMethod("CreateZone", parameters, null);

When I try to use current code on web application(asp.net), it's not working:

System.Management.ManagementException: Generic failure

When I change @"\\{0}\Root\MicrosoftDNS" to @"\\{0}\root\cimv2" this error appears:

System.Management.ManagementException: Not found

On my physical path, any permission provided:

enter image description here

Even I set Windows Authentication like:

<security>
      <authentication>
        <anonymousAuthentication enabled="false"/>
        <windowsAuthentication enabled="true"/>
      </authentication>
    </security>

enter image description here

Also I set permission here on WMI enter image description here

Even I checked my RPC, it's works fine

enter image description here

Also I checked Register this connection's addresses in DNS

enter image description here

Here on Microsoft Forums, you could to see same question without result.

  • the second answer in the link shows that it was a permission error on the DNS server. – LinkedListT Jan 23 '20 at 14:26
  • @LinkedListT it's: **Just to finish this one up. It turned out to be a permission problem on the dns-server.** And what I asked is: **Need DNS permission in windows server**, so I looking for the permission. Help me to have permission please. – مهدی نبوی Jan 23 '20 at 15:26

0 Answers0