Esempio n. 1
0
        protected override void InternalProcessRecord()
        {
            if (this.Organization != null)
            {
                if (this.ehfService == null)
                {
                    this.globalSession = this.CreateGlobalSession();
                    EhfTargetServerConfig config = Utils.CreateEhfTargetConfig(this.globalSession, this.ConnectorId, this);
                    this.edgeSyncEhfConnector = Utils.GetConnector(this.globalSession, this.ConnectorId, this);
                    this.ehfService           = new EhfProvisioningService(config);
                }
                ExchangeConfigurationUnit currentOrganization  = this.GetCurrentOrganization(this.globalSession);
                ExchangeTenantRecord      exchangeTenantRecord = this.CreateExchangeTenantRecord(currentOrganization);
                EhfCompanyRecord          ehfCompanyRecord     = this.CreateEhfCompanyRecord(exchangeTenantRecord.PerimeterConfig);
                IList <object>            list = EhfSyncDiffRecord <object> .Compare(exchangeTenantRecord, ehfCompanyRecord);

                using (IEnumerator <object> enumerator = list.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object sendToPipeline = enumerator.Current;
                        base.WriteObject(sendToPipeline);
                    }
                    return;
                }
            }
            base.TestGeneralSyncHealth();
        }
        internal static IList <object> Compare(ExchangeTenantRecord exchangeTenantRecord, EhfCompanyRecord ehfCompanyRecord)
        {
            List <object> list = new List <object>();

            if (!exchangeTenantRecord.PerimeterConfig.EhfConfigSyncEnabled && ehfCompanyRecord == null)
            {
                return(list);
            }
            if (exchangeTenantRecord.PerimeterConfig.EhfConfigSyncEnabled && ehfCompanyRecord == null)
            {
                list.Add(new EhfSyncDiffRecord <SyncedPerimeterConfig>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "PerimeterConfig", exchangeTenantRecord.PerimeterConfig, null, null, exchangeTenantRecord.PerimeterConfig.SyncErrors));
                list.AddRange(EhfSyncDiffRecord <object> .CompareDomain(exchangeTenantRecord, ehfCompanyRecord));
            }
            if (!exchangeTenantRecord.PerimeterConfig.EhfConfigSyncEnabled && ehfCompanyRecord != null)
            {
                list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "Company ID", exchangeTenantRecord.CompanyId, ehfCompanyRecord.CompanyId));
                foreach (DomainSyncRecord actualObject in ehfCompanyRecord.Domains)
                {
                    list.Add(new EhfSyncDiffRecord <DomainSyncRecord>(exchangeTenantRecord.Organization.RawIdentity, null, EhfSyncObjectType.AcceptedDomain, string.Empty, null, actualObject));
                }
            }
            if (ehfCompanyRecord != null && exchangeTenantRecord.PerimeterConfig.EhfConfigSyncEnabled)
            {
                EhfSyncDiffRecord <IList <string> > item;
                if (EhfSyncDiffRecord <IList <string> > .TryGetEdgeSyncDiffRecord(exchangeTenantRecord.Organization, exchangeTenantRecord.PerimeterConfig, exchangeTenantRecord.GatewayIPAddresses, ehfCompanyRecord.GatewayIPAddresses, "GatewayIPAddresses", out item))
                {
                    list.Add(item);
                }
                EhfSyncDiffRecord <IList <string> > item2;
                if (EhfSyncDiffRecord <IList <string> > .TryGetEdgeSyncDiffRecord(exchangeTenantRecord.Organization, exchangeTenantRecord.PerimeterConfig, exchangeTenantRecord.InternalIPAddresses, ehfCompanyRecord.InternalIPAddresses, "InternalServerIPAddresses", out item2))
                {
                    list.Add(item2);
                }
                if (!exchangeTenantRecord.CompanyId.Equals(ehfCompanyRecord.CompanyId))
                {
                    list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "Company ID", exchangeTenantRecord.CompanyId, ehfCompanyRecord.CompanyId));
                }
                if (!exchangeTenantRecord.Guid.Equals(ehfCompanyRecord.Guid))
                {
                    list.Add(new EhfSyncDiffRecord <Guid>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "GUID", exchangeTenantRecord.Guid, ehfCompanyRecord.Guid));
                }
                if (!ehfCompanyRecord.CompanyName.EndsWith(exchangeTenantRecord.CompanyName))
                {
                    list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "Name", exchangeTenantRecord.CompanyName, ehfCompanyRecord.CompanyName));
                }
                if (exchangeTenantRecord.IPSkiplistingEnabled != ehfCompanyRecord.IPSkiplistingEnabled)
                {
                    list.Add(new EhfSyncDiffRecord <bool>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.PerimeterConfig.Identity, EhfSyncObjectType.PerimeterConfig, "IPSkiplistingEnabled", exchangeTenantRecord.IPSkiplistingEnabled, ehfCompanyRecord.IPSkiplistingEnabled));
                }
                list.AddRange(EhfSyncDiffRecord <object> .CompareDomain(exchangeTenantRecord, ehfCompanyRecord));
            }
            return(list);
        }
        private static IList <object> CompareDomain(ExchangeTenantRecord exchangeTenantRecord, EhfCompanyRecord ehfCompanyRecord)
        {
            List <object> list = new List <object>();

            if (ehfCompanyRecord != null)
            {
                IList <DomainSyncRecord> list2 = ehfCompanyRecord.Domains.Intersect(exchangeTenantRecord.Domains).ToList <DomainSyncRecord>();
                if (list2.Count != ehfCompanyRecord.Domains.Count || ehfCompanyRecord.Domains.Count != exchangeTenantRecord.Domains.Count)
                {
                    IList <DomainSyncRecord> list3 = exchangeTenantRecord.Domains.Except(ehfCompanyRecord.Domains).ToList <DomainSyncRecord>();
                    IList <DomainSyncRecord> list4 = ehfCompanyRecord.Domains.Except(exchangeTenantRecord.Domains).ToList <DomainSyncRecord>();
                    foreach (DomainSyncRecord domainSyncRecord in list3)
                    {
                        list.Add(new EhfSyncDiffRecord <DomainSyncRecord>(exchangeTenantRecord.Organization.RawIdentity, exchangeTenantRecord.AcceptedDomains[domainSyncRecord.Name].Identity, EhfSyncObjectType.AcceptedDomain, string.Empty, domainSyncRecord, null, null, exchangeTenantRecord.AcceptedDomains[domainSyncRecord.Name].SyncErrors));
                    }
                    if (list4.Count > 0)
                    {
                        foreach (DomainSyncRecord actualObject in list4)
                        {
                            list.Add(new EhfSyncDiffRecord <DomainSyncRecord>(exchangeTenantRecord.Organization.RawIdentity, null, EhfSyncObjectType.AcceptedDomain, string.Empty, null, actualObject));
                        }
                    }
                }
                using (IEnumerator <DomainSyncRecord> enumerator3 = list2.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        DomainSyncRecord     domainSyncRecord2    = enumerator3.Current;
                        SyncedAcceptedDomain syncedAcceptedDomain = exchangeTenantRecord.AcceptedDomains[domainSyncRecord2.Name];
                        if (!domainSyncRecord2.Enabled)
                        {
                            list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, syncedAcceptedDomain.Identity, EhfSyncObjectType.AcceptedDomain, "ENABLED", bool.TrueString, domainSyncRecord2.Enabled.ToString(), string.Empty, syncedAcceptedDomain.SyncErrors));
                        }
                        if (!domainSyncRecord2.Guid.Equals(syncedAcceptedDomain.Guid))
                        {
                            list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, syncedAcceptedDomain.Identity, EhfSyncObjectType.AcceptedDomain, "GUID", syncedAcceptedDomain.Guid.ToString(), domainSyncRecord2.Guid.ToString(), string.Empty, syncedAcceptedDomain.SyncErrors));
                        }
                    }
                    return(list);
                }
            }
            foreach (string text in exchangeTenantRecord.AcceptedDomains.Keys)
            {
                SyncedAcceptedDomain syncedAcceptedDomain2 = exchangeTenantRecord.AcceptedDomains[text];
                list.Add(new EhfSyncDiffRecord <string>(exchangeTenantRecord.Organization.RawIdentity, syncedAcceptedDomain2.Identity, EhfSyncObjectType.AcceptedDomain, string.Empty, text, string.Empty, string.Empty, syncedAcceptedDomain2.SyncErrors));
            }
            return(list);
        }