代码之家  ›  专栏  ›  技术社区  ›  Chris S

使用ASP.NET和TFS API进行直通(模拟)身份验证

  •  6
  • Chris S  · 技术社区  · 14 年前

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

    我在Cassini上可以正常工作,但是在IIs7.5(Windows7)上有问题。

    我找到了 this blog post 关于这个问题,并尝试了以下方法:

    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身份验证模块):

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

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

    2 回复  |  直到 14 年前
        1
  •  7
  •   Chris S    14 年前
    1. AD

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

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

    IIS

    • <
        2
  •  5
  •   Paul Nearney    14 年前