1

I want to access to System.Management and add dns record. Current code works fine on windows application, but I looking for a permission to run the code on web application too.

string site = "domain.com";
ConnectionOptions co = new ConnectionOptions();
ManagementScope _scope  = new ManagementScope(String.Format(@"\\{0}\Root\MicrosoftDNS", "host name"), 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);

I need the permission for web application, and here is what I did up to know:

Windows Authentication:

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

enter image description here

Permission entire:

enter image description here

iis feature delegation:

enter image description here

Update: you could to see the bug here on this link

  • please make sure your WMI service is running (possibly it stopped/crashed/etc) when the "System.Management.ManagementException: Generic failure" happens. – Jalpa Panchal Jan 22 '20 at 02:08
  • @JalpaPanchal thanks, current code works fine with windows application, I lost about 3 days for this bug. it's awful :( – مهدی نبوی Jan 22 '20 at 03:41
  • Could you please share under which application pool identity your application is running? – Jalpa Panchal Jan 22 '20 at 05:47
  • @JalpaPanchal here I find what other people faced, same error without response :( https://social.msdn.microsoft.com/Forums/en-US/3322cc53-259d-4c0d-9fbf-41dc51304988/trying-to-add-cname-to-dns-with-systemmanagement-results-in-generic-failure?forum=netfxnetcom – مهدی نبوی Jan 23 '20 at 11:22

0 Answers0