コード例 #1
0
 // Token: 0x060007E6 RID: 2022 RVA: 0x0001D0C1 File Offset: 0x0001B2C1
 public AccountPartitionIdParameter(AccountPartition partition)
 {
     if (partition == null)
     {
         throw new ArgumentNullException("partition");
     }
     this.Initialize(partition.Id);
 }
コード例 #2
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            SyncServiceInstance syncServiceInstance = (SyncServiceInstance)base.PrepareDataObject();

            syncServiceInstance.SetId(SyncServiceInstance.GetServiceInstanceObjectId(this.Name.InstanceId));
            if (this.AccountPartition != null)
            {
                AccountPartition accountPartition = (AccountPartition)base.GetDataObject <AccountPartition>(this.AccountPartition, this.ConfigurationSession, null, null, null);
                syncServiceInstance.AccountPartition = accountPartition.Id;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.MinVersion))
            {
                syncServiceInstance.MinVersion = this.MinVersion;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.MaxVersion))
            {
                syncServiceInstance.MaxVersion = this.MaxVersion;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.ActiveInstanceSleepInterval))
            {
                syncServiceInstance.ActiveInstanceSleepInterval = this.ActiveInstanceSleepInterval;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.PassiveInstanceSleepInterval))
            {
                syncServiceInstance.PassiveInstanceSleepInterval = this.PassiveInstanceSleepInterval;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.IsEnabled))
            {
                syncServiceInstance.IsEnabled = this.IsEnabled;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.NewTenantMinVersion))
            {
                syncServiceInstance.NewTenantMinVersion = this.NewTenantMinVersion;
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.NewTenantMaxVersion))
            {
                syncServiceInstance.NewTenantMaxVersion = this.NewTenantMaxVersion;
            }
            syncServiceInstance.IsMultiObjectCookieEnabled = true;
            TaskLogger.LogExit();
            return(syncServiceInstance);
        }
コード例 #3
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            SyncServiceInstance syncServiceInstance = (SyncServiceInstance)base.PrepareDataObject();

            if (syncServiceInstance.IsChanged(ADObjectSchema.Name))
            {
                string text;
                syncServiceInstance.TryGetOriginalValue <string>(ADObjectSchema.Name, out text);
                if (!this.Force && !SetSyncServiceInstance.IsServiceInstanceEmpty(syncServiceInstance))
                {
                    base.WriteError(new InvalidOperationException(Strings.CannotChangeServiceInstanceNameError(text)), ErrorCategory.InvalidOperation, text);
                }
            }
            if (syncServiceInstance.IsChanged(SyncServiceInstanceSchema.ForwardSyncConfigurationXML))
            {
                string forwardSyncConfigurationXML = syncServiceInstance.ForwardSyncConfigurationXML;
                try
                {
                    XElement.Parse(forwardSyncConfigurationXML);
                }
                catch (XmlException ex)
                {
                    base.WriteError(new InvalidOperationException(Strings.InvalidForwardSyncConfigurationError(ex.Message)), ErrorCategory.InvalidOperation, ex.Message);
                }
            }
            if (base.Fields.IsModified(SyncServiceInstanceSchema.AccountPartition))
            {
                if (this.AccountPartition != null)
                {
                    AccountPartition accountPartition = (AccountPartition)base.GetDataObject <AccountPartition>(this.AccountPartition, this.ConfigurationSession, null, null, null);
                    syncServiceInstance.AccountPartition = accountPartition.Id;
                }
                else
                {
                    syncServiceInstance.AccountPartition = null;
                }
            }
            TaskLogger.LogExit();
            return(syncServiceInstance);
        }
コード例 #4
0
        private static PartitionId ResolvePartitionId(AccountPartitionIdParameter accountPartitionIdParameter, Task.TaskErrorLoggingDelegate errorLogger)
        {
            PartitionId     result = null;
            LocalizedString?localizedString;
            IEnumerable <AccountPartition> objects = accountPartitionIdParameter.GetObjects <AccountPartition>(null, DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.SessionSettingsFactory.Default.FromRootOrgScopeSet(), 548, "ResolvePartitionId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\NewOrganizationTask.cs"), null, out localizedString);
            Exception ex = null;

            using (IEnumerator <AccountPartition> enumerator = objects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    AccountPartition accountPartition = enumerator.Current;
                    if (!accountPartition.TryGetPartitionId(out result))
                    {
                        ex = new NotSupportedException(Strings.ErrorCorruptedPartition(accountPartitionIdParameter.ToString()));
                    }
                    else if (enumerator.MoveNext())
                    {
                        ex = new ManagementObjectAmbiguousException(Strings.ErrorObjectNotUnique(accountPartitionIdParameter.ToString()));
                    }
                    if (accountPartition.IsSecondary)
                    {
                        ex = new ArgumentException(Strings.ErrorSecondaryPartitionNotEnabledForProvisioning(accountPartitionIdParameter.RawIdentity));
                    }
                }
                else
                {
                    ex = new ManagementObjectNotFoundException(localizedString ?? Strings.ErrorObjectNotFound(accountPartitionIdParameter.ToString()));
                }
            }
            if (ex != null)
            {
                errorLogger(ex, ErrorCategory.InvalidArgument, accountPartitionIdParameter);
            }
            return(result);
        }
コード例 #5
0
        List <TenantOrganizationPresentationObjectWrapper> IOrganizationOperation.GetAllOrganizations(bool checkAllPartitions)
        {
            List <TenantOrganizationPresentationObjectWrapper> result;

            using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers"))
            {
                PSCommand pscommand = new PSCommand();
                pscommand.AddCommand("Get-AccountPartition");
                Collection <AccountPartition> collection = null;
                try
                {
                    collection = anchorRunspaceProxy.RunPSCommand <AccountPartition>(pscommand);
                }
                catch (MigrationPermanentException ex)
                {
                    this.Context.Logger.Log(MigrationEventType.Error, "Get-AccountPartition failed: {0}", new object[]
                    {
                        ex
                    });
                    throw;
                }
                pscommand.Clear();
                List <TenantOrganizationPresentationObject> list = new List <TenantOrganizationPresentationObject>();
                if (collection == null || collection.Count == 0)
                {
                    result = null;
                }
                else
                {
                    Collection <AccountPartition> collection2 = new Collection <AccountPartition>();
                    if (!checkAllPartitions)
                    {
                        AccountPartition accountPartition = collection.FirstOrDefault((AccountPartition p) => p.IsLocalForest);
                        if (accountPartition == null)
                        {
                            this.Context.Logger.Log(MigrationEventType.Information, "No LocalForest partitions found", new object[0]);
                            return(null);
                        }
                        collection2.Add(accountPartition);
                        this.Context.Logger.Log(MigrationEventType.Information, "Get-Organization will run on partition: {0} IsLocalPartition: {1}", new object[]
                        {
                            collection2.ElementAt(0).Name,
                            collection2.ElementAt(0).IsLocalForest
                        });
                    }
                    else
                    {
                        collection2 = collection;
                    }
                    foreach (AccountPartition accountPartition2 in collection2)
                    {
                        pscommand.AddCommand("Get-Organization");
                        pscommand.AddParameter("AccountPartition", accountPartition2);
                        pscommand.AddParameter("Filter", "OrganizationStatus -eq 1");
                        Stopwatch stopwatch = Stopwatch.StartNew();
                        Collection <TenantOrganizationPresentationObject> collection3 = new Collection <TenantOrganizationPresentationObject>();
                        try
                        {
                            collection3 = anchorRunspaceProxy.RunPSCommand <TenantOrganizationPresentationObject>(pscommand);
                            this.Context.Logger.Log(MigrationEventType.Information, "Get-Organization ran for partition {0} in: {1}, found {2} orgs.", new object[]
                            {
                                accountPartition2.Name,
                                stopwatch.Elapsed.TotalSeconds,
                                collection3.Count
                            });
                        }
                        catch (MigrationPermanentException ex2)
                        {
                            this.Context.Logger.Log(MigrationEventType.Error, "Get-Organization failed for Partition {0} : {1}", new object[]
                            {
                                accountPartition2.Name,
                                ex2
                            });
                            throw;
                        }
                        List <TenantOrganizationPresentationObject> collection4 = CommonUtils.RandomizeSequence <TenantOrganizationPresentationObject>(collection3.ToList <TenantOrganizationPresentationObject>());
                        list.AddRange(collection4);
                    }
                    List <TenantOrganizationPresentationObjectWrapper> list2 = new List <TenantOrganizationPresentationObjectWrapper>();
                    foreach (TenantOrganizationPresentationObject tenant in list)
                    {
                        list2.Add(new TenantOrganizationPresentationObjectWrapper(tenant));
                    }
                    result = list2;
                }
            }
            return(result);
        }
コード例 #6
0
        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();
        }