protected void PerformSeedIfNecessary()
        {
            TDataObject                  dataObject    = this.DataObject;
            IIdentityParameter           id            = new DatabaseIdParameter(dataObject.Id);
            IConfigDataProvider          dataSession   = base.DataSession;
            ObjectId                     rootId        = this.RootId;
            TDataObject                  dataObject2   = this.DataObject;
            LocalizedString?             notFoundError = new LocalizedString?(Strings.ErrorDatabaseNotFound(dataObject2.Name));
            TDataObject                  dataObject3   = this.DataObject;
            Database                     database      = (Database)base.GetDataObject <Database>(id, dataSession, rootId, notFoundError, new LocalizedString?(Strings.ErrorDatabaseNotUnique(dataObject3.Name)));
            IADDatabaseAvailabilityGroup dag           = null;

            if (this.m_server.DatabaseAvailabilityGroup != null)
            {
                DatabaseAvailabilityGroup dag2 = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.m_server.DatabaseAvailabilityGroup);
                dag = ADObjectWrapperFactory.CreateWrapper(dag2);
            }
            ReplayConfiguration config = RemoteReplayConfiguration.TaskGetReplayConfig(dag, ADObjectWrapperFactory.CreateWrapper(database), ADObjectWrapperFactory.CreateWrapper(this.m_server));

            if (this.m_fSeeding)
            {
                this.SeedDatabase(config);
            }
            this.SuspendDatabaseCopyIfNecessary(config);
        }
Пример #2
0
        private void VerifyLegacyPublicFolderDatabaseLocked()
        {
            PublicFolderEndpoint publicFolderEndpoint = (PublicFolderEndpoint)this.DataObject.SourceEndpoint;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                IMailbox mailbox;
                if (publicFolderEndpoint != null)
                {
                    mailbox = disposeGuard.Add <IMailbox>(publicFolderEndpoint.ConnectToSourceDatabase());
                }
                else
                {
                    DatabaseIdParameter  id = DatabaseIdParameter.Parse(this.DataObject.SourcePublicFolderDatabase);
                    PublicFolderDatabase publicFolderDatabase = (PublicFolderDatabase)base.GetDataObject <PublicFolderDatabase>(id, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.DataObject.SourcePublicFolderDatabase)), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.DataObject.SourcePublicFolderDatabase)));
                    mailbox = disposeGuard.Add <IMailbox>(PublicFolderEndpoint.ConnectToLocalSourceDatabase(publicFolderDatabase.ExchangeObjectId));
                }
                try
                {
                    bool flag;
                    mailbox.SetInTransitStatus(InTransitStatus.MoveSource, out flag);
                    mailbox.SetInTransitStatus(InTransitStatus.NotInTransit, out flag);
                }
                catch (SourceMailboxAlreadyBeingMovedTransientException)
                {
                    base.WriteError(new MigrationBatchCannotBeCompletedException(Strings.CompletePublicFolderMigrationBatchRequiresSourceLockDown));
                }
            }
        }
Пример #3
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.RootId != null)
            {
                try
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch));
                    LocalizedString?          localizedString;
                    IEnumerable <TDataObject> objects = new DatabaseIdParameter
                    {
                        AllowInvalid = true
                    }.GetObjects <TDataObject>(this.RootId, base.DataSession, base.OptionalIdentityData, out localizedString);
                    this.WriteResult <TDataObject>(objects);
                    goto IL_7E;
                }
                catch (DataSourceTransientException exception)
                {
                    base.WriteError(exception, ErrorCategory.ReadError, null);
                    goto IL_7E;
                }
            }
            base.InternalProcessRecord();
IL_7E:
            TaskLogger.LogExit();
        }
Пример #4
0
 public InjectMoveRequest(string batchName, DirectoryMailbox mailbox, ILogger logger, bool protect, RequestPriority requestPriority, ADObjectId mailboxObjectId, DirectoryIdentity targetDatabaseIdentity, ILoadBalanceSettings settings, CmdletExecutionPool cmdletPool) : base("New-MoveRequest", cmdletPool, logger)
 {
     this.settings       = settings;
     this.TargetDatabase = targetDatabaseIdentity;
     this.BatchName      = batchName;
     this.Mailbox        = mailbox;
     this.Protect        = protect;
     AnchorUtil.ThrowOnNullArgument(mailbox, "mailbox");
     base.Command.AddParameter("Identity", mailboxObjectId);
     base.Command.AddParameter("WorkloadType", RequestWorkloadType.LoadBalancing);
     if (!string.IsNullOrWhiteSpace(batchName))
     {
         base.Command.AddParameter("BatchName", batchName);
     }
     if (targetDatabaseIdentity != null)
     {
         DatabaseIdParameter value = new DatabaseIdParameter(targetDatabaseIdentity.ADObjectId);
         if (mailbox.IsArchiveOnly)
         {
             base.Command.AddParameter("ArchiveTargetDatabase", value);
             base.Command.AddParameter("ArchiveOnly");
         }
         else
         {
             base.Command.AddParameter("TargetDatabase", value);
             base.Command.AddParameter("PrimaryOnly");
         }
     }
     base.Command.AddParameter("CompletedRequestAgeLimit", 0);
     base.Command.AddParameter("Priority", requestPriority);
     if (protect)
     {
         base.Command.AddParameter("Protect");
     }
 }
        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;
            }
        }
Пример #6
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);
        }
        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();
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            DatabaseIdParameter databaseIdParameter = null;
            Guid empty = Guid.Empty;

            if (base.ParameterSetName == "Identity")
            {
                if (this.Identity != null)
                {
                    StoreIntegrityCheckJobIdentity storeIntegrityCheckJobIdentity = new StoreIntegrityCheckJobIdentity(this.Identity.RawIdentity);
                    databaseIdParameter = new DatabaseIdParameter(new ADObjectId(storeIntegrityCheckJobIdentity.DatabaseGuid));
                    this.requestGuid    = storeIntegrityCheckJobIdentity.RequestGuid;
                    this.jobGuid        = storeIntegrityCheckJobIdentity.JobGuid;
                }
                else
                {
                    base.WriteError(new ArgumentNullException("identity"), ErrorCategory.InvalidArgument, null);
                }
            }
            else if (base.ParameterSetName == "Database")
            {
                databaseIdParameter = this.Database;
                if (this.StoreMailbox != null)
                {
                    Guid.TryParse(this.StoreMailbox.RawIdentity, out this.mailboxGuid);
                }
            }
            else if (base.ParameterSetName == "Mailbox")
            {
                ADUser aduser = ((ADRecipient)base.GetDataObject <ADRecipient>(this.Mailbox, this.RecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Mailbox.ToString())))) as ADUser;
                if (!this.Archive)
                {
                    databaseIdParameter = new DatabaseIdParameter(aduser.Database);
                    this.mailboxGuid    = aduser.ExchangeGuid;
                }
                else if (aduser.ArchiveDomain == null && aduser.ArchiveGuid != Guid.Empty)
                {
                    databaseIdParameter = new DatabaseIdParameter(aduser.ArchiveDatabase ?? aduser.Database);
                    this.mailboxGuid    = aduser.ArchiveGuid;
                }
                else if (aduser.ArchiveDomain != null)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Mailbox);
                }
                else
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Mailbox);
                }
            }
            this.databaseObject = (Database)base.GetDataObject <Database>(databaseIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
            TaskLogger.LogExit();
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
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;
        }
Пример #12
0
        protected override IConfigurable PrepareDataObject()
        {
            DatabaseIdParameter databaseIdParameter = null;
            Guid empty = Guid.Empty;

            if (base.ParameterSetName == "Database")
            {
                databaseIdParameter = this.Database;
                if (this.StoreMailbox != null && !Guid.TryParse(this.StoreMailbox.RawIdentity, out this.mailboxGuid))
                {
                    base.WriteError(new OnlineIsIntegException(this.Database.ToString(), Strings.InvalidStoreMailboxIdentity, null), ErrorCategory.InvalidArgument, this.StoreMailbox);
                }
            }
            else if (base.ParameterSetName == "Mailbox")
            {
                ADUser aduser = ((ADRecipient)base.GetDataObject <ADRecipient>(this.Mailbox, this.RecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Mailbox.ToString())))) as ADUser;
                if (!this.Archive)
                {
                    databaseIdParameter = new DatabaseIdParameter(aduser.Database);
                    this.mailboxGuid    = aduser.ExchangeGuid;
                }
                else if (aduser.ArchiveDomain == null && aduser.ArchiveGuid != Guid.Empty)
                {
                    databaseIdParameter = new DatabaseIdParameter(aduser.ArchiveDatabase ?? aduser.Database);
                    this.mailboxGuid    = aduser.ArchiveGuid;
                }
                else if (aduser.ArchiveDomain != null)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Mailbox);
                }
                else
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Mailbox);
                }
                this.organizationId = aduser.OrganizationId;
            }
            this.databaseObject = (Database)base.GetDataObject <Database>(databaseIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
            return(new StoreIntegrityCheckJob());
        }
Пример #13
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            bool flag = ((OfflineAddressBook)dataObject).Versions.Contains(OfflineAddressBookVersion.Version1);

            this.isOriginalPfDistributionEnabled = ((OfflineAddressBook)dataObject).PublicFolderDistributionEnabled;
            base.StampChangesOn(dataObject);
            bool flag2 = ((OfflineAddressBook)dataObject).Versions.Contains(OfflineAddressBookVersion.Version1);

            this.isPresentPfDistributionEnabled = ((OfflineAddressBook)dataObject).PublicFolderDistributionEnabled;
            OfflineAddressBook offlineAddressBook = (OfflineAddressBook)dataObject;

            for (int i = 0; i < SetOfflineAddressBookInternal.propertiesCannotBeSet.GetLength(0); i++)
            {
                if (offlineAddressBook.IsModified(SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 0]))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorSpecifiedPropertyCannotBeSet((SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 1] ?? SetOfflineAddressBookInternal.propertiesCannotBeSet[i, 0]).ToString())), ErrorCategory.InvalidOperation, this.Identity);
                }
            }
            if (!flag && flag2)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorSetVersion1OfExchange12OAB), ErrorCategory.InvalidOperation, offlineAddressBook.Identity);
            }
            if (this.GeneratingMailbox != null)
            {
                if (offlineAddressBook.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorLegacyOABDoesNotSupportLinkedMailbox), ErrorCategory.InvalidOperation, this.Identity);
                }
                offlineAddressBook.GeneratingMailbox = OfflineAddressBookTaskUtility.ValidateGeneratingMailbox(base.TenantGlobalCatalogSession, this.GeneratingMailbox, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADUser>), offlineAddressBook, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (this.AddressLists != null && this.AddressLists.Length > 0)
            {
                offlineAddressBook.AddressLists = OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            else if (offlineAddressBook.IsModified(OfflineAddressBookSchema.AddressLists))
            {
                List <AddressBookBaseIdParameter> list = new List <AddressBookBaseIdParameter>();
                if (offlineAddressBook.AddressLists != null && offlineAddressBook.AddressLists.Added.Length != 0)
                {
                    foreach (ADObjectId adObjectId in offlineAddressBook.AddressLists.Added)
                    {
                        list.Add(new AddressBookBaseIdParameter(adObjectId));
                    }
                    OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, list.ToArray(), new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
            }
            if (base.Fields.IsModified("VirtualDirectories"))
            {
                if (this.VirtualDirectories != null && this.VirtualDirectories.Length > 0)
                {
                    offlineAddressBook.VirtualDirectories = OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, this.VirtualDirectories, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
                else
                {
                    offlineAddressBook.VirtualDirectories = null;
                }
            }
            else if (offlineAddressBook.IsModified(OfflineAddressBookSchema.VirtualDirectories))
            {
                if (offlineAddressBook.VirtualDirectories != null && offlineAddressBook.VirtualDirectories.Added.Length > 0)
                {
                    List <VirtualDirectoryIdParameter> list2 = new List <VirtualDirectoryIdParameter>();
                    foreach (ADObjectId adObjectId2 in offlineAddressBook.VirtualDirectories.Added)
                    {
                        list2.Add(new VirtualDirectoryIdParameter(adObjectId2));
                    }
                    OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, list2.ToArray(), new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), offlineAddressBook, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
                else
                {
                    offlineAddressBook.VirtualDirectories = null;
                }
            }
            bool flag3 = false;

            if (this.isOriginalPfDistributionEnabled ^ this.isPresentPfDistributionEnabled)
            {
                if (offlineAddressBook.PublicFolderDatabase != null)
                {
                    IEnumerable <PublicFolderDatabase> objects = new DatabaseIdParameter(offlineAddressBook.PublicFolderDatabase)
                    {
                        AllowLegacy = true
                    }.GetObjects <PublicFolderDatabase>(null, base.GlobalConfigSession);
                    using (IEnumerator <PublicFolderDatabase> enumerator = objects.GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            this.publicFolderDatabase = enumerator.Current;
                            if (enumerator.MoveNext())
                            {
                                this.publicFolderDatabase = null;
                            }
                            else
                            {
                                flag3 = true;
                            }
                        }
                    }
                }
                if (!flag3)
                {
                    OfflineAddressBookTaskUtility.ValidatePublicFolderInfrastructure(base.GlobalConfigSession, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), this.isPresentPfDistributionEnabled);
                }
            }
            if (this.UseDefaultAttributes.IsPresent)
            {
                if (offlineAddressBook.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010))
                {
                    base.WriteError(new InvalidOperationException(Strings.CannotUseDefaultAttributesForExchange2007OAB), ErrorCategory.InvalidOperation, this.Identity);
                }
                offlineAddressBook.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
            }
            if (!this.isOriginalPfDistributionEnabled && this.isPresentPfDistributionEnabled && !flag3)
            {
                this.publicFolderDatabase = OfflineAddressBookTaskUtility.FindPublicFolderDatabase(base.GlobalConfigSession, offlineAddressBook.Server, new Task.TaskErrorLoggingDelegate(base.WriteError));
                offlineAddressBook.PublicFolderDatabase = (ADObjectId)this.publicFolderDatabase.Identity;
            }
            if (offlineAddressBook.IsChanged(OfflineAddressBookSchema.VirtualDirectories) || this.isOriginalPfDistributionEnabled != this.isPresentPfDistributionEnabled)
            {
                OfflineAddressBookTaskUtility.WarnForNoDistribution(offlineAddressBook, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         string     empty      = string.Empty;
         string     empty2     = string.Empty;
         int        num        = 0;
         ADObjectId adobjectId = null;
         base.OrganizationId = OrganizationId.ForestWideOrgId;
         if (base.ParameterSetName.Equals("MailboxMigrationOutlookAnywherePublicFolder"))
         {
             IConfigurationSession session = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
             if (this.Organization == null && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId)
             {
                 this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit);
             }
             if (this.Organization != null)
             {
                 ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Organization, session, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString())));
                 base.OrganizationId = adorganizationalUnit.OrganizationId;
             }
             base.RescopeToOrgId(base.OrganizationId);
             base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
         }
         else if (base.ParameterSetName.Equals("MailboxMigrationLocalPublicFolder"))
         {
             base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull);
             PublicFolderDatabase publicFolderDatabase = base.CheckDatabase <PublicFolderDatabase>(this.SourceDatabase, NewRequest <PublicFolderMailboxMigrationRequest> .DatabaseSide.Source, this.SourceDatabase, out empty, out empty2, out adobjectId, out num);
             this.sourceDatabase = publicFolderDatabase.Id;
         }
         this.recipientSession  = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.FullyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(base.OrganizationId), 408, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\PublicFolderMailboxMigrationRequest\\NewPublicFolderMailboxMigrationRequest.cs");
         this.TargetMailboxUser = (ADUser)base.GetDataObject <ADUser>(this.TargetMailbox, this.recipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.TargetMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.TargetMailbox.ToString())));
         TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.OrganizationId);
         this.PublicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(base.OrganizationId);
         if (this.PublicFolderConfiguration.HeuristicsFlags.HasFlag(HeuristicsFlags.PublicFolderMigrationComplete))
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorPublicFolderMigrationCompletedPreviously), ExchangeErrorCategory.Client, null);
         }
         if (this.PublicFolderConfiguration.GetHierarchyMailboxInformation().HierarchyMailboxGuid == Guid.Empty)
         {
             base.WriteError(new RecipientTaskException(MrsStrings.PublicFolderMailboxesNotProvisionedForMigration), ExchangeErrorCategory.ServerOperation, null);
         }
         if (this.PublicFolderConfiguration.GetLocalMailboxRecipient(this.TargetMailboxUser.ExchangeGuid) == null)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorCannotMigratePublicFolderIntoNonPublicFolderMailbox), ExchangeErrorCategory.Client, this.TargetMailboxUser);
         }
         if (base.WorkloadType == RequestWorkloadType.None)
         {
             base.WorkloadType = (((base.Flags & RequestFlags.IntraOrg) == RequestFlags.IntraOrg) ? RequestWorkloadType.Local : RequestWorkloadType.Onboarding);
         }
         base.RequestName = "PublicFolderMailboxMigration" + this.TargetMailboxUser.ExchangeGuid;
         ADObjectId          requestQueueForMailboxMigrationRequest = this.GetRequestQueueForMailboxMigrationRequest();
         DatabaseIdParameter databaseIdParameter = new DatabaseIdParameter(requestQueueForMailboxMigrationRequest);
         ADObjectId          mdbServerSite       = null;
         MailboxDatabase     mailboxDatabase     = base.CheckDatabase <MailboxDatabase>(databaseIdParameter, NewRequest <PublicFolderMailboxMigrationRequest> .DatabaseSide.RequestStorage, this.Organization, out empty, out empty2, out mdbServerSite, out num);
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.CurrentOrgConfigSession.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         base.MdbId         = mailboxDatabase.Id;
         base.MdbServerSite = mdbServerSite;
         base.RequestName   = this.CheckRequestNameAvailability(base.RequestName, null, false, MRSRequestType.PublicFolderMailboxMigration, this.TargetMailbox, false);
         if (base.CheckRequestOfTypeExists(MRSRequestType.PublicFolderMigration))
         {
             base.WriteError(new MultiplePublicFolderMigrationTypesNotAllowedException(), ExchangeErrorCategory.Client, this.Organization);
         }
         this.ValidateCSV();
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Пример #15
0
        protected void ResolveDatabaseAndServer()
        {
            DatabaseIdParameter databaseIdParameter   = this.Database;
            ServerIdParameter   serverIdParameter     = this.Server ?? new ServerIdParameter();
            ActiveManager       activeManagerInstance = ActiveManager.GetActiveManagerInstance();

            if (this.Identity != null)
            {
                bool flag = false;
                if (this.isRunningLogonStatisticsTask)
                {
                    TIdentity tidentity            = this.Identity;
                    IEnumerable <Database> objects = tidentity.GetObjects <Database>(null, base.GlobalConfigSession);
                    foreach (Database item in objects)
                    {
                        this.databases.Add(item);
                    }
                    if (this.databases.Count > 0)
                    {
                        if (this.databases[0].Server == null)
                        {
                            string    name       = typeof(Database).Name;
                            TIdentity tidentity2 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name, tidentity2.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databases[0].Guid);
                        serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                        if (string.IsNullOrEmpty(this.databases[0].ExchangeLegacyDN))
                        {
                            string    name2      = typeof(Database).Name;
                            TIdentity tidentity3 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name2, tidentity3.ToString(), DatabaseSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        this.identity = new MailboxId(this.databases[0].ExchangeLegacyDN);
                        flag          = true;
                    }
                }
                if (!flag)
                {
                    IIdentityParameter  id            = this.Identity;
                    IConfigDataProvider session       = this.readOnlyRecipientSession;
                    ObjectId            rootID        = null;
                    TIdentity           tidentity4    = this.Identity;
                    LocalizedString?    notFoundError = new LocalizedString?(Strings.ErrorMailboxNotFound(tidentity4.ToString()));
                    TIdentity           tidentity5    = this.Identity;
                    ADRecipient         adrecipient   = (ADRecipient)base.GetDataObject <ADRecipient>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorMailboxNotUnique(tidentity5.ToString())));
                    Guid       guid = Guid.Empty;
                    string     mailboxExchangeLegacyDn = null;
                    ADObjectId adobjectId = null;
                    if (string.IsNullOrEmpty(adrecipient.LegacyExchangeDN))
                    {
                        string    name3      = typeof(ADRecipient).Name;
                        TIdentity tidentity6 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name3, tidentity6.ToString(), ADRecipientSchema.LegacyExchangeDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                    }
                    ADUser                   aduser                   = adrecipient as ADUser;
                    ADSystemMailbox          adsystemMailbox          = adrecipient as ADSystemMailbox;
                    ADSystemAttendantMailbox adsystemAttendantMailbox = adrecipient as ADSystemAttendantMailbox;
                    ADPublicDatabase         adpublicDatabase         = adrecipient as ADPublicDatabase;
                    if (aduser != null)
                    {
                        if (this.isRunningMailboxStatisticsTask && aduser.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox && !this.GetAuditLogMailboxStatistics())
                        {
                            TIdentity tidentity7 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientNotFoundException(tidentity7.ToString())), ErrorCategory.InvalidArgument, null);
                        }
                        bool archiveMailboxStatistics = this.GetArchiveMailboxStatistics();
                        if (aduser.RecipientType == RecipientType.MailUser && !archiveMailboxStatistics)
                        {
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientTypeNotValid(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                        }
                        RecipientIdParameter recipientIdParameter = this.Identity as RecipientIdParameter;
                        if (this.isRunningMailboxStatisticsTask && recipientIdParameter != null && recipientIdParameter.RawMailboxGuidInvolvedInSearch != Guid.Empty && aduser.MailboxLocations != null)
                        {
                            IMailboxLocationInfo mailboxLocation = aduser.MailboxLocations.GetMailboxLocation(recipientIdParameter.RawMailboxGuidInvolvedInSearch);
                            if (mailboxLocation != null)
                            {
                                guid       = mailboxLocation.MailboxGuid;
                                adobjectId = mailboxLocation.DatabaseLocation;
                            }
                        }
                        if (guid == Guid.Empty || adobjectId == null)
                        {
                            if (archiveMailboxStatistics)
                            {
                                if (aduser.ArchiveGuid != Guid.Empty)
                                {
                                    if (aduser.ArchiveDomain != null)
                                    {
                                        base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                                    }
                                    else
                                    {
                                        guid       = aduser.ArchiveGuid;
                                        adobjectId = (aduser.ArchiveDatabase ?? aduser.Database);
                                    }
                                }
                                else
                                {
                                    base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                                }
                            }
                            else
                            {
                                guid       = aduser.ExchangeGuid;
                                adobjectId = aduser.Database;
                            }
                        }
                        mailboxExchangeLegacyDn = aduser.LegacyExchangeDN;
                    }
                    else if (adsystemMailbox != null)
                    {
                        guid = adsystemMailbox.ExchangeGuid;
                        mailboxExchangeLegacyDn = adsystemMailbox.LegacyExchangeDN;
                        adobjectId = adsystemMailbox.Database;
                    }
                    else if (adsystemAttendantMailbox != null)
                    {
                        guid = adsystemAttendantMailbox.Guid;
                        mailboxExchangeLegacyDn = adsystemAttendantMailbox.LegacyExchangeDN;
                        adobjectId = adsystemAttendantMailbox.Database;
                    }
                    else if (adpublicDatabase != null)
                    {
                        mailboxExchangeLegacyDn = adpublicDatabase.LegacyExchangeDN;
                        adobjectId = (ADObjectId)adpublicDatabase.Identity;
                    }
                    if (adobjectId == null)
                    {
                        string    name4      = adrecipient.GetType().Name;
                        TIdentity tidentity8 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name4, tidentity8.ToString(), IADMailStorageSchema.Database.Name)), ErrorCategory.InvalidArgument, adrecipient);
                    }
                    databaseIdParameter = new DatabaseIdParameter(adobjectId);
                    if (this.isRunningLogonStatisticsTask)
                    {
                        this.identity = new MailboxId(mailboxExchangeLegacyDn);
                    }
                    else
                    {
                        this.identity = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid);
                    }
                }
            }
            if (databaseIdParameter != null)
            {
                databaseIdParameter.AllowLegacy = true;
                LocalizedString empty  = LocalizedString.Empty;
                LocalizedString empty2 = LocalizedString.Empty;
                Database        database;
                if (this.isRunningLogonStatisticsTask)
                {
                    database = (Database)base.GetDataObject <Database>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                else
                {
                    database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                if (database.Server == null)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(this.isRunningLogonStatisticsTask ? typeof(Database).Name : typeof(MailboxDatabase).Name, databaseIdParameter.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database);
                }
                this.databases = new List <Database>(new Database[]
                {
                    database
                });
                if (this.CopyOnServer != null)
                {
                    serverIdParameter = this.CopyOnServer;
                }
                else
                {
                    DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid);
                    serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                }
            }
            if (this.Server != null)
            {
                serverIdParameter = this.Server;
                this.server       = MapiTaskHelper.GetMailboxServer(this.Server, base.GlobalConfigSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            else
            {
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, base.GlobalConfigSession, null, new LocalizedString?((this.Identity == null && this.Database == null) ? Strings.ErrorLocalMachineIsNotExchangeServer : Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    if (this.Identity != null)
                    {
                        TIdentity tidentity9 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxInNonMailboxServer(tidentity9.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    if (this.Database != null)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorDatabaseInNonMailboxServer(this.Database.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
            }
            if (string.IsNullOrEmpty(this.server.ExchangeLegacyDN))
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, serverIdParameter.ToString(), ServerSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (this.databases.Count == 0)
            {
                if (this.isRunningLogonStatisticsTask)
                {
                    this.FilterActiveDatabases(activeManagerInstance, this.server.GetDatabases());
                    return;
                }
                this.FilterActiveDatabases(activeManagerInstance, this.server.GetMailboxDatabases());
            }
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         string     empty      = string.Empty;
         string     empty2     = string.Empty;
         int        num        = 0;
         ADObjectId adobjectId = null;
         if (base.ParameterSetName.Equals("MigrationOutlookAnywherePublicFolder"))
         {
             IConfigurationSession session = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
             if (this.Organization == null)
             {
                 this.Organization = new OrganizationIdParameter(base.CurrentOrganizationId.OrganizationalUnit);
             }
             ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Organization, session, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString())));
             base.RescopeToOrgId(adorganizationalUnit.OrganizationId);
             base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull);
         }
         else if (base.ParameterSetName.Equals("MigrationLocalPublicFolder"))
         {
             base.OrganizationId = OrganizationId.ForestWideOrgId;
             base.Flags          = (RequestFlags.IntraOrg | RequestFlags.Pull);
             PublicFolderDatabase publicFolderDatabase = base.CheckDatabase <PublicFolderDatabase>(this.SourceDatabase, NewRequest <PublicFolderMigrationRequest> .DatabaseSide.Source, this.SourceDatabase, out empty, out empty2, out adobjectId, out num);
             this.sourceDatabase = publicFolderDatabase.Id;
         }
         if (base.WorkloadType == RequestWorkloadType.None)
         {
             base.WorkloadType = (((base.Flags & RequestFlags.IntraOrg) == RequestFlags.IntraOrg) ? RequestWorkloadType.Local : RequestWorkloadType.Onboarding);
         }
         if (!string.IsNullOrEmpty(this.Name))
         {
             base.ValidateName();
             base.RequestName = this.Name;
         }
         else
         {
             base.RequestName = "PublicFolderMigration";
         }
         ADObjectId          adObjectId          = this.AutoSelectRequestQueueForPFRequest(base.OrganizationId);
         DatabaseIdParameter databaseIdParameter = new DatabaseIdParameter(adObjectId);
         ADObjectId          mdbServerSite       = null;
         MailboxDatabase     mailboxDatabase     = base.CheckDatabase <MailboxDatabase>(databaseIdParameter, NewRequest <PublicFolderMigrationRequest> .DatabaseSide.RequestStorage, this.Organization, out empty, out empty2, out mdbServerSite, out num);
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.CurrentOrgConfigSession.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         base.MdbId         = mailboxDatabase.Id;
         base.MdbServerSite = mdbServerSite;
         this.CheckRequestNameAvailability(null, null, false, MRSRequestType.PublicFolderMigration, this.Organization, false);
         if (base.CheckRequestOfTypeExists(MRSRequestType.PublicFolderMailboxMigration))
         {
             base.WriteError(new MultiplePublicFolderMigrationTypesNotAllowedException(), ExchangeErrorCategory.Client, this.Organization);
         }
         this.publicFolderConfiguration = TenantPublicFolderConfigurationCache.Instance.GetValue(base.OrganizationId);
         if (this.publicFolderConfiguration.HeuristicsFlags.HasFlag(HeuristicsFlags.PublicFolderMigrationComplete))
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorPublicFolderMigrationCompletedPreviously), ExchangeErrorCategory.Client, null);
         }
         this.ValidateCSV();
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Пример #17
0
        protected override void InternalValidate()
        {
            this.ResetForParametersFromPipeline();
            SearchTestResult searchTestResult = SearchTestResult.DefaultSearchTestResult;
            Exception        ex = null;

            try
            {
                if (this.Identity != null)
                {
                    base.InternalValidate();
                    ADUser dataObject = this.DataObject;
                    searchTestResult = this.GetTestResultFromMailbox(dataObject);
                    this.CheckDatabaseRecoveryAndIndexEnabled(this.GetMailboxDatabase(DatabaseIdParameter.Parse(dataObject.Database.Name)), searchTestResult);
                    this.WriteProgress(Strings.TestSearchCurrentMailbox(dataObject.DisplayName));
                    this.monitor.AddMonitoringEvent(searchTestResult, Strings.TestSearchCurrentMailbox(dataObject.DisplayName));
                    this.searchTestResults.Add(searchTestResult);
                }
                else
                {
                    List <MailboxDatabase> list = new List <MailboxDatabase>(1);
                    if (this.MailboxDatabase != null)
                    {
                        MailboxDatabase mailboxDatabase = this.GetMailboxDatabase(this.MailboxDatabase);
                        list.Add(mailboxDatabase);
                    }
                    else
                    {
                        if (this.Server == null)
                        {
                            this.Server = ServerIdParameter.Parse(Environment.MachineName);
                        }
                        Server server = this.GetServer(this.Server);
                        foreach (MailboxDatabase item in server.GetMailboxDatabases())
                        {
                            list.Add(item);
                        }
                        if (list.Count == 0)
                        {
                            throw new RecipientTaskException(Strings.TestSearchServerNoMdbs(server.Name));
                        }
                    }
                    foreach (MailboxDatabase mailboxDatabase2 in list)
                    {
                        searchTestResult = this.GetTestResultFromMailboxDatabase(mailboxDatabase2);
                        this.CheckDatabaseRecoveryAndIndexEnabled(mailboxDatabase2, searchTestResult);
                        this.WriteProgress(Strings.TestSearchCurrentMDB(mailboxDatabase2.Name));
                        this.monitor.AddMonitoringEvent(searchTestResult, Strings.TestSearchCurrentMDB(mailboxDatabase2.Name));
                        this.searchTestResults.Add(searchTestResult);
                    }
                }
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADExternalException ex3)
            {
                ex = ex3;
            }
            catch (DatabaseNotFoundException ex4)
            {
                ex = ex4;
            }
            catch (ServerNotFoundException ex5)
            {
                ex = ex5;
            }
            catch (ObjectNotFoundException ex6)
            {
                ex = ex6;
            }
            catch (StorageTransientException ex7)
            {
                ex = ex7;
            }
            catch (StoragePermanentException ex8)
            {
                ex = ex8;
            }
            catch (RecipientTaskException ex9)
            {
                ex = ex9;
            }
            finally
            {
                if (ex is StorageTransientException || ex is StoragePermanentException)
                {
                    searchTestResult.SetErrorTestResult(EventId.ActiveManagerError, new LocalizedString(ex.Message));
                    this.WriteTestResult(searchTestResult);
                    base.WriteError(ex, ErrorCategory.ResourceUnavailable, null);
                }
                else if (ex != null)
                {
                    searchTestResult.SetErrorTestResult(EventId.ADError, new LocalizedString(ex.Message));
                    this.WriteTestResult(searchTestResult);
                    base.WriteError(ex, ErrorCategory.ResourceUnavailable, null);
                }
            }
        }
Пример #18
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);
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            ADObjectId  adobjectId  = null;
            ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.Identity, this.recipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Identity.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Identity.ToString())));
            ADUser      aduser      = adrecipient as ADUser;

            if (aduser != null)
            {
                this.exchangeGuid = aduser.ExchangeGuid;
                adobjectId        = aduser.Database;
            }
            else
            {
                ADSystemMailbox adsystemMailbox = adrecipient as ADSystemMailbox;
                if (adsystemMailbox != null)
                {
                    this.exchangeGuid = adsystemMailbox.ExchangeGuid;
                    adobjectId        = adsystemMailbox.Database;
                }
            }
            if (adobjectId == null)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(adrecipient.GetType().Name, this.Identity.ToString(), IADMailStorageSchema.Database.Name)), ErrorCategory.InvalidArgument, adrecipient);
            }
            DatabaseIdParameter id = new DatabaseIdParameter(adobjectId);

            this.database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(id, this.systemConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(adobjectId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(adobjectId.ToString())));
            try
            {
                this.dbLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(this.database.Id.ObjectGuid);
                this.server         = this.DbLocationInfo.ServerFqdn.Split(new char[]
                {
                    '.'
                })[0];
            }
            catch (DatabaseNotFoundException exception)
            {
                base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null);
            }
            catch (ObjectNotFoundException exception2)
            {
                base.WriteError(exception2, ExchangeErrorCategory.ServerOperation, null);
            }
            try
            {
                if (this.registryKeyHive == null)
                {
                    this.registryKeyHive = this.OpenHive(this.dbLocationInfo.ServerFqdn);
                }
            }
            catch (IOException ex)
            {
                base.WriteError(new FailedMailboxQuarantineException(this.Identity.ToString(), ex.ToString()), ErrorCategory.ObjectNotFound, null);
            }
            catch (SecurityException ex2)
            {
                base.WriteError(new FailedMailboxQuarantineException(this.Identity.ToString(), ex2.ToString()), ErrorCategory.SecurityError, null);
            }
            catch (UnauthorizedAccessException ex3)
            {
                base.WriteError(new FailedMailboxQuarantineException(this.Identity.ToString(), ex3.ToString()), ErrorCategory.PermissionDenied, null);
            }
            TaskLogger.LogExit();
        }