вы можете использовать приведенный ниже код, чтобы включить windows аутентификацию, используя c точный код:
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample {
private static void Main() {
using(ServerManager serverManager = new ServerManager()) {
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "htmlsite");
windowsAuthenticationSection["enabled"] = true;
serverManager.CommitChanges();
}
}
}
отключить анонимную аутентификацию:
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample {
private static void Main() {
using(ServerManager serverManager = new ServerManager()) {
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "htmlsite");
anonymousAuthenticationSection["enabled"] = false;
serverManager.CommitChanges();
}
}
}