private static void ExpandContainers(string parentIdentityNameGraphId, string identityDisplayName, string accessEntryDescription, DirectedGraph directedGraph)
        {
            TeamFoundationIdentity identity;

            TeamProjectScanner.DisplayNameToIdentity.TryGetValue(identityDisplayName, out identity);
            if (identity == null)
            {
                return; // Skip unknown identities
            }
            string identityNameGraphId = parentIdentityNameGraphId + "_" + identity.UniqueName;
            string identityCategory    = identity.Category();
            string groupState          = (identity.IsContainer) ? "Expanded" : null;
            string label = identityDisplayName + " " + accessEntryDescription;

            if (identity.IsContainer)
            {
                directedGraph.AddNode(identityNameGraphId, label, identityCategory, null, groupState, new Tuple <string, string>("MaxWidth", "300"));
            }
            else
            {
                directedGraph.AddNode(identityNameGraphId, label, identityCategory, null, groupState);
            }
            directedGraph.AddLink(parentIdentityNameGraphId, identityNameGraphId, "Contains");

            foreach (TeamFoundationIdentity childIdentity in identity.Children())
            {
                TeamProjectScanner.ExpandContainers(identityNameGraphId, childIdentity.DisplayName, string.Empty, directedGraph);
            }
        }
Esempio n. 2
0
        public XDocument GenerateDependencyGraph(TfsTeamProjectCollection tfsTeamProjectCollection, IEnumerable <ProjectInfo> projectInfoArray)
        {
            DirectedGraph directedGraph = new DirectedGraph();

            foreach (ProjectInfo projectInfo in projectInfoArray)
            {
                TeamProjectScanner.ScanUsers(tfsTeamProjectCollection, projectInfo);
                TeamProjectScanner.ScanPermissions(tfsTeamProjectCollection, projectInfo, directedGraph);
            }
            return(directedGraph.ProduceGraph());
        }
        public static void ScanPermissions(TfsTeamProjectCollection tfsTeamProjectCollection, ProjectInfo projectInfo, DirectedGraph directedGraph)
        {
            VersionControlServer vcs = tfsTeamProjectCollection.GetService <VersionControlServer>();

            TeamProject[] teamProjects = vcs.GetAllTeamProjects(true);
            TeamProject   teamProject  = teamProjects.ToList().FirstOrDefault(tp => tp.Name == projectInfo.Name);

            if (teamProject == null)
            {
                return;
            }

            ItemSecurity[] itemSecurityArray = vcs.GetPermissions(new string[] { teamProject.ServerItem }, RecursionType.Full);

            foreach (ItemSecurity itemSecurity in itemSecurityArray)
            {
                string vcsPath        = itemSecurity.ServerItem;
                string vcsPathGraphId = "vcsPath_" + vcsPath;
                directedGraph.AddNode(vcsPathGraphId, vcsPath, "Version Control Folder", null, "Expanded");

                foreach (AccessEntry accessEntry in itemSecurity.Entries)
                {
                    string[] accessEntryArray = new string[4]
                    {
                        accessEntry.Allow.Length > 0 ? "Allow: " + string.Join(", ", accessEntry.Allow) + " " : string.Empty,
                        accessEntry.AllowInherited.Length > 0
                            ? "Allow Inherited: " + string.Join(", ", accessEntry.AllowInherited) + " "
                            : string.Empty,
                        accessEntry.Deny.Length > 0 ? "Deny: " + string.Join(", ", accessEntry.Deny) + " " : string.Empty,
                        accessEntry.DenyInherited.Length > 0
                            ? "Deny Inherited: " + string.Join(", ", accessEntry.DenyInherited) + " "
                            : string.Empty
                    };

                    string accessEntryDescription = string.Join(" ", accessEntryArray);
                    string identityDisplayName    = accessEntry.IdentityName;
                    TeamProjectScanner.ExpandContainers(vcsPathGraphId /*accessEntryGraphId*/, identityDisplayName, accessEntryDescription, directedGraph);
                }
            }
        }