// Token: 0x06000C75 RID: 3189 RVA: 0x00027247 File Offset: 0x00025447
 public TenantRelocationRequestIdParameter(TenantRelocationRequest tenant) : this(tenant.Name)
 {
 }
コード例 #2
0
        private static TenantRelocationState LoadTenantRelocationState(string tenantName, PartitionId partitionId)
        {
            ITenantConfigurationSession session = DirectorySessionFactory.NonCacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 185, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
            ExchangeConfigurationUnit   exchangeCUAndThrowIfNotFound = TenantRelocationStateCache.GetExchangeCUAndThrowIfNotFound(tenantName, session);

            if (exchangeCUAndThrowIfNotFound.IsCached)
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Tenant {0} found in cache.", tenantName);
                if ((DateTime.UtcNow - exchangeCUAndThrowIfNotFound.WhenReadUTC).Value.TotalSeconds >= 30.0)
                {
                    ITenantConfigurationSession session2 = DirectorySessionFactory.NonCacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 203, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
                    exchangeCUAndThrowIfNotFound = TenantRelocationStateCache.GetExchangeCUAndThrowIfNotFound(tenantName, session2);
                    ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.CacheSessionFactory.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 206, "LoadTenantRelocationState", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RelocationCache\\TenantRelocationStateCache.cs");
                    tenantConfigurationSession.Delete(exchangeCUAndThrowIfNotFound);
                    tenantConfigurationSession.Save(exchangeCUAndThrowIfNotFound);
                }
            }
            if ((string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest) && string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw)) || (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw) && exchangeCUAndThrowIfNotFound.RelocationStateRequested == RelocationStateRequested.Cleanup))
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string, bool>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} Cached {2} - not being relocated.", tenantName, exchangeCUAndThrowIfNotFound.OriginatingServer, exchangeCUAndThrowIfNotFound.IsCached);
                return(new TenantRelocationState(partitionId.ForestFQDN, TenantRelocationStatus.NotStarted));
            }
            if (string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId))
            {
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string, bool>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} Cached {2} - prepared for deletion.", tenantName, exchangeCUAndThrowIfNotFound.OriginatingServer, exchangeCUAndThrowIfNotFound.IsCached);
                TenantRelocationStatus sourceForestState;
                if (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest))
                {
                    sourceForestState = exchangeCUAndThrowIfNotFound.RelocationStatus;
                }
                else
                {
                    sourceForestState = TenantRelocationStatus.NotStarted;
                }
                return(new TenantRelocationState(partitionId.ForestFQDN, sourceForestState));
            }
            if (!string.IsNullOrEmpty(exchangeCUAndThrowIfNotFound.TargetForest))
            {
                TenantRelocationRequest tenantRelocationRequest;
                Exception ex;
                TenantRelocationRequest.LoadOtherForestObjectInternal(null, exchangeCUAndThrowIfNotFound.TargetForest, exchangeCUAndThrowIfNotFound.DistinguishedName, exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId, true, out tenantRelocationRequest, out ex);
                if (ex != null && !(ex is CannotFindTargetTenantException))
                {
                    throw ex;
                }
                ExTraceGlobals.TenantRelocationTracer.TraceDebug <string, string>(0L, "TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} - this is relocation source.", tenantName, (tenantRelocationRequest != null) ? tenantRelocationRequest.OriginatingServer : "<unknown>");
                return(new TenantRelocationState(partitionId.ForestFQDN, exchangeCUAndThrowIfNotFound.RelocationStatus, exchangeCUAndThrowIfNotFound.TargetForest, (RelocationStatusDetailsDestination)((tenantRelocationRequest != null) ? tenantRelocationRequest.RelocationStatusDetailsRaw : RelocationStatusDetails.NotStarted), exchangeCUAndThrowIfNotFound.OrganizationId, (tenantRelocationRequest != null) ? tenantRelocationRequest.OrganizationId : null));
            }
            else
            {
                Exception ex;
                TenantRelocationRequest tenantRelocationRequest2;
                TenantRelocationRequest.LoadOtherForestObjectInternal(null, exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw, exchangeCUAndThrowIfNotFound.DistinguishedName, exchangeCUAndThrowIfNotFound.ExternalDirectoryOrganizationId, false, out tenantRelocationRequest2, out ex);
                if (ex == null)
                {
                    ExTraceGlobals.TenantRelocationTracer.TraceDebug(0L, string.Format("TenantRelocationStateCache::LoadTenantRelocationState(): Found tenant {0} on DC {1} - this is relocation target.", tenantName, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.OriginatingServer : "<unknown>"));
                    return(new TenantRelocationState(exchangeCUAndThrowIfNotFound.RelocationSourceForestRaw, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.RelocationStatus : TenantRelocationStatus.NotStarted, partitionId.ForestFQDN, (RelocationStatusDetailsDestination)exchangeCUAndThrowIfNotFound.RelocationStatusDetailsSource, (tenantRelocationRequest2 != null) ? tenantRelocationRequest2.OrganizationId : null, exchangeCUAndThrowIfNotFound.OrganizationId));
                }
                if (ex is CannotFindTargetTenantException)
                {
                    return(new TenantRelocationState(partitionId.ForestFQDN, TenantRelocationStatus.NotStarted));
                }
                throw ex;
            }
        }
コード例 #3
0
        public static IEnumerable <TenantRelocationRequest> FindPagedStaleLockedRelocationRequests(ExDateTime olderThan)
        {
            QueryFilter staleLockedRelocationRequestsFilter = TenantRelocationRequest.GetStaleLockedRelocationRequestsFilter(olderThan, true);

            return(PartitionDataAggregator.FindPaged <TenantRelocationRequest>(staleLockedRelocationRequestsFilter, false, null));
        }
コード例 #4
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            this.DataObject.AutoCompletionEnabled  = this.AutoCompletionEnabled;
            this.DataObject.LargeTenantModeEnabled = this.LargeTenantModeEnabled;
            this.DataObject.SafeLockdownSchedule   = (this.SafeLockdownSchedule ?? Schedule.Always);
            if (base.Fields.IsModified(TenantRelocationRequestSchema.RelocationStateRequested))
            {
                this.DataObject.RelocationStateRequested = (RelocationStateRequested)this.RelocationStateRequested;
            }
            this.DataObject.TargetForest = this.targetAccountPartitionFqdn;
            this.sourceForestRIDMaster   = ForestTenantRelocationsCache.GetRidMasterName(this.sourceAccountPartitionId);
            DirectorySessionFactory @default = DirectorySessionFactory.Default;
            Fqdn domainController            = base.DomainController;
            ITenantConfigurationSession tenantConfigurationSession = @default.CreateTenantConfigurationSession((domainController != null) ? domainController : this.sourceForestRIDMaster, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAllTenantsPartitionId(this.sourceAccountPartitionId), 334, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");
            PartitionId partitionId = new PartitionId(this.targetAccountPartitionFqdn);

            this.targetForestRIDMaster = ForestTenantRelocationsCache.GetRidMasterName(partitionId);
            ITenantConfigurationSession tenantConfigurationSession2 = DirectorySessionFactory.Default.CreateTenantConfigurationSession(this.targetForestRIDMaster, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 343, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");

            tenantConfigurationSession2.SessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
            MsoTenantCookieContainer msoTenantCookieContainer = tenantConfigurationSession2.GetMsoTenantCookieContainer(this.externalDirectoryOrganizationId);

            if (msoTenantCookieContainer != null && !NewTenantRelocationRequest.IntraForestRelocationEnabled())
            {
                InvalidOperationException exception = new InvalidOperationException(Strings.ErrorTargetPartitionHasTenantWithSameId(this.DataObject.DistinguishedName, this.targetAccountPartitionFqdn, msoTenantCookieContainer.DistinguishedName, this.DataObject.ExternalDirectoryOrganizationId));
                base.WriteError(exception, ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            string text = this.GetInitialDomainName(tenantConfigurationSession, this.DataObject.OrganizationId);
            ExchangeConfigurationUnit exchangeConfigurationUnitByName = tenantConfigurationSession2.GetExchangeConfigurationUnitByName(text);

            if (exchangeConfigurationUnitByName != null)
            {
                if (text.Length > 50)
                {
                    text = text.Substring(0, 50);
                }
                text = string.Format("{0}-RELO-{1}", text, Guid.NewGuid().ToString());
                if (text.Length > 64)
                {
                    text = text.Substring(0, 64);
                }
            }
            Exception      ex;
            OrganizationId targetSharedOrgId = SharedConfiguration.FindMostRecentSharedConfigurationInPartition(this.DataObject.OrganizationId, partitionId, out ex);

            if (ex != null)
            {
                base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            ADOrganizationalUnit adorganizationalUnit = null;
            bool useConfigNC = tenantConfigurationSession.UseConfigNC;

            try
            {
                tenantConfigurationSession.UseConfigNC = false;
                adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(this.DataObject.OrganizationId.OrganizationalUnit);
            }
            finally
            {
                tenantConfigurationSession.UseConfigNC = useConfigNC;
            }
            this.DataObject.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationStarted;
            base.InternalProcessRecord();
            ADObjectId enclosureContainerId = this.CreateEnclosureConfigContainer(text, tenantConfigurationSession2);
            ExchangeConfigurationUnit exchangeConfigurationUnit = this.CreateOrgConfigurationContainer(enclosureContainerId, targetSharedOrgId, this.DataObject.ExternalDirectoryOrganizationId, this.DataObject.ProgramId, this.DataObject.OfferId, this.DataObject.IsDehydrated, this.DataObject.IsStaticConfigurationShared, this.sourceForestFqdn, this.DataObject.Guid, this.DataObject.ExchangeObjectId, tenantConfigurationSession2);
            ADObjectId organizationalUnitLink = this.CreateOrganizationUnitContainer(text, adorganizationalUnit.Guid, adorganizationalUnit.ExchangeObjectId, tenantConfigurationSession2);

            exchangeConfigurationUnit.OrganizationalUnitLink     = organizationalUnitLink;
            exchangeConfigurationUnit.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationFinished;
            tenantConfigurationSession2.Save(exchangeConfigurationUnit);
            this.DataObject.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationFinished;
            base.DataSession.Save(this.DataObject);
            TenantRelocationRequest tenantRelocationRequest = (TenantRelocationRequest)base.DataSession.Read <TenantRelocationRequest>(this.DataObject.Identity);
            TenantRelocationRequest targetForestObject      = tenantConfigurationSession2.Read <TenantRelocationRequest>(exchangeConfigurationUnit.Id);

            TenantRelocationRequest.PopulatePresentationObject(tenantRelocationRequest, targetForestObject);
            GetTenantRelocationRequest.PopulateGlsProperty(tenantRelocationRequest, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            GetTenantRelocationRequest.PopulateRidMasterProperties(tenantRelocationRequest, this.sourceForestRIDMaster, this.targetForestRIDMaster, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            if (tenantRelocationRequest.OriginatingServer != this.sourceForestRIDMaster)
            {
                this.WriteWarning(Strings.WarningShouldWriteToRidMaster(tenantRelocationRequest.OriginatingServer, this.sourceForestRIDMaster));
            }
            base.WriteObject(tenantRelocationRequest);
            TaskLogger.LogExit();
        }