Beispiel #1
0
        private void InvokeEhfDeleteCompanies()
        {
            if (this.companiesToDelete == null || this.companiesToDelete.Count == 0)
            {
                return;
            }
            CompanyResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Delete Company", delegate
            {
                responseSet = this.ProvisioningService.DeleteCompanies(this.companiesToDelete);
            }, this.companiesToDelete.Count);
            int num = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                CompanyResponseInfo companyResponseInfo = responseSet.ResponseInfo[i];
                EhfCompanyItem      ehfCompanyItem      = this.companiesToDelete[i];
                bool flag = false;
                if (companyResponseInfo.Status == ResponseStatus.Success)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully deleted EHF company: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        companyResponseInfo.CompanyGuid.Value,
                        companyResponseInfo.CompanyId
                    });
                    flag = true;
                }
                else if (companyResponseInfo.Fault.Id == FaultId.CompanyDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to delete a company that does not exist; ignoring the company: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        ehfCompanyItem.GetCompanyGuid(),
                        ehfCompanyItem.CompanyId
                    });
                    flag = true;
                }
                else
                {
                    this.HandleFailedCompany("Delete Company", ehfCompanyItem, companyResponseInfo, ref num, ref permanentFailureCount);
                    if (!ehfCompanyItem.ADEntry.IsDeleted && ehfCompanyItem.TryUpdateAdminSyncEnabledFlag(base.ADAdapter, true) == EhfADResultCode.Failure)
                    {
                        num++;
                    }
                }
                if (!ehfCompanyItem.ADEntry.IsDeleted && flag)
                {
                    if (ehfCompanyItem.TryClearEhfCompanyIdAndDisableAdminSync(base.ADAdapter) == EhfADResultCode.Failure)
                    {
                        num++;
                    }
                    else
                    {
                        this.RemoveCompanyItemFromCache(ehfCompanyItem);
                    }
                }
                if (!ehfCompanyItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    throw new InvalidOperationException("EventLogAndTryStoreSyncErrors() returned false for a deleted object");
                }
            }
            base.HandlePerEntryFailureCounts("Delete Company", this.companiesToDelete.Count, num, permanentFailureCount, false);
            this.companiesToDelete.Clear();
        }
Beispiel #2
0
        private void InvokeEhfUpdateCompanies()
        {
            if (this.companiesToUpdate == null || this.companiesToUpdate.Count == 0)
            {
                return;
            }
            CompanyResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Update Company", delegate
            {
                responseSet = this.ProvisioningService.UpdateCompanies(this.companiesToUpdate);
            }, this.companiesToUpdate.Count);
            int num = 0;
            int permanentFailureCount  = 0;
            List <EhfCompanyItem> list = new List <EhfCompanyItem>();

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                CompanyResponseInfo companyResponseInfo = responseSet.ResponseInfo[i];
                EhfCompanyItem      ehfCompanyItem      = this.companiesToUpdate[i];
                if (companyResponseInfo.Status == ResponseStatus.Success)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully updated EHF company: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        companyResponseInfo.CompanyGuid.Value,
                        companyResponseInfo.CompanyId
                    });
                    if (ehfCompanyItem.TryUpdateAdminSyncEnabledFlag(base.ADAdapter, false) != EhfADResultCode.Success)
                    {
                        num++;
                    }
                }
                else if (companyResponseInfo.Fault.Id == FaultId.CompanyDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to update a company that does not exists in EHF: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        ehfCompanyItem.GetCompanyGuid(),
                        companyResponseInfo.CompanyId
                    });
                    list.Add(ehfCompanyItem);
                }
                else
                {
                    this.HandleFailedCompany("Update Company", ehfCompanyItem, companyResponseInfo, ref num, ref permanentFailureCount);
                }
                if (!ehfCompanyItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    num++;
                }
            }
            base.HandlePerEntryFailureCounts("Create Company", this.companiesToUpdate.Count, num, permanentFailureCount, false);
            foreach (EhfCompanyItem ehfCompanyItem2 in this.companiesToUpdate)
            {
                if (ehfCompanyItem2.IsForcedDomainSyncRequired())
                {
                    this.EhfConfigConnection.AddDomainsForNewCompany(ehfCompanyItem2);
                }
            }
            this.companiesToUpdate.Clear();
            foreach (EhfCompanyItem ehfCompanyItem3 in list)
            {
                base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Trying to re-create the company <{0}>. CompanyId:<{1}>", new object[]
                {
                    ehfCompanyItem3.DistinguishedName,
                    ehfCompanyItem3.CompanyId
                });
                ehfCompanyItem3.ADEntry.Attributes.Remove("msExchTenantPerimeterSettingsOrgID");
                EhfCompanyItem company = EhfCompanyItem.CreateForActive(ehfCompanyItem3.ADEntry, base.DiagSession, base.Config.ResellerId);
                this.AddCompanyToCreateBatch(company);
            }
        }