使用 Windows 身份验证通过其 API 访问 TFS [英] Access TFS via its API using Windows Authentication

查看:38
本文介绍了使用 Windows 身份验证通过其 API 访问 TFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

我正在使用 ASP.Net MVC 4 应用程序.我已启用 Windows 身份验证.

I am using the ASP.Net MVC 4 application. I have enabled Windows Authentication.

直到现在它工作正常.

现在我增强了应用程序以通过其 API 连接到 TFS.为此,我需要使用 Windows 身份验证凭据.

Now I enhanced the application to connect to TFS via its API. For this, I need to use the windows authentication credentials.

我试过使用

ICredentialsProvider credential = new UICredentialsProvider();
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, credential);

这在开发环境中非常有效.但是,当我在 IIS 8.5 中托管应用程序时,它在应用程序池标识"和网络服务"帐户下根本不起作用.

This works great in the development environment. But when I host the application in IIS 8.5, it is not working at all under "Application Pool Identity" and "Network Service" account.

我尝试使用本地系统和应用程序池标识中的特定用户,它正在工作.

I tried with Local System and specific user in identity of application pool, it is working.

但我需要它基于 Windows 凭据(活动目录)工作.

But I need this to work based on the windows credential (Active directory).

谁能提出解决方案?

推荐答案

您可能遇到了 Kerberos 双重希望问题.

You are likely hitting a Kerberos double hope issue.

您有两种解决方法:

  1. 在与 tfs 相同的服务器上托管您的 mvc Web 应用
  2. 配置 Active Directory 以允许您的服务器身份将登录的用户凭据委托给其他服务.

#1 很简单,但 #2 需要您的 Active Directory 域管理员进行大量工作.

https://support.microsoft.com/en-us/kb/810572

您将需要:

  1. 至少为您的服务器帐户配置了一个服务主体名称 (SPN)(专用域\svc_myaccout 或用于网络服务的域\servername$ 帐户).
  2. 需要启用您使用的帐户以允许在 AD 中进行委派
  3. 托管您的应用程序的服务器需要启用委派

这不是 101,根据我的经验,在企业和小型企业中做了很多事情,大多数域管理员不知道 Kerberos 委派是如何工作的,或者如何配置它.

This is not 101 and in my experience, having done this a bunch in enterprise and small business, that most Domain Administrators don't know how Kerberos delegation works, or how to configure it.

您将需要了解如何并明确要求他们采取行动.比如运行‘setspn myapp.mydomain.com domain\myserviceaccount’".

You will need to learn how and make explicit requests that they can action. Like "run 'setspn myapp.mydomain.com domain\myserviceaccount'".

这篇关于使用 Windows 身份验证通过其 API 访问 TFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆