【问题标题】:Kerberos authentication issues in IIS Intranet Apps - Cloud vs On PremisesIIS Intranet 应用程序中的 Kerberos 身份验证问题 - 云与本地
【发布时间】:2021-08-30 20:20:55
【问题描述】:

我有一个问题困扰了我几个星期。

我们正在将我们的开发环境从本地迁移到 AWS EC2 实例,包括我们的 IIS 服务器。这托管了许多 Web 服务、ASP.Net 和 .Net Core 内部网应用程序。

其中大多数使用 Windows 身份验证,没有一个是面向外部世界的。

一些应用程序在这两种环境中都可以正常工作,但其中一些应用程序可以在本地环境中工作,但不能在 AWS 环境中工作,我要么弹出 windows 身份验证,要么出现 401(未经授权)“HTTP 请求未经授权使用客户端身份验证方案“匿名”。从服务器收到的身份验证标头是“协商,NTLM”。

所有应用程序都在具有委托权限的特定域帐户下运行,并且为该帐户设置了一个 SPN,用于托管各种应用程序数据库(也在 AWS 中)的 SQL 服务器。

在提供者下,所有应用程序都先协商,然后是 NTLM。

大多数应用程序仅启用 Windows 身份验证,有些应用程序具有 ASP.Net 模拟 也启用了,但与那些有这个设置的和那个工作的和那些没有的没有关联。

我尝试根据这篇文章设置 DisableStrictNameChecking:Unable to get windows authentication to work through local IIS

我读过的其他 SO 帖子:

ASP.net kerberos dropping down to NTLM sporadically

Add a Kerberos authentication to existing WebService in asp.net c#

WCF service access from client application when user is behind proxy

Error: The remote server returned an error: (401) Unauthorized

Many Web Service calls caused 401 Unauthorized response randomly

(401) Unauthorized error : WCF security/binding

其中一个应用在 web.config 中有以下部分:

    <system.web>      
      <authorization>
        <allow users="*" />
        <!-- Allowing all users. If the users dont have access then they see this page.. -->
      </authorization>
    </system.web>
  </location>

  <system.web>
    <compilation targetFramework="4.7" />
    <authentication mode="Windows" />
    <identity impersonate="true" />
    <customErrors mode="Off" />
    <authorization>
      <allow roles="XXXX\Development/>
      <deny users="*" />
    </authorization>
  </system.web>

这个应用程序在 AWS 中运行,我进入了 NoAccess.aspx 页面(我不是 Development AD 组的成员)。然后我删除了配置的“位置路径”部分,重新​​启动了应用程序池并获得了登录提示(如预期的那样)。

当我重新添加该部分并重新启动应用程序池时,我不再到达该页面,只是立即收到一个 401 错误“HTTP 请求未经授权,客户端身份验证方案‘匿名’。从服务器收到的身份验证标头是“协商,NTLM”。

有人知道为什么会发生这种情况吗?我无法在有效和无效的应用之间找到共同点。

我打开了增强型日志记录,并在运行其中一个无法运行的应用程序时看到了以下警告。有趣的是,它表明我已通过身份验证(并且我有权运行该应用程序)。

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 6/8/2021 12:09:45 PM 
Event time (UTC): 6/8/2021 12:09:45 AM 
Event ID: fd6819aa0e4e4011a54d98790112c2f8 
Event sequence: 8 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/3/ROOT/ContactManagementApp-1-132675845823847857 
    Trust level: Full 
    Application Virtual Path: /ContactManagementApp 
    Application Path: D:\Applications\ContactManagementApp\ 
    Machine name: SRV123 
 
Process information: 
    Process ID: 1224 
    Process name: w3wp.exe 
    Account name: DOMAIN\SRV123-iis 
 
Exception information: 
    Exception type: WebException 
    Exception message: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

 
 
Request information: 
    Request URL: http://SRV123/ContactManagementApp/contact.aspx 
    Request path: /ContactManagementApp/contact.aspx 
    User host address: 123.123.123.123
    User: DOMAIN\userName 
    Is authenticated: True 
    Authentication Type: Negotiate 
    Thread account name: DOMAIN\SRV123-iis 
 
Thread information: 
    Thread ID: 7 
    Thread account name: DOMAIN\SRV123-iis 
    Is impersonating: False 
    Stack trace:    at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
 
 
Custom event details: 

对此我需要注意什么? kerberos 会不会有超时问题?

【问题讨论】:

  • 感谢@theobald-du,这并不能真正解释为什么应用程序可以在一种环境中运行,而不能在另一种环境中运行,因为它指的是更改应用程序特定的配置。

标签: asp.net authentication iis


【解决方案1】:

我设法通过在 AWS 中设置只读域控制器来解决此问题。工作原理是,在与本地 DC 对话时,kerberos 存在某种超时问题。

【讨论】:

    猜你喜欢
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    • 2011-04-16
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 2020-06-14
    • 2010-09-09
    相关资源
    最近更新 更多