【问题标题】:IIS7: How to define that windows authentication is turned on?IIS7:如何定义打开 Windows 身份验证?
【发布时间】:2011-07-30 15:40:46
【问题描述】:

IIS7:如何定义开启windows认证?

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

我可以从 ASP .NET 代码定义 IIS 版本吗? 我是否可以从 ASP .NET 代码定义启用 Windows 身份验证的 IIS 7?

【问题讨论】:

  • 您需要在运行时(从代码)更改身份验证类型还是单个配置更改就足够了?
  • 我需要在运行时更改身份验证类型(从代码)。

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


【解决方案1】:

只想分享找到的解决方案。要获取是否为 current 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

【讨论】:

    猜你喜欢
    • 2012-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多