如何从 TFS 中选择所有用户到列表中? [英] How to select all users from TFS into a list?

查看:29
本文介绍了如何从 TFS 中选择所有用户到列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出所有 TFS 用户的列表,而不管他们是否有任何变更集.我希望列表中的所有用户都使用 C# 和 MVC.我该怎么做?

I want to make a list of all users of TFS irrespective of the fact if they have any changesets or not. I want all the users in my list, using C# and MVC. How do I do this?

推荐答案

以下是我列出集合的所有用户的方法(参考 Microsoft.TeamFoundation.Client.dll):

Here is a way how I list all user of a collection (reference Microsoft.TeamFoundation.Client.dll):

IIdentityManagementService ims = (IIdentityManagementService)tfsConnection.GetService(typeof(IIdentityManagementService));
// get all valid users of the collection
TeamFoundationIdentity SIDS = ims.ReadIdentity(IdentitySearchFactor.AccountName, "Project Collection Valid Users", MembershipQuery.Expanded, ReadIdentityOptions.ExtendedProperties);
List<string> ids = new List<string>();
foreach (var member in SIDS.Members)
{
    ids.Add(member.Identifier);
}

// get user objects for existing SIDS
TeamFoundationIdentity[][] UserId = ims.ReadIdentities(IdentitySearchFactor.Identifier, ids.ToArray(), MembershipQuery.None, ReadIdentityOptions.ExtendedProperties);
// convert to list
List<TeamFoundationIdentity> UserIds = UserId.SelectMany(T => T).ToList();

foreach (TeamFoundationIdentity user in UserIds)
{
  // exclude groups in listing
  if (!user.IsContainer)
  {
    //do what you want with the user
  }
}

这篇关于如何从 TFS 中选择所有用户到列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆