klashar
klashar

Reputation: 2563

IIS7: How to define that windows authentication is turned on?

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?

Upvotes: 2

Views: 1197

Answers (1)

klashar
klashar

Reputation: 2563

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

Upvotes: 1

Related Questions