在IIS7 Windows 2008中启用双跳代委派的步骤
-
30-09-2019 - |
题
我的ASP.NET Web应用程序在Intranet上使用Windows身份验证。我希望它能够向同一域上的另一台服务器提供服务器端HTTP请求,该域也需要Windows身份验证。
在此处提出附加请求时,我遵循有关临时模拟身份验证用户的说明:
http://msdn.microsoft.com/en-us/library/ff647404.aspx
使用这样的代码:
using System.Security.Principal;
// Obtain the authenticated user's Identity
WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = null;
try
{
// Start impersonating
ctx = winId.Impersonate();
// Now impersonating
// Access resources using the identity of the authenticated user
var request = WebRequest.Create("http://intranet/secureapp");
request.Credentials = CredentialCache.DefaultCredentials;
var response = request.GetResponse();
using (var streamReader = new StreamReader(response.GetResponseStream()))
{
Response.Write(streamReader.ReadToEnd());
}
}
// Prevent exceptions from propagating
catch
{
}
finally
{
// Revert impersonation
if (ctx != null)
ctx.Undo();
}
// Back to running under the default ASP.NET process identity
但是,不幸的是,我总是得到401个未经授权的错误。
我是否需要使用Active Directory配置我们的Web服务器以允许其委派自动用户(可能是200个用户中的任何一个,因此不想做200次的任何事情:))?如果是这样,谁能告诉我该怎么做?
解决方案
使用Windows配置Kerberos/委托有几个步骤。
首先,您需要配置ASP.NET以使用委托。我假设您在web.config中配置了此功能。
然后,您需要为授权配置ASP.NET服务帐户。有时您必须创建一个SPN。
然后在Active Directory中启用IIS服务器和帐户的委托。
这里提供了逐步说明: http://msdn.microsoft.com/en-us/library/ms998355.aspx遵循步骤1-3。
不隶属于 StackOverflow