2

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?

Community
  • 1
  • 1
klashar
  • 2,519
  • 2
  • 28
  • 38

1 Answers1

1

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

klashar
  • 2,519
  • 2
  • 28
  • 38