VS团队服务 - 安全报告提取在每个项目的角色中显示用户

时间:2017-03-30 18:20:27

标签: azure-devops

是否有办法针对Team Services中的安全设置运行报告,该报告将显示按角色和项目分组的所有用户?

1 个答案:

答案 0 :(得分:1)

没有报告在Team Services中显示用户/组。您可以参考下面的代码来检索必要的信息。

NetworkCredential cred = new NetworkCredential("XX", "XX");            
 string url = "https://XX.visualstudio.com/DefaultCollection";
TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(url), cred);
collection.EnsureAuthenticated();

           var structureService= collection.GetService<ICommonStructureService>();
            var teamprojects = structureService.ListAllProjects();
            TfsTeamService teamService = collection.GetService<TfsTeamService>();
            IGroupSecurityService gss = collection.GetService<IGroupSecurityService>();
foreach (var tp in teamprojects)
            {
                var teamList = teamService.QueryTeams(tp.Uri);
                foreach (var currentTeam in teamList)
                {
                    Identity[] appGroups = gss.ListApplicationGroups(currentTeam.Project);
                    foreach (var g in appGroups)
                    {
                        Identity[] groupMembers = gss.ReadIdentities(SearchFactor.Sid, new string[] { g.Sid }, QueryMembership.Expanded);
                   }
                }
  }

另一方面,有关于security的REST API可能对您有帮助。