How do I get list of all users in TFS 2013

北城余情 提交于 2019-12-06 05:34:09

问题


I am using Team Foundation Server (TFS) 2013 and Visual studio 2012. I need a list of all the user in TFS.

Is there any way to get all the users in TFS using C#?


回答1:


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);
}

Please try this code, above code is working in VS2010 & VS2013. Let me know if you have any questions.

More information in this link



来源:https://stackoverflow.com/questions/30639288/how-do-i-get-list-of-all-users-in-tfs-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!