IIS7:如何定义Windows身份验证是否已打开?

时间:2011-04-06 09:07:26

标签: asp.net iis-7 windows-authentication

IIS7:如何定义Windows身份验证已启用?

我知道two-stage authentication is not supported with IIS7 Integrated mode但是我需要定义是否启用了Windows身份验证以启用空间窗口身份验证功能。

我可以从ASP .NET代码定义IIS版本吗? 我可以定义从ASP .NET代码

启用IIS 7 的Windows身份验证吗?

1 个答案:

答案 0 :(得分:1)

只想分享找到的解决方案。要获取是否为当前 Web应用程序启用了Windows身份验证,请执行以下操作:

 Microsoft.Web.Administration.ConfigurationSection windowsAuthenticationSection = Microsoft.Web.Administration.WebConfigurationManager.GetSection("system.webServer/security/authentication/windowsAuthentication");
 return windowsAuthenticationSection["enabled"];

请注意,上面的代码有效配置:

如果没有为Web应用程序指定配置,则将返回父网站的设置表单。您可以在此处找到有关配置继承的更多信息:Working With Configuration Files in IIS 7