Asp.net delegation



我正在制作一个。net Web API,通过调用SQL服务器来获取数据。用户通过Windows身份验证(Kerberos)进行身份验证。我希望用户凭据通过委托传递给SQL服务器,但是SQL服务器看到一个匿名用户。

这是我所做的:

  • IIS应用程序:启用了Windows身份验证和asp.net模拟。禁用匿名和表单身份验证。选中"启用内核模式身份验证"。提供者:协商、Kerberos。

  • 应用程序池:托管管道模式:经典。身份:网络服务

  • 在AD中,运行web服务器的计算机被设置为"信任这台计算机来授权任何特定的服务(仅限Kerberos)"。

  • 到SQL server的连接字符串包含Integrated Security=SSPI;

  • 编辑:在我的网页。config I have

 <system.web>
    <authentication mode="Windows" />
    <identity impersonate="true" />
  </system.web>

<security>
  <authentication>
    <windowsAuthentication enabled="true">
      <providers>
        <clear />
        <add value="Negotiate" />
        <add value="Kerberos" />
      </providers>
      <extendedProtection tokenChecking="None" />
    </windowsAuthentication>
   <anonymousAuthentication enabled="false" />
  </authentication>
</security>
  • 为机器设置通用主机spn。

从浏览器中,我通过http://machinename.domain.net访问web应用程序。

我希望在这个设置中,我的IIS应用程序在机器帐户下运行?

当我在web服务器上的调试器中捕获请求时,我可以看到windowidentity . getcurrent()。Name是浏览web应用程序的用户的帐户和windowidentity . getcurrent()。"AuthenticationType"设置为"Kerberos"。这应该很好。

然而WindowsIdentity.GetCurrent

()。ImpersonationLevel只设置为"Impersonate"。我希望它被设置为"委托"?

当我向SQL服务器发出请求时,我得到"用户'NT AUTHORITYANONYMOUS LOGON'登录失败",因此显然用户凭据没有传递到SQL服务器。

我希望有人能看到我做错了什么。

供将来参考,如果有人遇到同样的问题:问题是我们在Chrome上进行了尝试。它可以在IE中工作,但在Chrome上,这篇文章中提到的注册表更改是必要的:Kerberos委托在Chrome中不起作用

您应该能够将身份验证设置为ASP。. NET在IIS中的模拟。您可能需要在web中设置以下内容。配置文件也是,作为<系统。>

网络>部分。
    <identity impersonate="true" />

在<系统。webServer>部分,尽管出于安全考虑并不总是推荐。

<validation validateIntegratedModeConfiguration="false" />

最新更新