예제 #1
0
        private SearchTestResult GetTestResultFromMailboxDatabase(MailboxDatabase mdb)
        {
            if (mdb == null)
            {
                throw new ArgumentNullException("mdb");
            }
            SearchTestResult defaultSearchTestResult = SearchTestResult.DefaultSearchTestResult;

            defaultSearchTestResult.Database     = mdb.ToString();
            defaultSearchTestResult.DatabaseGuid = mdb.Guid;
            Server activeServer = this.GetActiveServer(mdb.Guid);

            defaultSearchTestResult.Server     = activeServer.Name;
            defaultSearchTestResult.ServerGuid = activeServer.Guid;
            ADUser monitoringMailbox = this.GetMonitoringMailbox(mdb, activeServer);

            if (monitoringMailbox == null)
            {
                throw new ManagementObjectNotFoundException(Strings.TestSearchMdbMonitorMbxIsNull(mdb.ToString()));
            }
            defaultSearchTestResult.UserLegacyExchangeDN = monitoringMailbox.LegacyExchangeDN;
            defaultSearchTestResult.Mailbox     = monitoringMailbox.DisplayName;
            defaultSearchTestResult.MailboxGuid = monitoringMailbox.ExchangeGuid;
            return(defaultSearchTestResult);
        }
예제 #2
0
 protected override IConfigurable PrepareDataObject()
 {
     try
     {
         if (base.ParameterSetName.Equals("Identity"))
         {
             TransactionalRequestJob transactionalRequestJob = (TransactionalRequestJob)base.PrepareDataObject();
             if (transactionalRequestJob == null)
             {
                 if (this.mrCondition == RemoveMoveRequest.MoveRequestCondition.None)
                 {
                     this.mrCondition = RemoveMoveRequest.MoveRequestCondition.MissingMR;
                 }
                 MrsTracer.Cmdlet.Warning("Move Request is missing in the MDB", new object[0]);
                 transactionalRequestJob = RequestJobBase.CreateDummyObject <TransactionalRequestJob>();
             }
             return(transactionalRequestJob);
         }
         base.LocalADUser = null;
         MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.MoveRequestQueue, base.ConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(this.MoveRequestQueue.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(this.MoveRequestQueue.ToString())));
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         Guid guid = mailboxDatabase.Guid;
         this.moveRequestQueueName    = mailboxDatabase.ToString();
         base.MRProvider.AllowInvalid = true;
         return((TransactionalRequestJob)base.MRProvider.Read <TransactionalRequestJob>(new RequestJobObjectId(this.MailboxGuid, guid, null)));
     }
     catch (MapiExceptionMdbOffline e)
     {
         this.HandleMdbDownException(e);
     }
     catch (MapiExceptionLogonFailed e2)
     {
         this.HandleMdbDownException(e2);
     }
     return(RequestJobBase.CreateDummyObject <TransactionalRequestJob>());
 }
 private void SetTargetParameters()
 {
     if (base.Task.AutoDiscoverTargetMailboxServer.IsPresent)
     {
         base.Task.TargetMailboxServer = this.AutoDiscoverTargetServer();
     }
     if (base.Task.TargetMailboxServer != null)
     {
         this.targetMailboxServer = this.GetServerFromId(base.Task.TargetMailboxServer);
         ADSystemMailbox adsystemMailbox = null;
         try
         {
             this.targetSystemMailboxMdb = base.GetServerMdb(this.targetMailboxServer);
             adsystemMailbox             = base.GetSystemMailboxFromMdb(this.targetSystemMailboxMdb);
             this.targetServerHasMdb     = true;
         }
         catch (MailboxServerNotHostingMdbException)
         {
             this.targetServerHasMdb = false;
         }
         if (this.targetServerHasMdb)
         {
             this.targetMailboxAddress  = adsystemMailbox.PrimarySmtpAddress.ToString();
             this.friendlyTargetAddress = base.Task.TargetMailboxServer.ToString() + "\\" + this.targetMailboxAddress;
             return;
         }
     }
     else if (base.Task.TargetDatabase != null)
     {
         MailboxDatabase      mailboxDatabase       = (MailboxDatabase)base.Task.GetAdDataObject <MailboxDatabase>(base.Task.TargetDatabase, base.Task.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(base.Task.TargetDatabase.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(base.Task.TargetDatabase.ToString())));
         ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
         DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(mailboxDatabase.Guid);
         if (serverForDatabase != null && !string.IsNullOrEmpty(serverForDatabase.ServerFqdn))
         {
             base.Task.TargetMailboxServer = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
             this.targetMailboxServer      = this.GetServerFromId(base.Task.TargetMailboxServer);
             ADSystemMailbox systemMailboxFromMdb = base.GetSystemMailboxFromMdb(mailboxDatabase);
             this.targetSystemMailboxMdb = mailboxDatabase;
             this.targetMailboxAddress   = systemMailboxFromMdb.PrimarySmtpAddress.ToString();
             this.friendlyTargetAddress  = base.Task.TargetMailboxServer.ToString() + "\\" + this.targetMailboxAddress;
             return;
         }
         base.WriteErrorAndMonitoringEvent(new MdbServerNotFoundException(mailboxDatabase.ToString()), ErrorCategory.InvalidData, 1011);
         return;
     }
     else if (base.Task.TargetEmailAddress != null)
     {
         this.targetMailboxAddress = base.Task.TargetEmailAddress;
         if (string.IsNullOrEmpty(base.Task.TargetEmailAddressDisplayName))
         {
             this.friendlyTargetAddress = base.Task.TargetEmailAddress;
         }
         else
         {
             this.friendlyTargetAddress = base.Task.TargetEmailAddressDisplayName + "(" + base.Task.TargetEmailAddress + ")";
         }
         RoutingAddress routingAddress = new RoutingAddress(base.Task.TargetEmailAddress);
         if (!routingAddress.IsValid)
         {
             base.WriteErrorAndMonitoringEvent(new RecipientTaskException(Strings.TestMailflowInvalidTargetEmailAddress(base.Task.TargetEmailAddress)), ErrorCategory.InvalidData, 1008);
         }
     }
 }
예제 #4
0
 protected override IConfigurable PrepareDataObject()
 {
     this.brokenIndexEntry = null;
     this.indexEntries.Clear();
     try
     {
         if (base.ParameterSetName.Equals("Identity"))
         {
             TransactionalRequestJob transactionalRequestJob = (TransactionalRequestJob)base.PrepareDataObject();
             if (transactionalRequestJob == null)
             {
                 if (this.requestCondition == RemoveRequest <TIdentity> .RequestCondition.None)
                 {
                     this.requestCondition = RemoveRequest <TIdentity> .RequestCondition.MissingRJ;
                     this.indexEntries.Add(base.IndexEntry);
                 }
                 else
                 {
                     this.indexEntries.Add(this.brokenIndexEntry);
                 }
                 MrsTracer.Cmdlet.Warning("Request is missing from the MDB", new object[0]);
                 transactionalRequestJob = RequestJobBase.CreateDummyObject <TransactionalRequestJob>();
             }
             else
             {
                 this.indexEntries.AddRange(transactionalRequestJob.IndexEntries);
                 if (!this.indexEntries.Contains(base.IndexEntry))
                 {
                     this.indexEntries.Add(base.IndexEntry);
                 }
             }
             return(transactionalRequestJob);
         }
         base.IndexEntry = null;
         MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.RequestQueue, base.ConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(this.RequestQueue.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(this.RequestQueue.ToString())));
         MailboxTaskHelper.VerifyDatabaseIsWithinScopeForRecipientCmdlets(base.CurrentOrgConfigSession.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
         Guid guid = mailboxDatabase.Guid;
         this.requestQueueName        = mailboxDatabase.ToString();
         base.RJProvider.AllowInvalid = true;
         TransactionalRequestJob transactionalRequestJob2 = null;
         try
         {
             transactionalRequestJob2 = (TransactionalRequestJob)base.RJProvider.Read <TransactionalRequestJob>(new RequestJobObjectId(this.RequestGuid, guid, null));
             if (transactionalRequestJob2 != null)
             {
                 if (transactionalRequestJob2.TargetUser != null && transactionalRequestJob2.TargetUserId != null)
                 {
                     this.ResolveADUser(transactionalRequestJob2.TargetUserId);
                 }
                 if (transactionalRequestJob2.SourceUser != null && transactionalRequestJob2.SourceUserId != null)
                 {
                     this.ResolveADUser(transactionalRequestJob2.SourceUserId);
                 }
             }
             TransactionalRequestJob result = transactionalRequestJob2;
             transactionalRequestJob2 = null;
             return(result);
         }
         finally
         {
             if (transactionalRequestJob2 != null)
             {
                 transactionalRequestJob2.Dispose();
                 transactionalRequestJob2 = null;
             }
         }
     }
     catch (MapiExceptionMdbOffline e)
     {
         this.HandleMdbDownException(e);
         this.indexEntries.Add(base.IndexEntry);
     }
     catch (MapiExceptionLogonFailed e2)
     {
         this.HandleMdbDownException(e2);
         this.indexEntries.Add(base.IndexEntry);
     }
     return(RequestJobBase.CreateDummyObject <TransactionalRequestJob>());
 }