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? 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 )
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" ] = "";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.