【问题标题】:authentication failed while connecting to tfs using tfs api [duplicate]使用 tfs api 连接到 tfs 时身份验证失败 [重复]
【发布时间】:2012-12-13 21:41:31
【问题描述】:

可能重复:
authentication failed while connecting to tfs using tfs api

我遇到了一个奇怪的问题。我想以编程方式使用 tfs api 连接 tfs 服务器。 即使在提供适当的 authentcaion crdiatials 之后它也会失败。但是如果我通过在浏览器中键入 tfs 服务器名称来手动执行它,它就会连接。

代码:

TeamFoundationServer tfs = 
      new TeamFoundationServer(new Uri("http://xx.xx.xx.xx:8080/tfs"), 
                        new NetworkCredential(@"user", "pass", "domain"));
tfs.EnsureAuthenticated()

请提出建议。

【问题讨论】:

  • 我真的希望这不是您的实际 ip 和身份验证详细信息...如果是这样,如果我是您,我会编辑您的问题!

标签: c# asp.net tfs


【解决方案1】:

你可能想用这个alternative

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
using System;
using System.Collections.ObjectModel;

class Program
{
    static void Main()
    {
        var tfsUri = new Uri("http://xx.xx.xx.xx:8080/tfs");

        TfsConfigurationServer configurationServer =
                TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

        // Get the catalog of team project collections
        ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
            new[] { CatalogResourceTypes.ProjectCollection },
            false, CatalogQueryOptions.None);

        // List the team project collections
        foreach (CatalogNode collectionNode in collectionNodes)
        {
            // Use the InstanceId property to get the team project collection
            Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

            // Print the name of the team project collection
            Console.WriteLine("Collection: " + teamProjectCollection.Name);

            // Get a catalog of team projects for the collection
            ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
                new[] { CatalogResourceTypes.TeamProject },
                false, CatalogQueryOptions.None);

            // List the team projects in the collection
            foreach (CatalogNode projectNode in projectNodes)
            {
                Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName);
            }
        }
    }
}

【讨论】:

    【解决方案2】:

    你可以做到a simpler way(假设你已经通过认证):

    var tfsCollection = new TfsTeamProjectCollection(new Uri("http://yourtfs:8080/tfs/"));
    tfsCollection.Authenticate();
    var workItemStore = new WorkItemStore(TfsCollection);
    

    【讨论】:

      猜你喜欢
      • 2012-12-01
      • 2015-04-10
      • 2018-07-23
      • 1970-01-01
      • 2017-02-21
      • 2010-11-03
      • 1970-01-01
      • 2017-05-24
      • 1970-01-01
      相关资源
      最近更新 更多