Esempio n. 1
0
        public EhfADResultCode TryClearForceDomainSyncFlagFromPerimeterConfig(EhfADAdapter adAdapter)
        {
            if (!this.clearForceDomainSyncFlag)
            {
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "Domain <{0}> does not have [clearForceDomainSyncFlag] set. Not clearing the forceDomainSync flag", new object[]
                {
                    base.DistinguishedName
                });
                return(EhfADResultCode.Success);
            }
            Guid entryCompanyGuid = this.GetEntryCompanyGuid();

            base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Clearing the force-domainsync flag set on the perimeterconfig with Guid <{0}> for domain <{1}>.", new object[]
            {
                entryCompanyGuid,
                base.DistinguishedName
            });
            try
            {
                EhfDomainItem.ClearForceDomainSyncFlagFromPerimeterConfig(adAdapter, entryCompanyGuid);
            }
            catch (ExDirectoryException ex)
            {
                if (ex.ResultCode == ResultCode.NoSuchObject)
                {
                    base.DiagSession.LogAndTraceException(ex, "NoSuchObject error occurred while trying to clear the ForceDomainSync flag in Perimeter Settings for domain <{0}>:<{1}>", new object[]
                    {
                        base.DistinguishedName,
                        entryCompanyGuid
                    });
                    return(EhfADResultCode.NoSuchObject);
                }
                base.DiagSession.LogAndTraceException(ex, "Exception occurred while trying to clear the ForceDomainSync flag in Perimeter Settings for domain <{0}>:<{1}>", new object[]
                {
                    base.DistinguishedName,
                    entryCompanyGuid
                });
                base.DiagSession.EventLog.LogEvent(EdgeSyncEventLogConstants.Tuple_EhfFailedToClearForceDomainSyncFlagFromDomainSync, null, new object[]
                {
                    base.DistinguishedName,
                    ex.Message
                });
                return(EhfADResultCode.Failure);
            }
            return(EhfADResultCode.Success);
        }
        public void CreateEhfDomainsForNewCompany(string transportSettingsDN, int ehfCompanyId, Guid ehfCompanyGuid)
        {
            if (ehfCompanyGuid == Guid.Empty)
            {
                throw new ArgumentException("Ehf company Guid is empty for company " + transportSettingsDN, "ehfCompanyGuid");
            }
            IEnumerable <ExSearchResultEntry> enumerable = base.ADAdapter.PagedScan(transportSettingsDN, Schema.Query.QueryAcceptedDomains, EhfDomainSynchronizer.AcceptedDomainAllAttributes);

            foreach (ExSearchResultEntry entry in enumerable)
            {
                EhfDomainSynchronizer.AddAttributeToChangeEntry(entry, "msEdgeSyncEhfCompanyGuid", ehfCompanyGuid.ToString());
                this.CreateEhfDomainForNewCompany(entry, ehfCompanyId);
            }
            if (!this.SetForcedDomainSyncOnLastDomain(ehfCompanyGuid))
            {
                try
                {
                    EhfDomainItem.ClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter, ehfCompanyGuid);
                }
                catch (ExDirectoryException ex)
                {
                    if (ex.ResultCode == ResultCode.NoSuchObject)
                    {
                        base.DiagSession.LogAndTraceException(ex, "NoSuchObject error occurred while trying to clear the ForceDomainSync flag in Perimeter Settings for Company <{0}>:<{1}>", new object[]
                        {
                            transportSettingsDN,
                            ehfCompanyGuid
                        });
                    }
                    else
                    {
                        base.DiagSession.LogAndTraceException(ex, "Exception occurred while trying to clear the ForceDomainSync flag in Perimeter Settings for company <{0}>:<{1}>", new object[]
                        {
                            transportSettingsDN,
                            ehfCompanyGuid
                        });
                        base.DiagSession.EventLog.LogEvent(EdgeSyncEventLogConstants.Tuple_EhfFailedToClearForceDomainSyncFlagFromCompanySync, null, new object[]
                        {
                            transportSettingsDN,
                            ex.Message
                        });
                    }
                }
            }
        }