我想访问 System.Management 并添加 dns 记录。当前代码在 Windows 应用程序上运行良好,但我也在寻找在 Web 应用程序上运行代码的权限。
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);
我需要网络应用程序的许可,这是我知道的:
Windows 身份验证:
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
</security>
整个权限:
iis 功能委托:
更新:您可以在此链接上看到错误