IIS7模拟身份无法访问TFS代码库

7

我正在尝试构建一个在TFS中添加工作项的ASP.NET页面。

我已经启用了模拟和Windows身份验证:

<authentication mode="Windows" />
<identity impersonate="true" password="" userName="" />
<customErrors mode="Off" /> 

在页面上,我访问TFS并尝试添加工作项:
TfsTeamProjectCollection prjCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("xxx"));
WorkItemStore store = prjCollection.GetService<WorkItemStore>();
...

然而,只有我在ASP.NET模拟中选择了“特定用户”并存储了凭据时,它才能正常工作。当选择“已验证的用户”时,它无法工作。我已经检查过SpecificUser和Authenticated User是相同的,但在后一种情况下我会收到权限错误(这表明模拟未正确工作)。
TF30063: You are not authorized to access XXX. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at     Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.AsyncWebRequest.ExecRequest(Object obj)
   --- End of inner exception stack trace ---
   at     Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.ProcessHttpResponse(HttpWebResponse response, Stream responseStream, WebException webException, XmlReader& xmlResponseReader)
   at Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.ExecWebServiceRequest(HttpWebRequest request, XmlWriter requestXml, String methodName, HttpWebResponse& response)
   at Microsoft.TeamFoundation.Framework.Client.LocationWebService.Connect(Int32 connectOptions, ServiceTypeFilter[] serviceTypeFilters, Int32 lastChangeId)
   at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.Connect(ConnectOptions connectOptions)
   at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.EnsureConnected(ConnectOptions optionsNeeded)
   at Microsoft.TeamFoundation.Framework.Client.FrameworkServerDataProvider.get_InstanceId()
   at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.InitializeInternal()
   at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.InitializeTeamFoundationObject(String fullName, Object instance)
   at Microsoft.TeamFoundation.Client.TfsConnection.CreateServiceInstance(Assembly assembly, String fullName)
   at Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
   at Microsoft.TeamFoundation.Client.TfsConnection.GetService[T]()
   at ASP.index_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)

以下变量在两种情况下看起来都是相同的:
HttpContext.Current.Request.LogonUserIdentity.Name
HttpContext.Current.Request.IsAuthenticated
HttpContext.Current.User.Identity.Name
System.Environment.UserName
System.Security.Principal.WindowsIdentity.GetCurrent().Name

有什么想法吗?

编辑:

正如约翰在下面提到的那样,问题是由于 Kerberos委派引起的。

Kerberos委派

我发现以下文章和附带工具非常有用,可以解释和缓解此问题:

DelegConfig - 一个帮助解决Kerberos身份验证和委派问题的工具

Kerberos委派检查

3个回答

7

我认为你可能有一个"双跳"问题。


+1 ... 刚刚部署了一套基于 Web 的 UI 工具,用于在 IIS 上作为 Web 应用程序与 TFS 进行交互的“另一台机器”。 我观察到与本帖中描述的相同的行为。 有任何已知的解决方法吗? 先感谢了。 - culturalanomoly
是的。请点击我的回答中的“双跳”链接。 - John Saunders

2

根据这篇文章,尝试添加EnsureAuthenticated();可能会有所帮助。

TfsTeamProjectCollection prjCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("xxx"));
prjCollection.EnsureAuthenticated();
WorkItemStore store = prjCollection.GetService<WorkItemStore>();

我从未尝试过这个,所以只能希望它能够成功。


0

运行IIS应用程序池的用户是谁?默认情况下,我认为它是IIUSR帐户之一,不一定是具有TFS服务器凭据的域帐户。


它使用默认的ApplicationPoolIdentity,但这就是为什么我设置了模拟身份验证,以便可以使用用户凭据访问TFS。 - the_void

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接