如何获取 TFS 2013 中所有用户的列表 [英] How do I get list of all users in TFS 2013
本文介绍了如何获取 TFS 2013 中所有用户的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是 Team Foundation Server (TFS) 2013 和 Visual Studio 2012.我需要 TFS 中所有用户的列表.
I am using Team Foundation Server (TFS) 2013 and Visual studio 2012. I need a list of all the user in TFS.
有没有办法使用 C# 获取 TFS 中的所有用户?
Is there any way to get all the users in TFS using C#?
推荐答案
从 TFS 2010 获取用户列表,您可以尝试使用 TFS API,请参考以下代码片段:
Get the users list from TFS 2010, you can try use the TFS API, please refer to the following code snippet:
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);
}
请试试这个代码,上面的代码在 VS2010 &VS2013.如果您有任何问题,请告诉我.
Please try this code, above code is working in VS2010 & VS2013. Let me know if you have any questions.
更多信息在此链接
More information in this link
这篇关于如何获取 TFS 2013 中所有用户的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文