Sunday, January 8, 2012

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

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

No comments: