Sunday, January 8, 2012

List the users of a TFS project associated with a local workspace path

  1. var workspace = Workstation.Current.GetLocalWorkspaceInfo(path);
  2. var tfs = new TfsTeamProjectCollection(workspace.ServerUri);
  3. var gss = tfs.GetService<IGroupSecurityService>();
  4. var grp = gss.ReadIdentity(SearchFactor.EveryoneApplicationGroup, null, QueryMembership.Expanded);
  5. var names = gss.ReadIdentities(SearchFactor.Sid, grp.Members, QueryMembership.None)
  6. .Where(identity => identity.Type == IdentityType.WindowsUser)
  7. .Select(identity => string.Format(@"{0}\{1}", identity.Domain, identity.AccountName))
  8. .ToArray();

No comments: