【问题标题】:Can't Get Windows Authentication to Work无法让 Windows 身份验证工作
【发布时间】:2014-12-10 11:19:28
【问题描述】:

我尝试使用 Windows 身份验证在 aspx 中创建身份验证系统。对于使用 Windows PC 的公司来说,这似乎是在 Intranet 中验证用户的默认模式。我在 IIS 中为我​​的站点启用了“Windows 身份验证”,并禁用了其他类型的身份验证。这是我的 Web.config 文件:

<system.web>
    <authentication mode="Windows" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
</system.web>

我所拥有的是我的代码中这一行提供的反馈(总是错误的)

Response.Write(User.Identity.IsAuthenticated.ToString());

我不确定我是否以正确的方式做所有事情,但我已经阅读了许多教程并且一切似乎都很简单......那么,我想做什么?我做错了什么?

我没有找到任何对我的实施有帮助的东西,只是我写的所有东西似乎什么都没做。呃,我也没有看到 Windows Auth Dialog

【问题讨论】:

  • 试试(WindowsIdentity)HttpContext.Current.User.Identity; 看看它会返回什么

标签: c# asp.net windows authentication iis


【解决方案1】:

我解决了在 IIS 的“授权规则”中添加一行的问题。在我的公司,我们都是管理员,所以我为管理员用户添加了允许规则,并拒绝了其他人的访问。现在一切正常,我显示 Windows 身份验证对话框,并使用用户名和密码进行身份验证。

【讨论】:

    【解决方案2】:

    检查这些要求:

    1. Windows 身份验证已在 IIS 中启用(您已经这样做了)。
    2. 匿名访问在 IIS (http://technet.microsoft.com/en-us/library/cc731244(v=ws.10).aspx) 中被禁用
    3. Windows 身份验证在客户端的 Internet Explorer 中启用
    4. impersonationweb.config (http://msdn.microsoft.com/en-us/library/134ec8tc(v=vs.140).aspx) 中开启。

    据我所知,仅此而已。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-27
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      • 2015-12-24
      • 2016-11-09
      相关资源
      最近更新 更多