如何从TFS中选择所有用户到列表中

本文关键字:用户 列表 选择 TFS | 更新日期: 2023-09-27 18:19:23

我想列出TFS的所有用户,而不管他们是否有任何更改集。我希望所有的用户在我的列表中,使用c#和MVC。我该怎么做呢?

如何从TFS中选择所有用户到列表中

这是我列出集合(引用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
  }
}