如何获取 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