IIS7: How to define that windows authentication is turned on?
I know that two-stage authentication is not supported with IIS7 Integrated mode but I need to define whether windows authentication is turned on to enable spacial windows authenticated features.
Can I define the IIS version from the ASP .NET code ? Can I define that windows authentication is turned on IIS 7 from the ASP .NET code ?
Just want to share the found solution. To get whether Windows Authentication is is enabled for current web application do following:
Microsoft.Web.Administration.ConfigurationSection windowsAuthenticationSection = Microsoft.Web.Administration.WebConfigurationManager.GetSection("system.webServer/security/authentication/windowsAuthentication");
return windowsAuthenticationSection["enabled"];
Please note that the code above get effective configuration:
If there is not configuration specified for the web application the setting form the parent web site will be returned. You can find more info about the configuration inheritance here: Working With Configuration Files in IIS 7
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.