将我的网站移至其他服务器会将身份验证从 Kerberos 更改为 NTLM

将我的网站移至其他服务器会将身份验证从 Kerberos 更改为 NTLM

我有一个配置为 Windows 身份验证的 Web 服务。调用 WS 的客户端代码将凭据传递给 WS,如下所示:

myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials;

(我的理解是,这代表登录用户的用户名-密码-域)。

我正在测试配置问题,但不清楚如何确保 Kerberos 已设置。

详情 关注:

我在同一个 IIS 服务器(一个是带有 .aspx 页面的“客户端”),另一个是“服务器”(它托管客户端调用的 Web 服务)。

我的客户端通过以下代码显示有关连接用户的关键信息:

private string GetUserInfo()
{
    System.Security.Principal.WindowsIdentity UserIdentityInfo;
    StringBuilder msg = new StringBuilder("User Name: ");
    UserIdentityInfo = System.Security.Principal.WindowsIdentity.GetCurrent();
    msg.Append(UserIdentityInfo.Name);
    msg.Append(Environment.NewLine);
    msg.Append(" Token: ");
    msg.Append(UserIdentityInfo.Token.ToString());
    msg.Append(Environment.NewLine);
    msg.Append(" Authenticated: ");
    msg.Append(UserIdentityInfo.AuthenticationType);
    msg.Append(Environment.NewLine);
    msg.Append(" System: ");
    msg.Append(UserIdentityInfo.IsSystem);
    msg.Append(Environment.NewLine);
    msg.Append(" Guest: ");
    msg.Append(UserIdentityInfo.IsGuest);
    msg.Append(Environment.NewLine);
    msg.Append(" Anonymous: ");
    msg.Append(UserIdentityInfo.IsAnonymous);
    msg.Append(Environment.NewLine);
    return msg.ToString();
}

身份验证类型为凯尔伯罗斯当 webclient 和被调用的 webservice 都在同一台服务器上(例如 SERVER1)时。实际执行也能正常进行。

身份验证类型更改为NTLM当调用相同的 webclient 代码时,但它现在驻留在 SERVER2 上。被调用的 webservice 仍然驻留在原始服务器 (SERVER1) 上。实际执行失败,因为凭证不正确。

SERVER1 和 SERVER2 在同一个局域网(同一个域)上,并且我用于测试上述每个场景的域帐户是相同的(我在每台机器上都在管理员组中)。

我该如何配置它以便 KERBEROS 成为身份验证类型 - 也就是说,当“我”从浏览器调用 SERVER2 上的这个客户端时?

答案1

您遇到的情况是典型的双跳情况。以下帖子中的图形几乎就是您的确切情况:

http://blogs.technet.com/b/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx

当您的“客户端”和“服务”都在 Server1 上时,只有一个“单跳”来验证用户身份。当您将 Server2 引入组合时,您现在有了双跳,身份验证现在被委托。

由于您以域帐户身份运行应用程序池,因此您需要设置服务主体名称 (SPN) 以防止双跳。上面的帖子中提到了相关资源。本文中也提到了这一点:

http://msdn.microsoft.com/en-us/library/ff649309.aspx

需要为特定用户帐户、服务和主机名创建 SPN。这需要在域控制器上完成。

相关内容