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:
Even I set Windows Authentication like:
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
</security>
Also I set permission here on WMI
Even I checked my RPC, it's works fine
Also I checked Register this connection's addresses in DNS
Here on Microsoft Forums, you could to see same question without result.