【问题标题】:authentication failed while connecting to tfs using tfs api使用 tfs api 连接到 tfs 时身份验证失败
【发布时间】:2012-12-01 00:09:18
【问题描述】:

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

代码:

TeamFoundationServer tfs = new TeamFoundationServer(new Uri("http://10.112.205.145:8080/tfs"),  new NetworkCredential(@"usrname", "pwd", "domain"));
tfs.EnsureAuthenticated()

请提出建议。

【问题讨论】:

    标签: c# asp.net tfs


    【解决方案1】:

    执行此操作的一种简单方法是将“Syetem.Net”命名空间添加到您的代码中,然后使用“CredentialCache”对象。使用“DefaultCredentials”将使用活动用户的凭据进行身份验证。

    // connect to the collection
    using (TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection("http://server:8080/tfs/DefaultCollection", CredentialCache.DefaultCredentials))
                { 
                    //Do Stuff here 
                }
    

    【讨论】:

    • 我将此问题解释为 OP 希望使用可能具有更高权限的特定用户..
    • 这是一个足够公平的假设,但不确定是否要在代码中留下具有提升权限的凭据 :-)
    【解决方案2】:

    你试过这样做吗..

    TfsTeamProjectCollection collection = new TfsTeamProjectCollection(
        new Uri(http://server:8080/tfs/DefaultCollection,
        new System.Net.NetworkCredential("domain_name\\user_name", "pwd"));
    collection.EnsureAuthenticated();
    

    【讨论】:

    • 仍然无法正常工作。它说您无权访问 tfs servername
    • 好的 - 试试下面的 - 安装 TFS Power Tools 并检查所有与安全相关的东西是否正常。你安装了 VS2010 SP1 吗?
    • 如果您已经进入 Internet 设置(我通过 IE > Internet 选项进行)并将 TFS 服务器的路径添加到“安全”选项卡中的受信任站点列表中。
    • 或 - 代表他人对默认集合应用 make 请求权限..
    • 嗨,石普,哪件事对你有用? The Unculled Badger 提供了 3 个选项
    【解决方案3】:

    对于您的问题,通常您会收到如下错误:

    失败的可能原因包括: - Team Foundation Server 的名称、端口号或协议不正确。 - Team Foundation Server 处于脱机状态。 - 密码已过期或不正确。

    问题的根本原因是 URI 应该以集合名称结尾。所以解决方法是,将“http://10.112.205.145:8080/tfs”更改为“http://10.112.205.145:8080/tfs/%YourCollectionName%”,然后就可以了! :-)

    【讨论】:

      猜你喜欢
      • 1970-01-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
      相关资源
      最近更新 更多