Team Services 编程访问适用于一些没有凭据的用户 - 为什么? [英] Team Services programmatic access is working for some users without credentials - why?

查看:17
本文介绍了Team Services 编程访问适用于一些没有凭据的用户 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近升级到了 VS 2017 和 Visual Studio Team Services.

We have recently upgraded to VS 2017 and Visual Studio Team Services.

我们有一套自动化工具,可以代表开发人员执行各种与源代码控制相关的任务.

We have a set of automated tools that perform various source control related tasks on behalf of developers.

某些用户和一个服务帐户似乎在某处缓存了凭据,并且在运行工具时不会提示输入凭据.

Some users and one service account appear to have cached credentials somewhere and do not get prompted for credentials when running the tools.

但是,系统会提示其他用户输入凭据.

However, other users get prompted for credentials.

我创建了一个迷你测试应用程序来说明这个问题.注意:VSTS dll 是来自 VS2017 Team Explorer 安装文件夹的 15.x 版文件.如果您不介意膨胀,它们也可作为 Microsoft.TeamFoundationServer.ExtendedClient NuGet 包的一部分使用.

I created a mini test app to illustrate the issue. NOTE: The VSTS dlls are the version 15.x files from the VS2017 Team Explorer installation folder. They are also available as part of the Microsoft.TeamFoundationServer.ExtendedClient NuGet package if you don't mind the bloat.

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace VSTSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                if (args.Length > 0)
                {
                    var projectCollectionUrl = args[0];

                    var projectCollection = new TfsTeamProjectCollection(new Uri(projectCollectionUrl));
                    var versionControlServer = (VersionControlServer)projectCollection.GetService(typeof(VersionControlServer));

                    Console.WriteLine("AuthorizedUser: {0}", versionControlServer.AuthorizedUser);
                }

                Console.WriteLine("Usage is {projectCollectionUrl}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.ReadLine();
        }
    }
}

这对某些用户有效,但对其他人无效,我正在努力找出原因.

This works for some users but not for others and I am trying to find out why.

推荐答案

检查这个注册表路径:HKEY_CURRENT_USERSoftwareMicrosoftVSCommon14.0ClientServicesTokenStorageVisualStudioVssApp(在VS2017中测试,它也存储在 14.0)

Check this registry path: HKEY_CURRENT_USERSoftwareMicrosoftVSCommon14.0ClientServicesTokenStorageVisualStudioVssApp (Tested in VS2017, it stores in 14.0 too)

您还可以查看凭证管理器.

You also can check credential manager.

另一方面,您可以更改存储密钥:

On the other hand, you can change storage key:

var c = new VssClientCredentials();
c.Storage = new VssClientCredentialStorage(storageKind: "VssApp2", storageNamespace: "VisualStudio");
TfsTeamProjectCollection _tfs = new TfsTeamProjectCollection(u, c);

这篇关于Team Services 编程访问适用于一些没有凭据的用户 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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