我可以在这里看到如何启用匿名身份验证并专门为凭据设置用户名和密码。谁能告诉我是否可以使用 .NET 来设置凭据以改用应用程序池的身份?我没有看到以编程方式做到这一点的方法。
Public Sub CreateApplication(ByVal website As String, ByVal application As String, ByVal path As String, applicationPoolName As String)
Using manager As New ServerManager()
manager.Sites(website).Applications.Add("/" & application, path)
manager.CommitChanges()
manager.Sites(website).Applications("/" & application).ApplicationPoolName = applicationPoolName
Dim config As Configuration = manager.GetApplicationHostConfiguration
Dim anonymousAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", website & "/" & application)
anonymousAuthenticationSection("enabled") = True
manager.CommitChanges()
End Using
End Sub