6

我正在尝试在使用 TFS2010 API 的 ASP.NET 网站内启用直通或模拟身份验证。

我在 Cassini 上可以正常工作,但是在 IIS 7.5 (Windows 7) 中出现了问题。

我找到了关于这个主题的这篇博文,并尝试了以下方法:

private static void Test()
{
    TfsTeamProjectCollection baseUserTpcConnection = 
            new TfsTeamProjectCollection(new Uri(Settings.TfsServer));
    
    // Fails as 'baseUserTpcConnection' isn't authenticated
    IIdentityManagementService ims = 
            baseUserTpcConnection.GetService<IIdentityManagementService>();
    
    // Read out the identity of the user we want to impersonate
    TeamFoundationIdentity identity = ims.ReadIdentity(
            IdentitySearchFactor.AccountName, 
            HttpContext.Current.User.Identity.Name,
            MembershipQuery.None, 
            ReadIdentityOptions.None);

    TfsTeamProjectCollection impersonatedTpcConnection = new 
            TfsTeamProjectCollection(new Uri(Settings.TfsServer), 
            identity.Descriptor);
}

当我使用卡西尼时,除了

collection = new TfsTeamProjectCollection(new Uri(server));

我已启用 web.config 设置(并安装了 Windows Auth 模块):

<authentication mode="Windows"/>
<identity impersonate="true" />

有什么明显的我错过了吗?

4

2 回答 2

7

解决方案 1

这是委托方法。正如 Paul 指出的,这是您活动目录中的一个设置:

  1. 在“Active Directory 用户和计算机”控制台的计算机节点中找到 IIS 服务器。

  2. 单击委托选项卡,然后选择第二个选项: 广告

  3. 在 IIS 根文件夹中创建一个“缓存”目录

  4. 将以下内容添加到您的 web.config 中:

<appSettings>
<add key="WorkItemTrackingCacheRoot" value="C:\path-to-web-root\Cache\"/>
</appSettings>

  1. 确保您的 web.config 包含:

<system.web>
<identity impersonate="true" />
</system.web>

  1. 打开 Windows 身份验证和模拟并禁用 IIS 身份验证中的所有其他内容:

IIS

解决方案 2

避免上述步骤的另一个解决方案是在 TFS:8080 站点下简单地运行您的应用程序,作为一个新应用程序。当您在与您的应用程序调用的 Web 服务相同的上下文中运行时,跃点问题将被移除。

  • 创建一个新的应用程序池,使用网络身份。
  • 确保您的应用程序已关闭匿名身份验证
  • 确保它已打开 Windows 身份验证。
  • 添加<identity impersonate="true" />到网络配置。
于 2010-10-25T23:56:00.090 回答
5

我想知道您是否在这里遇到了旧的Double-Hop问题?

于 2010-10-25T12:11:08.477 回答