private void SetDefaultRetentionValues(Mailbox mailbox)
        {
            bool flag  = mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetainDeletedItemsFor);
            bool flag2 = mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetainDeletedItemsUntilBackup);

            if (flag && flag2)
            {
                return;
            }
            MailboxDatabase mailboxDatabase;

            if (this.Database != null)
            {
                mailboxDatabase = (MailboxDatabase)this.scopeObject;
            }
            else
            {
                DatabaseIdParameter databaseIdParam = new DatabaseIdParameter(mailbox.Database);
                string subKey = databaseIdParam.ToString();
                mailboxDatabase = base.ProvisioningCache.TryAddAndGetGlobalDictionaryValue <MailboxDatabase, string>(CannedProvisioningCacheKeys.MailboxDatabaseForDefaultRetentionValuesCacheKey, subKey, () => (MailboxDatabase)this.GetDataObject <MailboxDatabase>(databaseIdParam, this.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(mailbox.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(mailbox.Database.ToString()))));
            }
            if (!flag)
            {
                mailbox.RetainDeletedItemsFor = mailboxDatabase.DeletedItemRetention;
            }
            if (!flag2)
            {
                mailbox.RetainDeletedItemsUntilBackup = mailboxDatabase.RetainDeletedItemsUntilBackup;
            }
        }
Ejemplo n.º 2
0
        private MailboxDatabase GetMailboxDatabase(DatabaseIdParameter databaseId)
        {
            if (databaseId == null)
            {
                throw new ArgumentNullException("databaseId");
            }
            MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseId, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseId.ToString())));

            if (mailboxDatabase == null)
            {
                throw new DatabaseNotFoundException(databaseId.ToString());
            }
            return(mailboxDatabase);
        }
Ejemplo n.º 3
0
        private MailboxDatabase LocateAndVerifyMdb(DatabaseIdParameter databaseId, out ServerVersion targetServerVersion)
        {
            MailboxDatabase     mailboxDatabase     = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseId, base.ConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseId.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseId.ToString())));
            DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mailboxDatabase.Id.ObjectGuid, null, null, FindServerFlags.None);

            targetServerVersion = new ServerVersion(databaseInformation.ServerVersion);
            this.EnsureSupportedServerVersion(databaseInformation.ServerVersion);
            return(mailboxDatabase);
        }
Ejemplo n.º 4
0
        private ADObjectId ResolveDatabaseParameterId(DatabaseIdParameter dbId)
        {
            MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(dbId, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(dbId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(dbId.ToString())));

            return(mailboxDatabase.Id);
        }
Ejemplo n.º 5
0
        private void ResolveDatabaseAndServer()
        {
            DatabaseIdParameter database = this.Database;

            database.AllowLegacy = false;
            Database database2 = (Database)base.GetDataObject <Database>(database, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(database.ToString())));

            if (database2.Server == null)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Database).Name, database.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database2);
            }
            ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
            DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(database2.Guid);
            ServerIdParameter    serverIdParameter     = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);

            this.targetServer = (Server)base.GetDataObject <Server>(serverIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
            if (!this.TargetServer.IsE14OrLater || !this.TargetServer.IsMailboxServer)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.TargetServer);
            }
            this.targetDatabase = database2;
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            StoreIntegrityCheckJobIdentity storeIntegrityCheckJobIdentity = new StoreIntegrityCheckJobIdentity(this.Identity.RawIdentity);
            DatabaseIdParameter            databaseIdParameter            = new DatabaseIdParameter(new ADObjectId(storeIntegrityCheckJobIdentity.DatabaseGuid));

            this.jobGuid  = storeIntegrityCheckJobIdentity.JobGuid;
            this.database = (Database)base.GetDataObject <Database>(databaseIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
            TaskLogger.LogExit();
        }
Ejemplo n.º 7
0
        protected T CheckDatabase <T>(DatabaseIdParameter databaseIdParameter, NewRequest <TRequest> .DatabaseSide databaseSide, object errorObject, out string serverName, out string serverDN, out ADObjectId serverSite, out int serverVersion) where T : Database, new()
        {
            T result = (T)((object)base.GetDataObject <T>(databaseIdParameter, this.ConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString()))));
            DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(result.Id.ObjectGuid, null, null, FindServerFlags.None);

            serverName    = databaseInformation.ServerFqdn;
            serverDN      = databaseInformation.ServerDN;
            serverSite    = databaseInformation.ServerSite;
            serverVersion = databaseInformation.ServerVersion;
            if (!this.IsSupportedDatabaseVersion(serverVersion, databaseSide))
            {
                base.WriteError(new DatabaseVersionUnsupportedPermanentException(result.Identity.ToString(), serverName, new ServerVersion(serverVersion).ToString()), ErrorCategory.InvalidArgument, errorObject);
            }
            return(result);
        }