public override void HandleDeletedDomain(ExSearchResultEntry entry)
        {
            base.HandleDeletedDomain(entry);
            EhfDomainItem domain = EhfDomainItemVersion2.CreateForOutboundOnlyTombstone(entry, base.DiagSession);

            base.AddDomainToDisableBatch(domain);
        }
        private void CreateEhfDomainForNewCompany(ExSearchResultEntry entry, int ehfCompanyId)
        {
            EhfDomainItem ehfDomainItem = this.CreateDomainItemForNewCompany(entry, ehfCompanyId);

            if (ehfDomainItem == null)
            {
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Ignoring domain <{0}> for newly-created EHF company <{1}>", new object[]
                {
                    entry.DistinguishedName,
                    ehfCompanyId
                });
                return;
            }
            if (!EhfDomainSynchronizer.ValidateDomainName(entry, base.DiagSession))
            {
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Ignoring unsupported domain <{0}> for newly-created EHF company <{1}>", new object[]
                {
                    entry.DistinguishedName,
                    ehfCompanyId
                });
                return;
            }
            base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Creating domain <{0}> for newly-created EHF company <{1}>", new object[]
            {
                entry.DistinguishedName,
                ehfCompanyId
            });
            this.AddDomainToCreateBatch(ehfDomainItem);
        }
        protected void HandleFailedDomain(string operationName, EhfDomainItem domain, DomainResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount)
        {
            if (response.Status == ResponseStatus.TransientFailure)
            {
                transientFailureCount++;
            }
            else
            {
                permanentFailureCount++;
            }
            string       responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response);
            EdgeSyncDiag diagSession   = base.DiagSession;
            string       messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); Name={7}; AD-GUID=({8}); EHF-GUID=({9}); EHF-Company-ID={10}";

            object[] array = new object[11];
            array[0] = operationName;
            array[1] = response.Fault.Id;
            array[2] = response.Status;
            array[3] = (response.Fault.Detail ?? "null");
            array[4] = response.Target;
            array[5] = responseTargetValuesString;
            array[6] = domain.DistinguishedName;
            array[7] = domain.Name;
            array[8] = domain.GetDomainGuid();
            object[] array2     = array;
            int      num        = 9;
            Guid?    domainGuid = response.DomainGuid;

            array2[num] = ((domainGuid != null) ? domainGuid.GetValueOrDefault() : "null");
            array[10]   = domain.Domain.CompanyId;
            domain.AddSyncError(diagSession.LogAndTraceError(messageFormat, array));
        }
Пример #4
0
        public static EhfDomainItem CreateForOutboundOnlyTombstone(ExSearchResultEntry entry, EdgeSyncDiag diagSession)
        {
            EhfDomainItem ehfDomainItem = EhfDomainItem.CreateForTombstone(entry, diagSession);

            ehfDomainItem.Domain.Name = AcceptedDomain.FormatEhfOutboundOnlyDomainName(ehfDomainItem.Domain.Name, ehfDomainItem.Domain.DomainGuid.Value);
            return(ehfDomainItem);
        }
Пример #5
0
        public static EhfDomainItem CreateIfAuthoritative(ExSearchResultEntry entry, int ehfCompanyId, EdgeSyncDiag diagSession)
        {
            EhfDomainItem ehfDomainItem = new EhfDomainItem(entry, ehfCompanyId, diagSession);

            if (ehfDomainItem.AcceptedDomainType != AcceptedDomainType.Authoritative)
            {
                return(null);
            }
            return(ehfDomainItem);
        }
        public void CreateOrDeleteEhfDomain(ExSearchResultEntry entry)
        {
            EhfDomainItem ehfDomainItem = EhfDomainItem.CreateForActive(entry, base.DiagSession);

            if (ehfDomainItem.AcceptedDomainType == AcceptedDomainType.Authoritative)
            {
                this.AddDomainToCreateBatch(ehfDomainItem);
                return;
            }
            this.AddDomainToDisableBatch(ehfDomainItem);
        }
 protected void AddDomainToCreateBatch(EhfDomainItem domain)
 {
     base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Adding domain <{0}> to Create batch", new object[]
     {
         domain.DistinguishedName
     });
     if (base.AddItemToBatch <EhfDomainItem>(domain, ref this.domainsToCreate))
     {
         this.InvokeEhfCreateDomains();
     }
 }
Пример #8
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
                        });
                    }
                }
            }
        }
        private void InvokeEhfDeleteDomains()
        {
            if (this.domainsToDelete == null || this.domainsToDelete.Count == 0)
            {
                return;
            }
            DomainResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Delete Domain", delegate
            {
                responseSet = this.ProvisioningService.DeleteDomains(this.domainsToDelete);
            }, this.domainsToDelete.Count);
            int transientFailureCount = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = this.domainsToDelete[i];
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully deleted EHF domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that does not exist; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company under this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.AccessDenied)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a domain that belongs to a different company outside of this reseller; ignoring the domain: DN=<{0}>; GUID=<{1}>; EHF-Company-ID=<{2}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.GetDomainGuid(),
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else
                {
                    this.HandleFailedDomain("Delete Domain", ehfDomainItem, domainResponseInfo, ref transientFailureCount, ref permanentFailureCount);
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    throw new InvalidOperationException("EventLogAndTryStoreSyncErrors() returned false for a deleted object");
                }
            }
            base.HandlePerEntryFailureCounts("Delete Domain", this.domainsToDelete.Count, transientFailureCount, permanentFailureCount, false);
            this.domainsToDelete.Clear();
        }
        public void DeleteEhfDomain(ExSearchResultEntry entry)
        {
            EhfDomainItem domain = EhfDomainItem.CreateForTombstone(entry, base.DiagSession);

            this.AddDomainToDisableBatch(domain);
        }
        protected virtual void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate)
        {
            int num = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i];
                EhfDomainItem      ehfDomainItem      = domainsTriedToCreate[i];
                bool flag = false;
                if (domainResponseInfo.Status == ResponseStatus.Success)
                {
                    flag = true;
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                    {
                        ehfDomainItem.DistinguishedName,
                        ehfDomainItem.Domain.Name,
                        domainResponseInfo.DomainGuid.Value,
                        ehfDomainItem.Domain.CompanyId
                    });
                }
                else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany)
                {
                    Guid domainGuid = ehfDomainItem.GetDomainGuid();
                    if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid))
                    {
                        flag = true;
                        base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[]
                        {
                            ehfDomainItem.DistinguishedName,
                            ehfDomainItem.Domain.Name,
                            domainGuid,
                            ehfDomainItem.Domain.CompanyId
                        });
                    }
                    else if (!this.handledAllDeletedDomains)
                    {
                        base.AddItemToLazyList <EhfDomainItem>(ehfDomainItem, ref this.domainsToCreateLast);
                        EdgeSyncDiag         diagSession = base.DiagSession;
                        EdgeSyncLoggingLevel level       = EdgeSyncLoggingLevel.Low;
                        string   messageFormat           = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>";
                        object[] array = new object[5];
                        array[0] = ehfDomainItem.DistinguishedName;
                        array[1] = ehfDomainItem.Name;
                        array[2] = domainGuid;
                        object[] array2      = array;
                        int      num2        = 3;
                        Guid?    domainGuid2 = domainResponseInfo.DomainGuid;
                        array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null");
                        array[4]     = ehfDomainItem.Domain.CompanyId;
                        diagSession.LogAndTraceInfo(level, messageFormat, array);
                    }
                    else
                    {
                        this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                    }
                }
                else
                {
                    this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount);
                }
                if (flag && ehfDomainItem.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure)
                {
                    num++;
                }
                if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    num++;
                }
            }
            base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false);
        }
 protected virtual EhfDomainItem CreateDomainItemForNewCompany(ExSearchResultEntry entry, int ehfCompanyId)
 {
     return(EhfDomainItem.CreateIfAuthoritative(entry, ehfCompanyId, base.DiagSession));
 }
 protected void AddDomainToCreateLastList(EhfDomainItem domain)
 {
     base.AddItemToLazyList <EhfDomainItem>(domain, ref this.domainsToCreateLast);
 }