我有一个 TFS 扩展,需要获取 TFS 2017 中所有用户的列表。是否有为此的 API 调用?我能找到的最接近的东西是CoreHttpClient.getTeamMembers() https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/client/api/tfs/core/restclient/corehttpclient2_2#method_getTeamMembersREST 客户端调用。但我正在寻找返回所有用户身份列表的东西。
Google 搜索产生了一些旧版本 TFS 的结果,这些结果似乎不适用于 TFS 2017。
注意 1:这是针对现场托管的 TFS 实例,而不是 VSTS。
注 2:我正在寻找一种从 TFS 扩展的前端 JavaScript 代码调用此 API 的方法。
Thanks!
2017 年 6 月 29 日更新:请参阅帕特里克在他的回答中的评论。显然,目前没有可从 TFS 扩展前端调用的 REST API。
目前还没有 Rest API 可以做到这一点。您必须使用旧的客户端 API读取身份 https://msdn.microsoft.com/en-us/library/ff738489(v=vs.120).aspx方法。这也适用于 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);
}
更多详情请参考如何获取 TFS 2013 中所有用户的列表 https://stackoverflow.com/questions/30639288/how-do-i-get-list-of-all-users-in-tfs-2013谷歌上还有很多其他的。
它正在使用TFS 的 .NET 客户端库 https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet,您可以通过将 nuget 包导入到 Visual Studio 项目中来使用这些方法。这也适用于 TFS2017。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)