【问题标题】:Looking for rest api to retrieve user entitlements on on-premise azure devops寻找 rest api 来检索本地 azure devops 上的用户权利
【发布时间】:2020-07-14 00:33:47
【问题描述】:

我在本地 azure devops 环境中自动化了几个进程,并且我正在寻找允许我从 azure devops 服务器检索用户权利的 rest api。

【问题讨论】:

  • 如果您还没有,请尝试检查此documentation here。如果您在关注后仍遇到问题,请添加具体细节。

标签: c# azure-devops azure-devops-rest-api on-premises-instances


【解决方案1】:

目前没有这样的 REST API 来检索本地 Azure DevOps 服务器的用户权利。

但是,作为一种解决方法,我们可以使用客户端 API 从特定集合中检索所有用户:(需要安装 Microsoft.TeamFoundationServer.ExtendedClient

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
using System.Linq;
using System.IO;

namespace Getuserlist

{

    class Program

    {
        static void Main(string[] args)

        {

            TfsConfigurationServer tcs = new TfsConfigurationServer(new Uri("https://wsicads2019"));

            IIdentityManagementService ims = tcs.GetService<IIdentityManagementService>();

            TeamFoundationIdentity tfi = ims.ReadIdentity(IdentitySearchFactor.AccountName, "[DefaultCollection]\\Project Collection Valid Users", MembershipQuery.Expanded, ReadIdentityOptions.None);

            TeamFoundationIdentity[] ids = ims.ReadIdentities(tfi.Members, MembershipQuery.None, ReadIdentityOptions.None);

            using (StreamWriter file = new StreamWriter("userlist.txt"))

                foreach (TeamFoundationIdentity id in ids)

                {
                    if (id.Descriptor.IdentityType == "System.Security.Principal.WindowsIdentity")

                    { Console.WriteLine("[{0},{1}]", id.UniqueName); }

                    file.WriteLine("[{0},{1}]", id.UniqueName);
                }

            var count = ids.Count(x => ids.Contains(x));
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

在客户端的开发人员命令提示符下交替运行 TFSSecurity 命令或在 Azure DevOps 服务器应用程序层上运行以获取所有用户和组的列表:

tfssecurity /imx all: /server:http://server:8080/tfs

对于访问级别,我们可以调用以下 REST API 来获取相应的用户:(在 Azure DevOps 2019 上测试)

Stakeholder : 
http://server:8080/tfs/_api/_identity/ReadLicenseUsers?__v=5&licenseTypeId=242a857e-50ce-43d9-ba9f-3aa82457d726

Basic : 
http://server:8080/tfs/_api/_identity/ReadLicenseUsers?__v=5&licenseTypeId=8b71784c-27ab-4490-bb97-e699ed4123e1

Basic + Test Plans : 
http://server:8080/tfs/_api/_identity/ReadLicenseUsers?__v=5&licenseTypeId=f29e17f1-60bd-44f0-ab2f-d67207ee9484

VS Enterprise : 
http://server:8080/tfs/_api/_identity/ReadLicenseUsers?__v=5&licenseTypeId=519a4528-2bd6-4ea4-b3cb-5440c1aaebc3

【讨论】:

  • @OkoronkwoAlfredChinedu 您是否按照解决方法解决了问题?这里有更新吗?
猜你喜欢
  • 2020-04-23
  • 2020-05-12
  • 2020-11-26
  • 1970-01-01
  • 2020-06-12
  • 1970-01-01
  • 2022-07-17
  • 2021-07-17
  • 1970-01-01
相关资源
最近更新 更多