现在没有Rest API可以做到这一点。您必须使用旧客户端API与ReadIdentities方法。这也适用于TFS2017。示例代码:
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("url"));
tfs.EnsureAuthenticated();
IGroupSecurityService gss = tfs.GetService<IGroupSecurityService>();
Identity SIDS = gss.ReadIdentity(SearchFactor.AccountName, "Project Collection Valid Users", QueryMembership.Expanded);
Identity[] UserId = gss.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.None);
foreach (Identity user in UserId)
{
Console.WriteLine(user.AccountName);
Console.WriteLine(user.DisplayName);
}
更多详细信息,请参阅How do I get list of all users in TFS 2013并且也有许多人在谷歌。
它使用.NET client libraries for TFS,您可以通过将nuget包导入到Visual Studio项目中来使用这些方法。这也适用于TFS2017。
我需要从TFS扩展中进行此调用;是否可以从前端JavaScript代码中调用该API?我已经为我的问题添加了一个解释性说明来澄清。谢谢你的时间! – broAhmed
阻止我接受这个答案的唯一原因是我需要从前端JavaScript代码中调用API :( – broAhmed
Hi @broAhmed,通过更多的信息和API后。不幸的是,它仍然无法做到这一点前端JavaScript代码现在:(你可以使用客户端API,Powershell,查询数据库,而不是Rest API,你可以添加一个[uservocie](https://visualstudio.uservoice.com/forums/330519-team - 服务),TFS PM会好心检讨你的建议 –