[英]Looking for rest api to retrieve user entitlements on on-premise azure devops
I am automating a couple of processes on an on-premise azure devops environment and I am looking for rest apis that would allow me retrieve user entitlements from the azure devops server.我在本地 azure devops 环境中自动化了几个进程,我正在寻找 rest api,它允许我从 ZCF04A02E37B774FC311A48F605C 服务器检索用户权利。
Currently there isn't such a REST API to retrieve user entitlements for on-premise Azure DevOps server.目前没有这样的 REST API 来检索本地 Azure DevOps 服务器的用户权利。
However as a workaround we can retrieve all the users using the client API from a specific collection: (Need to install Microsoft.TeamFoundationServer.ExtendedClient )但是,作为一种解决方法,我们可以使用客户端 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();
}
}
}
Alternately run TFSSecurity command from Developer command prompt on Client or run on Azure DevOps Server Application Tier to get list of all users and groups:或者从客户端上的开发人员命令提示符运行TFSSecurity命令或在 Azure DevOps 服务器应用程序层上运行以获取所有用户和组的列表:
tfssecurity /imx all: /server:http://server:8080/tfs
For access levels we can call the following REST APIs to get the corresponding users: (Tested on Azure DevOps 2019)对于访问级别,我们可以调用以下 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.