コード例 #1
0
        internal bool ForceADReplication()
        {
            Server server = this.m_adSession.FindLocalServer();

            if (server == null)
            {
                return(false);
            }
            ADObjectId localServerSite = server.ServerSite;

            ADObjectId[] array = (from s in DatabaseAvailabilityGroupAction.GetSitesForDag(this.m_dag)
                                  where s != null && !s.Equals(localServerSite)
                                  select s).Distinct <ADObjectId>().ToArray <ADObjectId>();
            if (array != null && array.Length > 0)
            {
                this.m_output.AppendLogMessage("forcing AD replication to site {0}", new object[]
                {
                    array[0].Name
                });
                DagTaskHelper.ForceReplication(this.m_adSession, this.m_dag, array, this.m_dag.Name, new Microsoft.Exchange.Configuration.Tasks.Task.TaskWarningLoggingDelegate(this.WriteWarning), new Microsoft.Exchange.Configuration.Tasks.Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                this.m_output.AppendLogMessage("forcing replication succeeded", new object[0]);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        protected DatabaseCopy SaveDBCopy()
        {
            TaskLogger.LogEnter();
            DatabaseCopy databaseCopy = null;

            if (this.preExistingDatabase != null)
            {
                foreach (DatabaseCopy databaseCopy2 in this.preExistingDatabase.InvalidDatabaseCopies)
                {
                    if (databaseCopy2.Name.Equals(this.OwnerServer.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        databaseCopy = databaseCopy2;
                        break;
                    }
                }
            }
            DatabaseCopy databaseCopy3 = databaseCopy ?? new DatabaseCopy();

            databaseCopy3.HostServer = (ADObjectId)this.OwnerServer.Identity;
            if (databaseCopy == null)
            {
                databaseCopy3.ActivationPreference = 1;
            }
            else
            {
                databaseCopy3.ActivationPreference = databaseCopy3.ActivationPreference;
            }
            ADRawEntry  adrawEntry = databaseCopy3;
            TDataObject dataObject = this.DataObject;

            adrawEntry.SetId(dataObject.Id.GetChildId(this.OwnerServer.Name));
            databaseCopy3.ParentObjectClass = ((this.DatabaseType == NewDatabaseTask <TDataObject> .ExchangeDatabaseType.Public) ? PublicFolderDatabase.MostDerivedClass : MailboxDatabase.MostDerivedClass);
            TDataObject dataObject2 = this.DataObject;
            ActivationPreferenceSetter <DatabaseCopy> activationPreferenceSetter = new ActivationPreferenceSetter <DatabaseCopy>(dataObject2.AllDatabaseCopies, databaseCopy3, (databaseCopy == null) ? EntryAction.Insert : EntryAction.Modify);
            UpdateResult updateResult = activationPreferenceSetter.UpdateCachedValues();

            if (updateResult == UpdateResult.AllChanged)
            {
                activationPreferenceSetter.SaveAllUpdatedValues(base.DataSession);
            }
            base.DataSession.Save(databaseCopy3);
            this.forcedReplicationSites = DagTaskHelper.DetermineRemoteSites(base.GlobalConfigSession, databaseCopy3.OriginatingServer, this.OwnerServer);
            if (this.forcedReplicationSites != null)
            {
                ITopologyConfigurationSession session = (ITopologyConfigurationSession)base.DataSession;
                TDataObject dataObject3    = this.DataObject;
                string      objectIdentity = dataObject3.Identity.ToString();
                if (DagTaskHelper.ForceReplication(session, this.DataObject, this.forcedReplicationSites, objectIdentity, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)))
                {
                    DagTaskHelper.ForceReplication(session, databaseCopy3, this.forcedReplicationSites, objectIdentity, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                }
            }
            TaskLogger.LogExit();
            return(databaseCopy3);
        }
コード例 #3
0
        internal static ADSystemMailbox SaveSystemMailbox(MailboxDatabase mdb, Server owningServer, ADObjectId rootOrgContainerId, ITopologyConfigurationSession configSession, IRecipientSession recipientSession, ADObjectId[] forcedReplicationSites, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose)
        {
            TaskLogger.LogEnter();
            bool               useConfigNC        = configSession.UseConfigNC;
            bool               useGlobalCatalog   = configSession.UseGlobalCatalog;
            string             text               = "SystemMailbox" + mdb.Guid.ToString("B");
            SecurityIdentifier securityIdentifier = new SecurityIdentifier("SY");
            ADSystemMailbox    adsystemMailbox    = new ADSystemMailbox();

            adsystemMailbox.StampPersistableDefaultValues();
            adsystemMailbox.Name        = text;
            adsystemMailbox.DisplayName = text;
            adsystemMailbox.Alias       = text;
            adsystemMailbox.HiddenFromAddressListsEnabled = true;
            adsystemMailbox.Database = mdb.Id;
            if (owningServer == null)
            {
                throw new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString()));
            }
            adsystemMailbox.ServerLegacyDN = owningServer.ExchangeLegacyDN;
            adsystemMailbox.ExchangeGuid   = Guid.NewGuid();
            AcceptedDomain defaultAcceptedDomain = configSession.GetDefaultAcceptedDomain();

            if (defaultAcceptedDomain == null || defaultAcceptedDomain.DomainName == null || defaultAcceptedDomain.DomainName.Domain == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorNoDefaultAcceptedDomainFound(mdb.Identity.ToString()));
            }
            adsystemMailbox.EmailAddresses.Add(ProxyAddress.Parse("SMTP:" + adsystemMailbox.Alias + "@" + defaultAcceptedDomain.DomainName.Domain.ToString()));
            adsystemMailbox.WindowsEmailAddress         = adsystemMailbox.PrimarySmtpAddress;
            adsystemMailbox.SendModerationNotifications = TransportModerationNotificationFlags.Never;
            Organization organization = configSession.Read <Organization>(rootOrgContainerId);

            if (organization == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorOrganizationNotFound(rootOrgContainerId.Name));
            }
            string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/ou={1}/cn=Recipients", new object[]
            {
                organization.LegacyExchangeDN,
                configSession.GetAdministrativeGroupId().Name
            });

            adsystemMailbox.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, adsystemMailbox);
            ADComputer adcomputer;

            try
            {
                configSession.UseConfigNC      = false;
                configSession.UseGlobalCatalog = true;
                adcomputer = configSession.FindComputerByHostName(owningServer.Name);
            }
            finally
            {
                configSession.UseConfigNC      = useConfigNC;
                configSession.UseGlobalCatalog = useGlobalCatalog;
            }
            if (adcomputer == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString()));
            }
            ADObjectId adobjectId = adcomputer.Id.DomainId;

            adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
            adsystemMailbox.SetId(adobjectId.GetChildId(text));
            GenericAce[] aces = new GenericAce[]
            {
                new CommonAce(AceFlags.None, AceQualifier.AccessAllowed, 131075, securityIdentifier, false, null)
            };
            DirectoryCommon.SetAclOnAlternateProperty(adsystemMailbox, aces, ADSystemAttendantMailboxSchema.ExchangeSecurityDescriptor, securityIdentifier, securityIdentifier);
            recipientSession.LinkResolutionServer = mdb.OriginatingServer;
            bool enforceDefaultScope = recipientSession.EnforceDefaultScope;

            try
            {
                writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox)));
                recipientSession.EnforceDefaultScope = false;
                recipientSession.Save(adsystemMailbox);
            }
            catch (ADConstraintViolationException ex)
            {
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ex.Server, false, ConsistencyMode.PartiallyConsistent, configSession.SessionSettings, 705, "SaveSystemMailbox", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\NewMailboxDatabase.cs");
                if (!tenantOrTopologyConfigurationSession.ReplicateSingleObjectToTargetDC(mdb, ex.Server))
                {
                    throw;
                }
                writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox)));
                recipientSession.Save(adsystemMailbox);
            }
            finally
            {
                writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(recipientSession));
                recipientSession.EnforceDefaultScope = enforceDefaultScope;
            }
            if (forcedReplicationSites != null)
            {
                DagTaskHelper.ForceReplication(recipientSession, adsystemMailbox, forcedReplicationSites, mdb.Name, writeWarning, writeVerbose);
            }
            TaskLogger.LogExit();
            return(adsystemMailbox);
        }
コード例 #4
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            if (this.m_invalidDbCopy == null && !this.m_fConfigOnly)
            {
                ReplayState.DeleteState(this.m_server.Fqdn, this.DataObject, true);
            }
            DatabaseCopy databaseCopy = this.m_invalidDbCopy ?? new DatabaseCopy();

            databaseCopy.HostServer = (ADObjectId)this.m_server.Identity;
            if (base.Fields["ActivationPreference"] == null)
            {
                if (this.m_invalidDbCopy == null)
                {
                    this.ActivationPreference = (uint)(this.DataObject.AllDatabaseCopies.Length + 1);
                }
                else
                {
                    this.ActivationPreference = (uint)this.m_invalidDbCopy.ActivationPreference;
                }
            }
            databaseCopy.ActivationPreference = (int)this.ActivationPreference;
            DatabaseCopy databaseCopy2 = null;

            if (databaseCopy.ActivationPreference == 1)
            {
                databaseCopy2 = databaseCopy;
            }
            else if (this.ActivationPreference != 0U)
            {
                databaseCopy2 = SetMailboxDatabaseCopy.GetDatabaseCopyOfPreference1(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), this.DataObject, databaseCopy);
            }
            ActivationPreferenceSetter <DatabaseCopy> activationPreferenceSetter = new ActivationPreferenceSetter <DatabaseCopy>(this.DataObject.AllDatabaseCopies, databaseCopy, (this.m_invalidDbCopy == null) ? EntryAction.Insert : EntryAction.Modify);
            UpdateResult updateResult = activationPreferenceSetter.UpdateCachedValues();

            if (updateResult == UpdateResult.AllChanged)
            {
                activationPreferenceSetter.SaveAllUpdatedValues(base.DataSession);
            }
            databaseCopy.ReplayLagTime     = this.m_replayLagTime;
            databaseCopy.TruncationLagTime = this.m_truncationLagTime;
            databaseCopy.SetId(this.DataObject.Id.GetChildId(this.m_server.Name.ToUpperInvariant()));
            databaseCopy.ParentObjectClass = (this.DataObject.IsPublicFolderDatabase ? PublicFolderDatabase.MostDerivedClass : MailboxDatabase.MostDerivedClass);
            if (databaseCopy2 != null)
            {
                base.WriteVerbose(Strings.UpdatingLegDnForDatabaseCopy(databaseCopy.Name));
                ITopologyConfigurationSession adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, base.SessionSettings, 338, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\AddMailboxDatabaseCopy.cs");
                SetMailboxDatabaseCopy.UpdateServerLegdnForDatabaseSite(new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), adSession, databaseCopy2);
            }
            base.WriteVerbose(Strings.UpdatingDatabaseCopyObject(databaseCopy.HostServer.Name, databaseCopy.ReplayLagTime.ToString(), databaseCopy.TruncationLagTime.ToString()));
            base.DataSession.Save(databaseCopy);
            MailboxDatabase database = databaseCopy.GetDatabase <MailboxDatabase>();

            if (this.m_firstCopy && database.DataMoveReplicationConstraint == DataMoveReplicationConstraintParameter.None)
            {
                database.DataMoveReplicationConstraint = DataMoveReplicationConstraintParameter.SecondCopy;
                base.DataSession.Save(database);
                base.WriteVerbose(Strings.ConstraintUpgrade(database.Identity.ToString(), DataMoveReplicationConstraintParameter.None, DataMoveReplicationConstraintParameter.SecondCopy));
            }
            ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession;

            ADObjectId[] array = DagTaskHelper.DetermineRemoteSites(topologyConfigurationSession, databaseCopy.OriginatingServer, this.m_server);
            if (array != null)
            {
                DagTaskHelper.ForceReplication(topologyConfigurationSession, databaseCopy, array, this.DataObject.Identity.ToString(), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            }
            if (!this.m_fConfigOnly)
            {
                this.RunSourceConfigurationUpdaterRpc();
            }
            if (!this.IsThirdPartyReplicationEnabled && !this.m_SeedingPostponedSpecified && !base.SeedingPostponed && !this.m_fConfigOnly)
            {
                base.CreateTargetEdbDirectory();
                base.PerformSeedIfNecessary();
            }
            if (!this.m_fConfigOnly)
            {
                this.RunTargetConfigurationUpdaterRpc();
            }
            this.WriteWarning(Strings.WarnAdministratorToRestartService(this.m_server.Name));
            TaskLogger.LogExit();
        }