Team Services程序化访问对某些没有凭据的用户有效-为什么? [英] Team Services programmatic access is working for some users without credentials - why?

查看:58
本文介绍了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_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp(在VS2017中测试,它也存储在14.0中)

Check this registry path: HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp (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天全站免登陆