internal static bool CanProceedWithOrganizationTask(OrganizationIdParameter orgIdParam, IConfigurationSession session, OrganizationStatus[] ignorableFlagsOnStatusTimeout, Task.TaskErrorLoggingDelegate errorLogger) { bool result = false; ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true); if (ExchangeConfigurationUnit.IsOrganizationActive(exchangeConfigUnitFromOrganizationId.OrganizationStatus)) { result = true; } else { DateTime?whenOrganizationStatusSet = exchangeConfigUnitFromOrganizationId.WhenOrganizationStatusSet; if (whenOrganizationStatusSet != null) { DateTime value = whenOrganizationStatusSet.Value.ToUniversalTime(); if (DateTime.UtcNow.Subtract(value) > OrganizationTaskHelper.organizationStatusTimeout && ignorableFlagsOnStatusTimeout != null) { foreach (OrganizationStatus organizationStatus in ignorableFlagsOnStatusTimeout) { if (organizationStatus == exchangeConfigUnitFromOrganizationId.OrganizationStatus) { result = true; break; } } } } } return(result); }
protected void LoadTenantCU() { this.tenantCU = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.orgIdParam, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true); if (this.tenantCU != null) { base.CurrentOrganizationId = this.tenantCU.OrganizationId; } }
private OrganizationId ResolveCurrentOrganization() { base.Session = this.CreateSession(); if (!OrganizationTaskHelper.CanProceedWithOrganizationTask(this.Organization, base.Session, AddSecondaryDomainTask.IgnorableFlagsOnStatusTimeout, new Task.TaskErrorLoggingDelegate(base.WriteError))) { base.WriteError(new OrganizationPendingOperationException(Strings.ErrorCannotOperateOnOrgInCurrentState), ErrorCategory.InvalidOperation, null); } base.Session.UseConfigNC = false; ADOrganizationalUnit oufromOrganizationId = OrganizationTaskHelper.GetOUFromOrganizationId(this.Organization, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true); base.Session.UseConfigNC = true; this.TenantCU = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.Organization, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true); base.Fields["TenantExternalDirectoryOrganizationId"] = this.TenantCU.ExternalDirectoryOrganizationId; return(oufromOrganizationId.OrganizationId); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); base.Fields["PrimaryOrganization"] = this.acceptedDomain.OrganizationId.OrganizationalUnit.DistinguishedName; base.Fields["SecondarySmtpDomainName"] = this.acceptedDomain.DomainName.ToString(); ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(this.organizationIdParam, base.Session, new Task.TaskErrorLoggingDelegate(base.WriteError), true); base.Fields["TenantExternalDirectoryOrganizationId"] = exchangeConfigUnitFromOrganizationId.ExternalDirectoryOrganizationId; IConfigurationSession session = (IConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(base.Session, exchangeConfigUnitFromOrganizationId.OrganizationId, true); if (exchangeConfigUnitFromOrganizationId.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainAddition || exchangeConfigUnitFromOrganizationId.OrganizationStatus == OrganizationStatus.PendingAcceptedDomainRemoval) { OrganizationTaskHelper.SetOrganizationStatus(this.organizationIdParam, session, OrganizationStatus.Active, new Task.TaskErrorLoggingDelegate(base.WriteError)); } base.InternalProcessRecord(); TaskLogger.LogExit(); }
internal static OrganizationStatus SetOrganizationStatus(OrganizationIdParameter orgIdParam, IConfigurationSession session, OrganizationStatus statusToSet, Task.TaskErrorLoggingDelegate errorLogger) { ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true); OrganizationStatus organizationStatus = exchangeConfigUnitFromOrganizationId.OrganizationStatus; if (statusToSet != organizationStatus) { bool useConfigNC = session.UseConfigNC; try { session.UseConfigNC = true; exchangeConfigUnitFromOrganizationId.OrganizationStatus = statusToSet; session.Save(exchangeConfigUnitFromOrganizationId); } finally { session.UseConfigNC = useConfigNC; } } return(organizationStatus); }
internal static OrganizationStatus GetOrganizationStatus(OrganizationIdParameter orgIdParam, IConfigurationSession session, Task.TaskErrorLoggingDelegate errorLogger) { ExchangeConfigurationUnit exchangeConfigUnitFromOrganizationId = OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId(orgIdParam, session, errorLogger, true); return(exchangeConfigUnitFromOrganizationId.OrganizationStatus); }