[英]Set IIS Website Application to use Application Pool identity for Anonymous authentication (via code)
I can see here how to enable anonymous authentication and specifically set a username and password for the credentials. 我在这里可以看到如何启用匿名身份验证,并专门为凭据设置用户名和密码。 Can anyone tell me if it's possible using .NET to set the credentials to use the Application Pool's identity instead? 任何人都可以告诉我,是否可以使用.NET来设置凭据以使用应用程序池的身份? I don't see a way of doing that programmatically. 我没有看到以编程方式执行此操作的方法。
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
Late reply (hopefully it will help someone) you can set it to use the application pool identity by simply setting the username and password blank for that part of the config eg 迟回复(希望它会帮助某人)您可以通过简单地为配置的那一部分设置用户名和密码为空来将其设置为使用应用程序池标识,例如
( excuse the C# syntax ) (原谅C#语法)
var config = _IIS.GetApplicationHostConfiguration();
var anonymousAuthenticationSection = config.GetSection( "system.webServer/security/authentication/anonymousAuthentication", name );
anonymousAuthenticationSection[ "enabled" ] = true;
//use app pool user
anonymousAuthenticationSection[ "userName" ] = "";
anonymousAuthenticationSection[ "password" ] = "";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.