Exemplo n.º 1
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            if (this.Identity != null)
            {
                this.Server = ServerIdParameter.Parse(this.Identity.Server);
            }
            if (this.Server == null || string.Compare(this.Server.ToString(), "localhost", true) == 0)
            {
                this.Server = new ServerIdParameter();
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(base.CurrentOrganizationId), 263, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\Queueviewer\\QueueTasks.cs");
            ServerIdParameter     server = this.Server;
            Server           entry       = (Server)this.GetDataObject <Server>(server, tenantOrTopologyConfigurationSession, null, null, Strings.ErrorServerNotFound(server.ToString()), Strings.ErrorServerNotUnique(server.ToString()));
            ADScopeException ex;

            if (!tenantOrTopologyConfigurationSession.TryVerifyIsWithinScopes(entry, true, out ex))
            {
                base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeObjectOutOfWriteScope((this.Identity != null) ? this.Identity.ToString() : this.Server.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ExchangeErrorCategory.Context, this.Identity);
            }
            if (this.Filter != null && !VersionedQueueViewerClient.UsePropertyBagBasedAPI((string)this.Server))
            {
                this.InitializeInnerFilter <QueueInfoSchema>(this.Filter, ObjectSchema.GetInstance <QueueInfoSchema>());
            }
        }
Exemplo n.º 2
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (!this.Identity.IsUnique())
            {
                base.WriteError(new NonUniqueEventCategoryInputException(), ErrorCategory.InvalidData, this.Identity);
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 148, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\EventLog\\SetEventLogLevel.cs");
            EventCategoryIdentity         eventCategoryIdentity        = null;

            if (this.Identity.ToString() != null)
            {
                eventCategoryIdentity = EventCategoryIdentity.Parse(this.Identity.ToString());
            }
            Server obj;

            if (eventCategoryIdentity == null || string.IsNullOrEmpty(eventCategoryIdentity.Server))
            {
                obj = topologyConfigurationSession.FindLocalServer();
            }
            else
            {
                ServerIdParameter serverIdParameter = ServerIdParameter.Parse(eventCategoryIdentity.Server);
                obj = (Server)base.GetDataObject <Server>(serverIdParameter, topologyConfigurationSession, null, null, new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())));
            }
            ADSessionSettings sessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);

            MapiTaskHelper.VerifyIsWithinConfigWriteScope(sessionSettings, obj, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
        }
Exemplo n.º 3
0
        internal static Server ResolveExpansionServer(string expansionServer, ITopologyConfigurationSession scSession, DataAccessHelper.CategorizedGetDataObjectDelegate getUniqueDataObjectDelegate, Task.ErrorLoggerDelegate errorHandler)
        {
            if (string.IsNullOrEmpty(expansionServer))
            {
                throw new ArgumentNullException("expansionServer");
            }
            if (scSession == null)
            {
                throw new ArgumentNullException("scSession");
            }
            if (getUniqueDataObjectDelegate == null)
            {
                throw new ArgumentNullException("getUniqueDataObjectDelegate");
            }
            if (errorHandler == null)
            {
                throw new ArgumentNullException("errorHandler");
            }
            ServerIdParameter id = null;

            try
            {
                id = ServerIdParameter.Parse(expansionServer);
            }
            catch (ArgumentException)
            {
                errorHandler(new TaskArgumentException(Strings.ErrorInvalidExpansionServer(expansionServer)), ExchangeErrorCategory.Client, null);
            }
            return((Server)getUniqueDataObjectDelegate(id, scSession, null, null, new LocalizedString?(Strings.ErrorServerNotFound(expansionServer)), new LocalizedString?(Strings.ErrorServerNotUnique(expansionServer)), ExchangeErrorCategory.Client));
        }
Exemplo n.º 4
0
 internal override void InitializeInnerFilter <Object>(QueueViewerPropertyDefinition <Object> messageIdentity, QueueViewerPropertyDefinition <Object> queueIdentity)
 {
     if (this.Identity != null)
     {
         if (this.Identity.IsFullySpecified)
         {
             this.innerFilter = new ComparisonFilter(ComparisonOperator.Equal, messageIdentity, this.Identity);
         }
         else
         {
             this.innerFilter = new TextFilter(messageIdentity, this.Identity.ToString(), MatchOptions.FullString, MatchFlags.Default);
         }
         base.Server = ServerIdParameter.Parse(this.Identity.QueueIdentity.Server);
         return;
     }
     if (this.Queue != null)
     {
         if (this.Queue.IsFullySpecified)
         {
             this.innerFilter = new ComparisonFilter(ComparisonOperator.Equal, queueIdentity, this.Queue);
         }
         else
         {
             this.innerFilter = new TextFilter(queueIdentity, this.Queue.ToString(), MatchOptions.FullString, MatchFlags.Default);
         }
         base.Server = ServerIdParameter.Parse(this.Queue.Server);
     }
 }
Exemplo n.º 5
0
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (base.HasErrors)
     {
         return;
     }
     if (this.Identity != null)
     {
         this.Server = ServerIdParameter.Parse(this.Identity.QueueIdentity.Server);
     }
 }
Exemplo n.º 6
0
        private void ResolveDatabaseAndServer()
        {
            ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance();

            if (this.Server != null)
            {
                this.server = MapiTaskHelper.GetMailboxServer(this.Server, (ITopologyConfigurationSession)this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            else if (this.Identity != null)
            {
                DatabaseIdParameter identity = this.Identity;
                identity.AllowLegacy = false;
                Database          database = (Database)base.GetDataObject <Database>(identity, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(identity.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(identity.ToString())));
                ServerIdParameter serverIdParameter;
                if (this.CopyOnServer != null)
                {
                    serverIdParameter = this.CopyOnServer;
                }
                else
                {
                    if (database.Server == null)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Database).Name, identity.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database);
                    }
                    DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid);
                    serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                }
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
                this.databases = new List <Database>(new Database[]
                {
                    database
                });
            }
            else
            {
                ServerIdParameter serverIdParameter2 = new ServerIdParameter();
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter2, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorLocalMachineIsNotExchangeServer), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter2.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
            }
            if (this.databases.Count == 0)
            {
                this.databases = StoreCommon.PopulateDatabasesFromServer(activeManagerInstance, this.server, this.IncludePassive);
            }
        }
Exemplo n.º 7
0
        protected override IConfigurable PrepareDataObject()
        {
            ADGroup adgroup = null;

            this.configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 197, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\permission\\DelegateBaseTask.cs");
            if (this.Role == DelegateRoleType.ServerAdmin)
            {
                ServerIdParameter serverIdParameter = null;
                try
                {
                    serverIdParameter = ServerIdParameter.Parse(this.Scope);
                }
                catch (ArgumentException exception)
                {
                    base.WriteError(exception, ErrorCategory.InvalidData, null);
                }
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, this.configSession, null, new LocalizedString?(Strings.ErrorServerNotFound((string)serverIdParameter)), new LocalizedString?(Strings.ErrorServerNotUnique((string)serverIdParameter)));
            }
            IRecipientSession recipientSession = (IRecipientSession)base.DataSession;
            bool useGlobalCatalog = recipientSession.UseGlobalCatalog;

            recipientSession.UseGlobalCatalog = true;
            try
            {
                if (this.Role == DelegateRoleType.OrgAdmin)
                {
                    adgroup = ((IDirectorySession)base.DataSession).ResolveWellKnownGuid <ADGroup>(WellKnownGuid.EoaWkGuid, this.ConfigurationSession.ConfigurationNamingContext.ToDNString());
                }
                else if (this.Role == DelegateRoleType.RecipientAdmin)
                {
                    adgroup = ((IDirectorySession)base.DataSession).ResolveWellKnownGuid <ADGroup>(WellKnownGuid.EmaWkGuid, this.ConfigurationSession.ConfigurationNamingContext.ToDNString());
                }
                else if (this.Role == DelegateRoleType.PublicFolderAdmin)
                {
                    adgroup = ((IDirectorySession)base.DataSession).ResolveWellKnownGuid <ADGroup>(WellKnownGuid.EpaWkGuid, this.ConfigurationSession.ConfigurationNamingContext.ToDNString());
                }
                else if (this.Role == DelegateRoleType.ViewOnlyAdmin || this.Role == DelegateRoleType.ServerAdmin)
                {
                    adgroup = ((IDirectorySession)base.DataSession).ResolveWellKnownGuid <ADGroup>(WellKnownGuid.EraWkGuid, this.ConfigurationSession.ConfigurationNamingContext.ToDNString());
                }
            }
            finally
            {
                recipientSession.UseGlobalCatalog = useGlobalCatalog;
            }
            if (adgroup == null)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorExchangeAdministratorsGroupNotFound(this.Role.ToString(), this.Identity.ToString())), ErrorCategory.InvalidData, this.Role);
            }
            return(adgroup);
        }
        private ServerIdParameter AutoDiscoverTargetServer()
        {
            ServerIdParameter      result        = base.Task.Identity;
            ADPagedReader <Server> adpagedReader = base.Task.ConfigurationSession.FindAllPaged <Server>();

            foreach (Server server in adpagedReader)
            {
                if (server.IsExchange2007OrLater && server.IsMailboxServer && (!string.Equals(server.Name, base.SourceMailboxServer.Name) || (server.ServerSite != null && base.SourceMailboxServer.ServerSite != null && !string.Equals(server.ServerSite.Name, base.SourceMailboxServer.ServerSite.Name, StringComparison.OrdinalIgnoreCase))))
                {
                    result = ServerIdParameter.Parse(server.Identity.ToString());
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 9
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (base.HasErrors)
     {
         TaskLogger.LogExit();
         return;
     }
     if (this.Server == null)
     {
         this.Server = ServerIdParameter.Parse("localhost");
     }
     this.ResolveTargetServer();
     TaskLogger.LogExit();
 }
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (base.HasErrors)
     {
         return;
     }
     if (base.Identity == null && this.Server == null)
     {
         this.Server = ServerIdParameter.Parse("localhost");
     }
     if (this.Filter != null && !VersionedQueueViewerClient.UsePropertyBagBasedAPI((string)this.Server))
     {
         this.InitializeInnerFilter <MessageInfoSchema>(this.Filter, ObjectSchema.GetInstance <MessageInfoSchema>());
     }
 }
 internal override void InternalValidate()
 {
     base.InternalValidate();
     base.IsRemoteTest = (!string.IsNullOrEmpty(base.Task.TargetEmailAddress) || base.Task.TargetMailboxServer != null || base.Task.TargetDatabase != null || base.Task.AutoDiscoverTargetMailboxServer.IsPresent);
     if (base.IsRemoteTest)
     {
         base.SetMonitoringDataSourceType("Remote");
     }
     else
     {
         base.SetMonitoringDataSourceType("Local");
     }
     if (base.Task.Identity == null)
     {
         string machineName = Environment.MachineName;
         base.Task.Identity = ServerIdParameter.Parse(machineName);
     }
     base.SourceMailboxServer = this.GetServerFromId(base.Task.Identity);
     try
     {
         base.SourceSystemMailboxMdb = base.GetServerMdb(base.SourceMailboxServer);
         base.SourceSystemMailbox    = base.GetSystemMailboxFromMdb(base.SourceSystemMailboxMdb);
         this.sourceServerHasMdb     = true;
     }
     catch (MailboxServerNotHostingMdbException)
     {
         this.sourceServerHasMdb = false;
     }
     if (this.sourceServerHasMdb)
     {
         this.friendlySourceAddress = base.Task.Identity.ToString() + "\\" + base.SourceSystemMailbox.PrimarySmtpAddress.ToString();
         if (!base.IsRemoteTest)
         {
             this.targetMailboxAddress  = base.SourceSystemMailbox.PrimarySmtpAddress.ToString();
             this.friendlyTargetAddress = this.friendlySourceAddress;
             return;
         }
         this.SetTargetParameters();
     }
 }
Exemplo n.º 12
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;
        }
Exemplo n.º 13
0
        private void ValidateIncludeExclude()
        {
            QueueViewerIncludesAndExcludes exclude = this.Exclude;
            QueueViewerIncludesAndExcludes include = this.Include;

            if (exclude == null && include == null)
            {
                return;
            }
            if (this.Identity != null)
            {
                base.Server = ServerIdParameter.Parse(this.Identity.Server);
            }
            string          filter;
            LocalizedString localizedString;

            if (QueueViewerIncludesAndExcludes.ComposeFilterString(base.Filter, exclude, include, out filter, out localizedString))
            {
                base.Filter = filter;
                return;
            }
            base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidData, base.Filter);
        }
 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);
         }
     }
 }
Exemplo n.º 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());
            }
        }
Exemplo n.º 16
0
        protected override void InternalValidate()
        {
            bool flag = false;

            try
            {
                ADRecipient            adrecipient = null;
                List <MailboxDatabase> list        = new List <MailboxDatabase>();
                bool          flag2 = false;
                ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                base.TenantGlobalCatalogSession.ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout));
                this.ConfigurationSession.ServerTimeout       = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout));
                this.transactionTargets = new List <MapiTransaction>();
                if (this.Identity != null)
                {
                    if (this.EnableSoftDeletedRecipientLogon)
                    {
                        IDirectorySession directorySession = base.DataSession as IDirectorySession;
                        directorySession.SessionSettings.IncludeSoftDeletedObjects = true;
                    }
                    ADUser aduser = (ADUser)RecipientTaskHelper.ResolveDataObject <ADUser>(base.DataSession, base.TenantGlobalCatalogSession, base.ServerSettings, this.Identity, null, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                    if (this.Archive)
                    {
                        if (aduser.ArchiveDatabase == null)
                        {
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        else
                        {
                            this.Database = new DatabaseIdParameter(aduser.ArchiveDatabase);
                        }
                    }
                    else
                    {
                        this.Database = new DatabaseIdParameter(aduser.Database);
                    }
                    flag        = true;
                    adrecipient = aduser;
                }
                if (this.Database != null)
                {
                    MailboxDatabase mailboxDatabase  = null;
                    MailboxDatabase mailboxDatabase2 = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString())));
                    if (mailboxDatabase2.Recovery)
                    {
                        string name = mailboxDatabase2.Name;
                        RecoveryMailboxDatabaseNotMonitoredException exception = new RecoveryMailboxDatabaseNotMonitoredException(name);
                        this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.InvalidOperation, null, 1006, "MSExchange Monitoring MAPIConnectivity");
                        return;
                    }
                    mailboxDatabase = mailboxDatabase2;
                    if (!flag)
                    {
                        try
                        {
                            MapiTaskHelper.VerifyDatabaseAndItsOwningServerInScope(base.SessionSettings, mailboxDatabase, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
                            flag = true;
                        }
                        catch (InvalidOperationException exception2)
                        {
                            this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.InvalidOperation, null, 1005, "MSExchange Monitoring MAPIConnectivity");
                            return;
                        }
                    }
                    list.Add(mailboxDatabase);
                    if (this.CopyOnServer != null)
                    {
                        this.Server = this.CopyOnServer;
                    }
                    else
                    {
                        DatabaseLocationInfo serverForDatabase = this.GetServerForDatabase(activeManagerInstance, mailboxDatabase.Guid);
                        if (serverForDatabase != null)
                        {
                            this.Server = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                        }
                        else
                        {
                            this.Server = ServerIdParameter.Parse(mailboxDatabase.Server.DistinguishedName);
                        }
                    }
                }
                if (this.Server == null)
                {
                    string machineName = Environment.MachineName;
                    this.Server = ServerIdParameter.Parse(machineName);
                }
                this.targetServer = (Server)base.GetDataObject <Server>(this.Server, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.Server.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.Server.ToString())));
                LocalizedException ex = null;
                if (!this.targetServer.IsExchange2007OrLater)
                {
                    ex = new OperationOnOldServerException(this.targetServer.Name);
                }
                else if (!this.targetServer.IsMailboxServer)
                {
                    ex = new OperationOnlyOnMailboxServerException(this.targetServer.Name);
                }
                if (ex != null)
                {
                    this.WriteErrorAndMonitoringEvent(ex, ErrorCategory.InvalidArgument, null, 1005, "MSExchange Monitoring MAPIConnectivity");
                }
                else
                {
                    if (!flag)
                    {
                        try
                        {
                            MapiTaskHelper.VerifyIsWithinConfigWriteScope(base.SessionSettings, this.targetServer, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
                        }
                        catch (InvalidOperationException exception3)
                        {
                            this.WriteErrorAndMonitoringEvent(exception3, ErrorCategory.InvalidOperation, null, 1005, "MSExchange Monitoring MAPIConnectivity");
                            return;
                        }
                    }
                    if (list.Count == 0)
                    {
                        MailboxDatabase[] mailboxDatabases = this.targetServer.GetMailboxDatabases();
                        if (mailboxDatabases.Length > 0)
                        {
                            flag2 = true;
                        }
                        foreach (MailboxDatabase mailboxDatabase3 in mailboxDatabases)
                        {
                            if (!mailboxDatabase3.AutoDagExcludeFromMonitoring)
                            {
                                if (this.IncludePassive)
                                {
                                    list.Add(mailboxDatabase3);
                                }
                                else
                                {
                                    DatabaseLocationInfo serverForDatabase = this.GetServerForDatabase(activeManagerInstance, mailboxDatabase3.Guid);
                                    if ((serverForDatabase != null && serverForDatabase.ServerGuid == this.targetServer.Guid) || (serverForDatabase == null && mailboxDatabase3.Server.ObjectGuid == this.targetServer.Guid))
                                    {
                                        list.Add(mailboxDatabase3);
                                    }
                                }
                            }
                        }
                    }
                    if (adrecipient != null)
                    {
                        this.wasTargetMailboxSpecified = true;
                        this.transactionTargets.Add(new MapiTransaction(this.targetServer, list[0], adrecipient, this.Archive, list[0].Server.ObjectGuid == this.targetServer.Guid));
                    }
                    else
                    {
                        foreach (MailboxDatabase mailboxDatabase4 in list)
                        {
                            if (!mailboxDatabase4.Recovery)
                            {
                                GeneralMailboxIdParameter id = GeneralMailboxIdParameter.Parse(string.Format(CultureInfo.InvariantCulture, "SystemMailbox{{{0}}}", new object[]
                                {
                                    mailboxDatabase4.Guid.ToString()
                                }));
                                IEnumerable <ADSystemMailbox> dataObjects = base.GetDataObjects <ADSystemMailbox>(id, base.RootOrgGlobalCatalogSession, null);
                                using (IEnumerator <ADSystemMailbox> enumerator2 = dataObjects.GetEnumerator())
                                {
                                    adrecipient = (enumerator2.MoveNext() ? enumerator2.Current : null);
                                    this.transactionTargets.Add(new MapiTransaction(this.targetServer, mailboxDatabase4, adrecipient, false, mailboxDatabase4.Server.ObjectGuid == this.targetServer.Guid));
                                }
                            }
                        }
                    }
                    this.transactionTargets.Sort();
                    if (this.transactionTargets.Count < 1)
                    {
                        if (flag2)
                        {
                            this.WriteWarning(Strings.MapiTransactionServerWithoutMdbs(this.targetServer.Name));
                            this.onlyPassives = true;
                        }
                        else
                        {
                            this.WriteErrorAndMonitoringEvent(new NoMdbForOperationException(this.targetServer.Name), ErrorCategory.ReadError, null, 1010, "MSExchange Monitoring MAPIConnectivity");
                        }
                    }
                }
            }
            finally
            {
                if (base.HasErrors && this.MonitoringContext)
                {
                    base.WriteObject(this.monitoringData);
                }
                TaskLogger.LogExit();
            }
        }
Exemplo n.º 17
0
 public TestEcpConnectivityOutcome(string virtualDirectoryName, string casServerName, string mailboxServerName, string localSite, Uri targetUri, VirtualDirectoryUriScope targetUriScope, string performanceCounterName, string userName) : base(casServerName, Strings.CasHealthEcpScenarioTestWebService, Strings.CasHealthEcpScenarioTestWebServiceDescription, performanceCounterName, localSite, targetUri != null && targetUri.AbsoluteUri != null && targetUri.AbsoluteUri.IndexOf("https", StringComparison.OrdinalIgnoreCase) == 0, userName, virtualDirectoryName, targetUri, targetUriScope)
 {
     this.MailboxServer = ((!string.IsNullOrEmpty(mailboxServerName)) ? ServerIdParameter.Parse(mailboxServerName) : null);
 }
Exemplo n.º 18
0
 public TestEcpConnectivityOutcome(string casServerName, string mailboxServerName, string scenarioName, string scenarioDescription, string performanceCounterName, string localSite, bool secureAccess, string userName, string virtualDirectoryName, Uri targetUri, VirtualDirectoryUriScope targetUriScope) : base(casServerName, scenarioName, scenarioDescription, performanceCounterName, localSite, secureAccess, userName, virtualDirectoryName, targetUri, targetUriScope)
 {
     this.MailboxServer = ((!string.IsNullOrEmpty(mailboxServerName)) ? ServerIdParameter.Parse(mailboxServerName) : null);
 }
Exemplo n.º 19
0
 internal CasTransactionOutcome(string clientAccessServer, string scenarioName, string scenarioDescription, string performanceCounterName, string localSite, bool secureAccess, string userName) : base((!string.IsNullOrEmpty(clientAccessServer)) ? ServerIdParameter.Parse(clientAccessServer).ToString() : string.Empty, scenarioName, scenarioDescription, performanceCounterName, userName)
 {
     this.LocalSite    = ((!string.IsNullOrEmpty(localSite)) ? AdSiteIdParameter.Parse(localSite).ToString() : string.Empty);
     this.SecureAccess = secureAccess;
 }
Exemplo n.º 20
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);
                }
            }
        }