Esempio n. 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();
        }
Esempio n. 2
0
        private void InvokeEhfDisableCompanies()
        {
            if (this.companiesToDisable == null || this.companiesToDisable.Count == 0)
            {
                return;
            }
            CompanyResponseInfoSet responseSet = null;

            base.InvokeProvisioningService("Disable Company", delegate
            {
                responseSet = this.ProvisioningService.DisableCompanies(this.companiesToDisable);
            }, this.companiesToDisable.Count);
            List <EhfCompanyItem> list = new List <EhfCompanyItem>(base.Config.EhfSyncAppConfig.BatchSize);
            int num = 0;
            int permanentFailureCount = 0;

            for (int i = 0; i < responseSet.ResponseInfo.Length; i++)
            {
                CompanyResponseInfo companyResponseInfo = responseSet.ResponseInfo[i];
                EhfCompanyItem      ehfCompanyItem      = this.companiesToDisable[i];
                if (companyResponseInfo.Status == ResponseStatus.Success)
                {
                    list.Add(ehfCompanyItem);
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully disabled EHF company: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        companyResponseInfo.CompanyGuid.Value,
                        companyResponseInfo.CompanyId
                    });
                }
                else if (companyResponseInfo.Fault.Id == FaultId.CompanyDoesNotExist)
                {
                    base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to disable a company that does not exist; ignoring the company: DN=<{0}>; GUID=<{1}>; EHF-ID=<{2}>", new object[]
                    {
                        ehfCompanyItem.DistinguishedName,
                        ehfCompanyItem.GetCompanyGuid(),
                        ehfCompanyItem.CompanyId
                    });
                    if (!ehfCompanyItem.ADEntry.IsDeleted)
                    {
                        if (ehfCompanyItem.TryClearEhfCompanyIdAndDisableAdminSync(base.ADAdapter) == EhfADResultCode.Failure)
                        {
                            num++;
                        }
                        else
                        {
                            this.RemoveCompanyItemFromCache(ehfCompanyItem);
                        }
                    }
                }
                else
                {
                    this.HandleFailedCompany("Disable Company", ehfCompanyItem, companyResponseInfo, ref num, ref permanentFailureCount);
                }
                if (!ehfCompanyItem.EventLogAndTryStoreSyncErrors(base.ADAdapter))
                {
                    throw new InvalidOperationException("EventLogAndTryStoreSyncErrors() returned false for a deleted object");
                }
            }
            base.HandlePerEntryFailureCounts("Disable Company", this.companiesToDisable.Count, num, permanentFailureCount, false);
            this.companiesToDisable.Clear();
            foreach (EhfCompanyItem ehfCompanyItem2 in list)
            {
                base.DiagSession.Tracer.TraceDebug <int, string>((long)base.DiagSession.GetHashCode(), "Adding disabled company ID=<{0}> DN=<{1}> to the delete batch", ehfCompanyItem2.CompanyId, ehfCompanyItem2.DistinguishedName);
                this.AddCompanyToDeleteBatch(ehfCompanyItem2);
            }
        }