Bo Johanson
Bo Johanson

Reputation: 59

VSTS list user's participation in projects

I'm the administrator of my company's VSTS account. From time to time, I need to map users and projects, i.e., to list the projects that a particular user is member of. In vain, I have looked in many of VSTS' nooks and crannies and searched the online documentation. I'm grateful for any suggestions.

Upvotes: 0

Views: 589

Answers (2)

starian chen-MSFT
starian chen-MSFT

Reputation: 33698

The other way is that you can achieve that through client SDK.

There is simple sample to obtain teams for specific user that you can refer to:

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri("[collection url]"));

            collection.EnsureAuthenticated();

           var structureService= collection.GetService<ICommonStructureService>();
            var teamprojects = structureService.ListAllProjects();
            TfsTeamService teamService = collection.GetService<TfsTeamService>();
            UserInfo user = new UserInfo();
            foreach (var tp in teamprojects)
            {

                var teamList = teamService.QueryTeams(tp.Uri);
                foreach(var t in teamList)
                {
                    var userIdentity = t.GetMembers(collection, MembershipQuery.Expanded).Where(ti=>ti.UniqueName.Equals("[user accunt, e.g. domain\\test]",StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if(userIdentity!=null)
                    {
                        user.Teams.Add(t.Name);
                        user.Alias = userIdentity.UniqueName;
                        user.DisplayName = userIdentity.DisplayName;
                    }
                }
            }
            Console.WriteLine(user);
            Console.Read();

Upvotes: 0

Luca Cappa
Luca Cappa

Reputation: 1989

If you are willing to leverage the VSTS REST APIs, you could:

Upvotes: 1

Related Questions