private WebApiBoard FindBoard(string workItemType, Models.Connection tpc, WebApiTeamProject tp, WebApiTeam team) { var boards = GetItems <WebApiBoard>(new { Board = "*", Team = team, Project = tp, Collection = tpc }).ToList(); foreach (WebApiBoard b in boards) { var keys = b.AllowedMappings.Values.SelectMany(o => o.Keys).ToList(); if (keys.Any(t => t.Equals(workItemType, StringComparison.OrdinalIgnoreCase))) { return(b); } } throw new Exception("Unable to find a board belonging to team " + $"'{team.Name}' that contains a mapping to the work item type '{workItemType}'"); }
public static void ListAllMembers() { // Interactively ask the user for credentials, caching them so the user isn't constantly prompted VssCredentials creds = new VssClientCredentials(); creds.Storage = new VssClientCredentialStorage(); // Connect to Azure DevOps Services connection = new VssConnection(new Uri(collectionUrl), creds); /* * ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>(); * TeamHttpClient teamClient = connection.GetClient<TeamHttpClient>(); * * IEnumerable<TeamProjectReference> projects = projectClient.GetProjects(top: 10000).Result; * * var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(collectionUrl)); * var ims = tpc.GetService<IIdentityManagementService>(); * //IGroupSecurityService gss = tpc.GetService<IGroupSecurityService>(); * IIdentityManagementService gss = tpc.GetService<IIdentityManagementService>();*/ Uri configurationServerUri = new Uri(serverUrl); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri); var tpcService = configurationServer.GetService <ITeamProjectCollectionService>(); string[,] members = new string[100000, 5]; int i = 0; foreach (Microsoft.TeamFoundation.Framework.Client.TeamProjectCollection tpc in tpcService.GetCollections()) { var tfsProjectCollection = new TfsTeamProjectCollection(new Uri(serverUrl + "/" + tpc.Name)); ProjectHttpClient projectClient = connection.GetClient <ProjectHttpClient>(); IEnumerable <TeamProjectReference> projects = projectClient.GetProjects(top: 10000).Result; List <TeamProjectReference> teamProjects = new List <TeamProjectReference>(projects); var sec = tfsProjectCollection.GetService <IGroupSecurityService>(); foreach (var teamProject in teamProjects) { Microsoft.TeamFoundation.Core.WebApi.TeamProject projectdet = projectClient.GetProject(teamProject.Name).Result; Uri proj = new Uri(teamProject.Url); var appGroups = sec.ListApplicationGroups(proj.AbsoluteUri);; foreach (var group in appGroups) { Identity[] groupMembers = sec.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded); foreach (Identity member in groupMembers) { if (member.Members != null) { foreach (string memberSid in member.Members) { Identity memberInfo = sec.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.Expanded); if (memberInfo.Type != IdentityType.WindowsUser) { continue; } members[i, 0] = tfsProjectCollection.Name; members[i, 1] = teamProject.Name; members[i, 2] = memberInfo.AccountName; members[i, 3] = memberInfo.Domain; members[i, 4] = group.DisplayName; Console.WriteLine(tfsProjectCollection.Name + " " + teamProject.Name + " " + memberInfo.AccountName + " " + memberInfo.DisplayName + " " + group.DisplayName); i++; } } } } } } /*string[,] members = new string[100000, 4]; * * int i = 0; * * foreach (var project in projects) * { * try * { * Identity[] appGroups = gss.ListApplicationGroups( .ListApplicationGroups(project.Url); * * foreach (var appGroup in appGroups) * { * * //string adminGroupName = "[" + project.Name.ToString() + "]" + "\\Project Administrators"; * //Identity SIDS = gss.ReadIdentity(SearchFactor.AccountName, adminGroupName, QueryMembership.Expanded); * * Identity SIDS = gss.ReadIdentity(SearchFactor.AccountName, appGroup.AccountName, QueryMembership.Expanded); * Identity[] userIds = gss.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.None); * * foreach (Identity id in userIds) * { * members[i, 0] = project.Name; * members[i, 1] = id.AccountName; * members[i, 2] = id.DisplayName; * members[i, 3] = appGroup.AccountName; * Console.WriteLine(project.Name + " " + id.AccountName + " " + id.DisplayName + " " +appGroup.AccountName); * i++; * } * Console.WriteLine("Number of total members: " + i); * } * } * catch (Exception ex) * { * members[i, 0] = project.Name; * members[i, 1] = "N/A"; * members[i, 2] = "N/A"; * members[i, 3] = "N/A"; * i++; * } * }*/ }
protected bool ShouldProcess(WebApiTeamProject target, string action) { return(Cmdlet.ShouldProcess($"Team Project '{target.Name}'", action)); }