예제 #1
0
        // sometimes we have only the netbios name. Try to find if we know the FQDN
        private static void EnrichDomainInfo(HealthcheckDataCollection consolidation, HealthCheckTrustDomainInfoData di)
        {
            bool enriched = false;

            // search direct report
            foreach (HealthcheckData data in consolidation)
            {
                if (data.NetBIOSName.Equals(di.NetbiosName, StringComparison.InvariantCultureIgnoreCase))
                {
                    di.DnsName    = data.DomainFQDN;
                    di.ForestName = data.ForestFQDN;
                    break;
                }
                foreach (var trust in data.Trusts)
                {
                    // for old report: no netbios name defined in domain object !
                    string[] values  = trust.TrustPartner.Split('.');
                    string   netbios = values[0];
                    if (!String.IsNullOrEmpty(trust.NetBiosName))
                    {
                        netbios = trust.NetBiosName;
                    }
                    if (netbios.Equals(di.NetbiosName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        di.DnsName = trust.TrustPartner;
                        // unknown forest name
                        enriched = true;
                        break;
                    }
                    foreach (var forestinfo in trust.KnownDomains)
                    {
                        if (!String.IsNullOrEmpty(forestinfo.NetbiosName) && forestinfo.NetbiosName.Equals(di.NetbiosName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            di.DnsName    = forestinfo.DnsName;
                            di.ForestName = trust.TrustPartner;
                            enriched      = true;
                            break;
                        }
                    }
                    if (enriched)
                    {
                        break;
                    }
                }
                if (enriched)
                {
                    break;
                }
            }
        }
예제 #2
0
        public HealthcheckDataCollection GetDataReportAtDate(DateTime dateToIssueReport)
        {
            var output = new HealthcheckDataCollection();

            foreach (var sid in data.Keys)
            {
                DateTime min = DateTime.MinValue;
                foreach (var date in data[sid].Keys)
                {
                    if (date > min && date <= dateToIssueReport)
                    {
                        min = date;
                    }
                }
                if (min != DateTime.MinValue)
                {
                    output.Add(data[sid][min]);
                }
            }
            return(output);
        }
예제 #3
0
        static public GraphNodeCollection BuildModel(HealthcheckDataCollection consolidation, OwnerInformationReferences EntityData)
        {
            GraphNodeCollection nodes = new GraphNodeCollection();

            // build links based on the most to the less reliable information
            Trace.WriteLine("Building model");
            int nodeNumber = 0;

            Trace.WriteLine("domain reports");
            // enumerate official domains
            foreach (HealthcheckData data in consolidation)
            {
                GraphNode node = nodes.CreateNodeIfNeeded(ref nodeNumber, data.Domain, data.NetBIOSName, data.GenerationDate);
                node.HealthCheckData = data;
                node.SetForest(data.Forest);
            }
            Trace.WriteLine("direct trust");
            // get trust map based on direct trusts data
            foreach (HealthcheckData data in consolidation)
            {
                GraphNode source = nodes.Locate(data);
                foreach (var trust in data.Trusts)
                {
                    GraphNode destination = nodes.CreateNodeIfNeeded(ref nodeNumber, trust.Domain, trust.NetBiosName, data.GenerationDate);
                    source.Link(destination, trust);
                }
            }
            Trace.WriteLine("forest trust");
            foreach (HealthcheckData data in consolidation)
            {
                foreach (var trust in data.Trusts)
                {
                    // do not examine if we have more accurate information (aka the forest report)
                    if (consolidation.GetDomain(trust.Domain) != null)
                    {
                        continue;
                    }
                    if (trust.KnownDomains != null)
                    {
                        GraphNode source = nodes.Locate(trust);
                        foreach (var domainInfo in trust.KnownDomains)
                        {
                            GraphNode destination = nodes.CreateNodeIfNeeded(ref nodeNumber, domainInfo.Domain, domainInfo.NetbiosName, data.GenerationDate);
                            source.LinkInsideAForest(destination, domainInfo.CreationDate);
                            destination.SetForest(domainInfo.Forest);
                        }
                    }
                }
            }
            Trace.WriteLine("Building reachable links");
            // make links based on reachable domains. Information is less reliable.
            foreach (HealthcheckData data in consolidation)
            {
                // ignore report without reachable domains
                if (data.ReachableDomains == null)
                {
                    continue;
                }
                // ignore reachable links if we have the forest domain report
                if (consolidation.GetDomain(data.Forest) != null)
                {
                    continue;
                }
                foreach (HealthCheckTrustDomainInfoData di in data.ReachableDomains)
                {
                    // domain info can contain only netbios name (not FQDN)
                    // enrich it
                    if (di.NetbiosName.Equals(di.DnsName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        EnrichDomainInfo(consolidation, di);
                    }
                    // if no information was given (only Netbios name!) fallback to a forest trust
                    if (String.IsNullOrEmpty(di.ForestName))
                    {
                        di.ForestName = di.DnsName;
                    }
                    // ignore the domain if the forest trust is known (information should be already there)
                    if (consolidation.GetDomain(di.Forest) != null)
                    {
                        continue;
                    }

                    // add the forest trust if needed
                    GraphNode remoteForestRoot = nodes.CreateNodeIfNeeded(ref nodeNumber, di.Forest, di.ForestNetbios, data.GenerationDate);
                    remoteForestRoot.SetForest(remoteForestRoot.Domain);

                    // add the forest root if needed
                    GraphNode myForestRoot = nodes.CreateNodeIfNeeded(ref nodeNumber, data.Forest, null, data.GenerationDate);
                    myForestRoot.LinkTwoForests(remoteForestRoot);
                    myForestRoot.SetForest(myForestRoot.Domain);
                    // add the trust if the domain is a child of the forest)
                    // (ignore the trust if forest root = trust)
                    if (di.ForestName.Equals(di.DnsName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    GraphNode childDomain = nodes.CreateNodeIfNeeded(ref nodeNumber, di.Domain, di.NetbiosName, data.GenerationDate);
                    remoteForestRoot.LinkInsideAForest(childDomain);
                    childDomain.SetForest(remoteForestRoot.Domain);
                }
            }
            Trace.WriteLine("enrich forest information");
            nodes.EnrichForestInformation();
            Trace.WriteLine("done");
            nodes.EnrichEntity(EntityData);
            nodes.RemoveDeletedNodes();
            return(nodes);
        }
예제 #4
0
 public HealthCheckReportMapBuilder(HealthcheckDataCollection consolidation) : this(consolidation, null)
 {
 }
예제 #5
0
 public HealthCheckReportMapBuilder(HealthcheckDataCollection consolidation, OwnerInformationReferences ownerInformationReferences)
 {
     this.consolidation = consolidation;
     EntityData         = ownerInformationReferences;
     FullNodeMap        = true;
 }