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

不问归期 提交于 2019-12-11 02:20:35

问题


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?


回答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



来源:https://stackoverflow.com/questions/5563929/iis7-how-to-define-that-windows-authentication-is-turned-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!