// Token: 0x060010DE RID: 4318 RVA: 0x00062C18 File Offset: 0x00060E18
        internal int GetOrganizationMailboxCount()
        {
            this.Logger.TraceDebug(this, "GetOrganizationMailboxCount", new object[0]);
            ADUser[] array = OrganizationMailbox.FindByOrganizationId(this.OrgId, this.CapabilityRequiringScaling);
            int      num   = array.Length;

            this.Logger.TraceDebug(this, "GetOrganizationMailboxCount - Count='{0}'", new object[]
            {
                num
            });
            return(num);
        }
Ejemplo n.º 2
0
        private ADUser GetLocalOrganizationMailbox()
        {
            Server localServer = LocalServerCache.LocalServer;

            ADUser[] array = OrganizationMailbox.FindByOrganizationId(this.DataObject.OrganizationId, this.OrganizationCapability);
            foreach (ADUser aduser in array)
            {
                if (this.DataObject.Identity.Equals(aduser.Id))
                {
                    string activeServerFqdn = OrganizationMailbox.GetActiveServerFqdn(aduser.Id);
                    if (StringComparer.OrdinalIgnoreCase.Equals(localServer.Fqdn, activeServerFqdn))
                    {
                        return(aduser);
                    }
                }
            }
            base.WriteError(new LocalizedException(Strings.ErrorNoLocalOrganizationMailbox(this.DataObject.Identity.ToString())), ErrorCategory.ObjectNotFound, this.Identity);
            return(null);
        }
        private void TryCallE15()
        {
            ADUser[] array = null;
            if (OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled)
            {
                ADObjectId generatingMailbox = this.DataObject.GeneratingMailbox;
                if (generatingMailbox != null)
                {
                    ADUser aduser = (ADUser)base.GetDataObject <ADUser>(new MailboxIdParameter(generatingMailbox), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(generatingMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotUnique(generatingMailbox.ToString())));
                    array = new ADUser[]
                    {
                        aduser
                    };
                }
            }
            if (array == null)
            {
                array = OrganizationMailbox.FindByOrganizationId(this.DataObject.OrganizationId, OrganizationCapability.OABGen);
                if (array.Length == 0)
                {
                    if (this.ownerServer != null && this.ownerServer.VersionNumber >= Server.E15MinVersion)
                    {
                        base.WriteError(new LocalizedException(Strings.ErrorOabGenFailedSinceNoOrgMbxFound(this.DataObject.Identity.ToString())), ErrorCategory.ObjectNotFound, this.Identity);
                    }
                    return;
                }
            }
            bool flag = false;

            foreach (ADUser aduser2 in array)
            {
                string activeServerFqdn = OrganizationMailbox.GetActiveServerFqdn(aduser2.Id);
                string text             = null;
                try
                {
                    OABGeneratorAssistantRunNowParameters oabgeneratorAssistantRunNowParameters = new OABGeneratorAssistantRunNowParameters
                    {
                        PartitionId = this.DataObject.Id.GetPartitionId(),
                        ObjectGuid  = this.DataObject.Id.ObjectGuid,
                        Description = "from Update-OAB on Server:" + Environment.MachineName
                    };
                    AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(activeServerFqdn);
                    assistantsRpcClient.StartWithParams("OABGeneratorAssistant", aduser2.ExchangeGuid, aduser2.Database.ObjectGuid, oabgeneratorAssistantRunNowParameters.ToString());
                    flag = true;
                }
                catch (RpcException ex)
                {
                    text = RpcUtility.MapRpcErrorCodeToMessage(ex.ErrorCode, activeServerFqdn);
                }
                catch (COMException ex2)
                {
                    text = ex2.Message;
                }
                if (text != null)
                {
                    if (array.Length == 1)
                    {
                        base.WriteError(new LocalizedException(Strings.ErrorOabGenFailed(this.DataObject.Identity.ToString(), activeServerFqdn, text)), ErrorCategory.InvalidResult, this.Identity);
                    }
                    else
                    {
                        this.WriteWarning(Strings.WarningOabGenFailed(this.DataObject.Identity.ToString(), aduser2.Identity.ToString(), activeServerFqdn, text));
                    }
                }
            }
            if (array.Length > 1 && !flag)
            {
                base.WriteError(new LocalizedException(Strings.ErrorOabGenFailedForAllOrgMailboxes(this.DataObject.Identity.ToString())), ErrorCategory.InvalidResult, this.Identity);
            }
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (!string.IsNullOrEmpty(this.DataObject.TargetForest) || !string.IsNullOrEmpty(this.DataObject.RelocationSourceForestRaw))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorTenantAlreadyBeingRelocated(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if ((this.DataObject.OrganizationStatus != OrganizationStatus.Active && this.DataObject.OrganizationStatus != OrganizationStatus.Suspended && this.DataObject.OrganizationStatus != OrganizationStatus.LockedOut) || this.DataObject.IsUpdatingServicePlan)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorTenantNotInActiveOrgState(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (this.DataObject.EnableAsSharedConfiguration || this.DataObject.ImmutableConfiguration)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorSCTsCannotBeMigrated(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (this.DataObject.AdminDisplayVersion.ExchangeBuild < ExchangeObjectVersion.Exchange2012.ExchangeBuild)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorOldTenantsCannotBeMigrated(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            this.sourceAccountPartitionId = this.DataObject.OrganizationId.PartitionId;
            this.sourceForestFqdn         = this.sourceAccountPartitionId.ForestFQDN;
            Organization rootOrgContainer = ADSystemConfigurationSession.GetRootOrgContainer(this.sourceForestFqdn, null, null);

            if (!rootOrgContainer.TenantRelocationsAllowed)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorTenantRelocationNotAllowed(this.Identity.ToString(), this.sourceForestFqdn)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (TopologyProvider.LocalForestFqdn.Equals(this.TargetAccountPartition.RawIdentity, StringComparison.OrdinalIgnoreCase))
            {
                this.targetAccountPartitionFqdn = PartitionId.LocalForest.ForestFQDN;
            }
            else
            {
                AccountPartition accountPartition = (AccountPartition)base.GetDataObject <AccountPartition>(this.TargetAccountPartition, DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.SessionSettingsFactory.Default.FromRootOrgScopeSet(), 207, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs"), null, null, null);
                this.targetAccountPartitionFqdn = accountPartition.PartitionId.ForestFQDN;
            }
            if (this.targetAccountPartitionFqdn.IndexOf(PartitionId.LocalForest.ForestFQDN, StringComparison.InvariantCultureIgnoreCase) > 0)
            {
                this.targetAccountPartitionFqdn = PartitionId.LocalForest.ForestFQDN;
            }
            rootOrgContainer = ADSystemConfigurationSession.GetRootOrgContainer(this.targetAccountPartitionFqdn, null, null);
            if (!rootOrgContainer.TenantRelocationsAllowed)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorTenantRelocationNotAllowed(this.Identity.ToString(), this.targetAccountPartitionFqdn)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (!base.Fields.IsModified(TenantRelocationRequestSchema.AutoCompletionEnabled))
            {
                this.AutoCompletionEnabled = false;
            }
            if (this.AutoCompletionEnabled && base.Fields.IsModified(TenantRelocationRequestSchema.RelocationStateRequested))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorRelocationStateRequestedIsNotAllowed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (!this.AutoCompletionEnabled && !base.Fields.IsModified(TenantRelocationRequestSchema.RelocationStateRequested))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorRelocationStateRequestedIsMandatory(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            ADUser[] array = OrganizationMailbox.FindByOrganizationId(this.DataObject.OrganizationId, OrganizationCapability.Management);
            if (array.Length != 1)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorOneManagementOrgMailboxIsRequired(this.Identity.ToString(), array.Length.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            TenantOrganizationPresentationObject tenantOrganizationPresentationObject = new TenantOrganizationPresentationObject(this.DataObject);
            DateTime utcNow = DateTime.UtcNow;
            bool     config = TenantRelocationConfigImpl.GetConfig <bool>("IgnoreRelocationConstraintExpiration");

            foreach (RelocationConstraint relocationConstraint in tenantOrganizationPresentationObject.RelocationConstraints)
            {
                if (config || relocationConstraint.ExpirationDate > utcNow)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorRelocationConstraintsPresent(this.Identity.ToString(), relocationConstraint.Name)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            this.externalDirectoryOrganizationId = Guid.Parse(this.DataObject.ExternalDirectoryOrganizationId);
            if (!NewTenantRelocationRequest.GLSRecordCheckDisabled() && GlsMServDirectorySession.GlsLookupMode != GlsLookupMode.MServOnly)
            {
                string    text;
                string    text2;
                string    text3;
                Exception ex;
                bool      flag = GetTenantRelocationRequest.TryGlsLookupByExternalDirectoryOrganizationId(this.externalDirectoryOrganizationId, out text, out text2, out text3, out ex);
                if (ex != null)
                {
                    base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                if (!flag || string.IsNullOrEmpty(text2) || !text2.Equals(this.sourceForestFqdn, StringComparison.InvariantCultureIgnoreCase))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorUnexpectedAccountForestValueInGls(this.Identity.ToString(), text2, this.sourceForestFqdn)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            TaskLogger.LogExit();
        }