Ejemplo n.º 1
0
        // Token: 0x06000458 RID: 1112 RVA: 0x0000F868 File Offset: 0x0000DA68
        internal static string GetMailboxLegacyDN(MapiAdministrationSession mapiAdminSession, ADObjectId databaseId, Guid mailboxGuid)
        {
            string               result = null;
            DatabaseId           root   = MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(databaseId);
            MailboxContextFilter filter = new MailboxContextFilter(mailboxGuid);

            MailboxStatistics[] array = null;
            try
            {
                array = mapiAdminSession.Find <MailboxStatistics>(filter, root, QueryScope.SubTree, null, 1);
            }
            catch (MapiObjectNotFoundException)
            {
            }
            if (array != null)
            {
                result = array[0].LegacyDN;
                array[0].Dispose();
            }
            return(result);
        }
        internal override IEnumerable <T> GetObjects <T>(ObjectId rootId, IConfigDataProvider session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            if (!typeof(MailboxEntry).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (rootId == null)
            {
                throw new ArgumentNullException("rootId");
            }
            if (!(session is MapiAdministrationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(MapiAdministrationSession).Name), "session");
            }
            if (string.IsNullOrEmpty(this.displayName) && null == base.MapiObjectId)
            {
                throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
            }
            notFoundReason = null;
            List <T> list        = new List <T>();
            Guid     mailboxGuid = Guid.Empty;

            if (base.MapiObjectId != null)
            {
                mailboxGuid = ((MailboxId)base.MapiObjectId).MailboxGuid;
            }
            QueryFilter filter = new MailboxContextFilter(mailboxGuid, this.flags);

            try
            {
                IEnumerable <T> enumerable = session.FindPaged <T>(filter, rootId, true, null, 0);
                if (null != base.MapiObjectId)
                {
                    bool flag  = Guid.Empty != ((MailboxId)base.MapiObjectId).MailboxGuid;
                    bool flag2 = !string.IsNullOrEmpty(((MailboxId)base.MapiObjectId).MailboxExchangeLegacyDn);
                    if (flag || flag2)
                    {
                        foreach (T t in enumerable)
                        {
                            IConfigurable configurable = t;
                            MailboxEntry  mailboxEntry = (MailboxEntry)configurable;
                            if (flag && mailboxEntry.Identity.MailboxGuid == ((MailboxId)base.MapiObjectId).MailboxGuid)
                            {
                                list.Add((T)((object)mailboxEntry));
                            }
                            else if (flag2 && string.Equals(mailboxEntry.Identity.MailboxExchangeLegacyDn, ((MailboxId)base.MapiObjectId).MailboxExchangeLegacyDn, StringComparison.OrdinalIgnoreCase))
                            {
                                list.Add((T)((object)mailboxEntry));
                            }
                        }
                    }
                }
                if (list.Count == 0 && typeof(MailboxStatistics).IsAssignableFrom(typeof(T)) && !string.IsNullOrEmpty(this.displayName))
                {
                    foreach (T t2 in enumerable)
                    {
                        IConfigurable     configurable2     = t2;
                        MailboxStatistics mailboxStatistics = (MailboxStatistics)configurable2;
                        if (string.Equals(this.displayName, mailboxStatistics.DisplayName, StringComparison.OrdinalIgnoreCase))
                        {
                            list.Add((T)((object)mailboxStatistics));
                        }
                    }
                }
            }
            catch (MapiObjectNotFoundException)
            {
            }
            return(list);
        }
Ejemplo n.º 3
0
        internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize)
        {
            MailboxEntry.< > c__DisplayClass1 <T> CS$ < > 8__locals1 = new MailboxEntry.< > c__DisplayClass1 <T>();
            CS$ < > 8__locals1.< > 4__this       = this;
            CS$ < > 8__locals1.mailboxGuid       = Guid.Empty;
            CS$ < > 8__locals1.mailboxTableFlags = MailboxTableFlags.MailboxTableFlagsNone;
            if (!base.GetType().IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("T");
            }
            CS$ < > 8__locals1.databaseId = (root as DatabaseId);
            if (null == CS$ < > 8__locals1.databaseId)
            {
                throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
            }
            if (filter != null)
            {
                MailboxContextFilter mailboxContextFilter = filter as MailboxContextFilter;
                if (mailboxContextFilter == null)
                {
                    throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
                }
                CS$ < > 8__locals1.mailboxGuid        = mailboxContextFilter.MailboxGuid;
                CS$ < > 8__locals1.mailboxTableFlags |= (MailboxTableFlags)mailboxContextFilter.MailboxFlags;
                this.noADLookup = mailboxContextFilter.NoADLookup;
            }
            else
            {
                this.noADLookup = false;
            }
            if (MapiObject.RetrievePropertiesScope.Database != this.RetrievePropertiesScopeForFinding)
            {
                yield break;
            }
            if (QueryScope.SubTree != scope)
            {
                throw new ArgumentException("scope");
            }
            if (sort != null)
            {
                throw new ArgumentException("sort");
            }
            if (0 > maximumResultsSize)
            {
                throw new ArgumentException("maximumResultsSize");
            }
            if (base.MapiSession == null)
            {
                throw new MapiOperationException(Strings.ExceptionSessionNull);
            }
            base.EnableDisposeTracking();
            PropTag[] tagsToRead = base.GetPropertyTagsToRead();
            if (tagsToRead == null || tagsToRead.Length == 0)
            {
                tagsToRead = new PropTag[]
                {
                    PropTag.UserGuid,
                    PropTag.EmailAddress
                };
            }
            PropValue[][] entries = null;
            base.MapiSession.InvokeWithWrappedException(delegate()
            {
                entries = CS$ < > 8__locals1.< > 4__this.MapiSession.Administration.GetMailboxTableInfo(CS$ < > 8__locals1.databaseId.Guid, CS$ < > 8__locals1.mailboxGuid, CS$ < > 8__locals1.mailboxTableFlags, tagsToRead);
            }, Strings.ExceptionFindObject(typeof(T).Name, (null == root) ? Strings.ConstantNull : root.ToString()), CS$ < > 8__locals1.databaseId);
            int resultSize = entries.Length;

            if (0 < maximumResultsSize && maximumResultsSize < resultSize)
            {
                resultSize = maximumResultsSize;
            }
            int entryIndex = 0;

            while (resultSize > entryIndex)
            {
                MailboxEntry mailbox = (MailboxEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
                try
                {
                    mailbox.Instantiate(entries[entryIndex]);
                    mailbox.MapiSession = base.MapiSession;
                    if (mailbox[MapiPropertyDefinitions.MailboxGuid] != null)
                    {
                        mailbox.Identity = new MailboxId(CS$ < > 8__locals1.databaseId, (Guid)mailbox[MapiPropertyDefinitions.MailboxGuid]);
                    }
                    mailbox.UpdateIdentity(mailbox.UpdateIdentityFlagsForFinding);
                    mailbox.OriginatingServer = Fqdn.Parse(mailbox.MapiSession.ServerName);
                    mailbox.ResetChangeTrackingAndObjectState();
                }
                finally
                {
                    mailbox.Dispose();
                }
                yield return((T)((object)mailbox));

                entryIndex++;
            }
            yield break;
        }
Ejemplo n.º 4
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     foreach (Database database in this.databases)
     {
         try
         {
             Guid mailboxGuid = Guid.Empty;
             MailboxTableFlags mailboxTableFlags = MailboxTableFlags.MailboxTableFlagsNone;
             if (null != this.identity)
             {
                 mailboxGuid = this.identity.MailboxGuid;
             }
             if (this.isRunningMailboxStatisticsTask)
             {
                 mailboxTableFlags |= MailboxTableFlags.IncludeSoftDeletedMailbox;
             }
             QueryFilter filter = new MailboxContextFilter(mailboxGuid, (ulong)((long)mailboxTableFlags), this.NoADLookupForMailboxStatistics);
             IEnumerable <TPresentationObject> enumerable = this.mapiSession.FindPaged <TDataObject, TPresentationObject>(filter, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), QueryScope.SubTree, null, 0, 0);
             foreach (TPresentationObject tpresentationObject in enumerable)
             {
                 try
                 {
                     MailboxId mailboxId = tpresentationObject.Identity as MailboxId;
                     if (this.Identity == null || (null != mailboxId && ((Guid.Empty != this.identity.MailboxGuid && this.identity.MailboxGuid == mailboxId.MailboxGuid) || (!string.IsNullOrEmpty(this.identity.MailboxExchangeLegacyDn) && string.Equals(this.identity.MailboxExchangeLegacyDn, mailboxId.MailboxExchangeLegacyDn, StringComparison.OrdinalIgnoreCase)))))
                     {
                         if (this.isRunningLogonStatisticsTask)
                         {
                             ((LogonStatistics)((object)tpresentationObject)).ServerName   = database.ServerName;
                             ((LogonStatistics)((object)tpresentationObject)).DatabaseName = database.Name;
                         }
                         else if (this.isRunningResourceMonitorDigestTask)
                         {
                             ((MailboxResourceMonitor)((object)tpresentationObject)).ServerName           = this.server.Name;
                             ((MailboxResourceMonitor)((object)tpresentationObject)).DatabaseName         = database.Name;
                             ((MailboxResourceMonitor)((object)tpresentationObject)).IsDatabaseCopyActive = (database.Server.ObjectGuid == this.server.Guid);
                         }
                         else if (this.isRunningMailboxStatisticsTask)
                         {
                             Microsoft.Exchange.Management.MapiTasks.Presentation.MailboxStatistics mailboxStatistics = (Microsoft.Exchange.Management.MapiTasks.Presentation.MailboxStatistics)((object)tpresentationObject);
                             mailboxStatistics.ServerName           = this.server.Name;
                             mailboxStatistics.DatabaseName         = database.Name;
                             mailboxStatistics.Database             = database.Identity;
                             mailboxStatistics.IsDatabaseCopyActive = (database.Server.ObjectGuid == this.server.Guid);
                             MailboxDatabase mailboxDatabase = database as MailboxDatabase;
                             if (mailboxDatabase != null)
                             {
                                 mailboxStatistics.DatabaseIssueWarningQuota        = mailboxDatabase.IssueWarningQuota;
                                 mailboxStatistics.DatabaseProhibitSendQuota        = mailboxDatabase.ProhibitSendQuota;
                                 mailboxStatistics.DatabaseProhibitSendReceiveQuota = mailboxDatabase.ProhibitSendReceiveQuota;
                             }
                             if (mailboxId != null && this.GetMoveHistoryOption() != MoveHistoryOption.None)
                             {
                                 UserMailboxFlags userMailboxFlags = UserMailboxFlags.None;
                                 if (database.Recovery)
                                 {
                                     userMailboxFlags |= UserMailboxFlags.RecoveryMDB;
                                 }
                                 if (mailboxStatistics.IsMoveDestination ?? false)
                                 {
                                     userMailboxFlags |= UserMailboxFlags.MoveDestination;
                                 }
                                 else if (mailboxStatistics.DisconnectReason != null)
                                 {
                                     if (mailboxStatistics.DisconnectReason.Value == MailboxState.SoftDeleted)
                                     {
                                         userMailboxFlags |= UserMailboxFlags.SoftDeleted;
                                     }
                                     else
                                     {
                                         userMailboxFlags |= UserMailboxFlags.Disconnected;
                                     }
                                 }
                                 try
                                 {
                                     mailboxStatistics.MoveHistory = MoveHistoryEntry.LoadMoveHistory(mailboxId.MailboxGuid, database.Id.ObjectGuid, this.GetMoveHistoryOption() == MoveHistoryOption.IncludeMoveHistoryAndReport, userMailboxFlags);
                                 }
                                 catch (LocalizedException exception)
                                 {
                                     base.WriteError(exception, ErrorCategory.ResourceUnavailable, mailboxId);
                                 }
                             }
                         }
                         bool flag = true;
                         if (this.isRunningMailboxStatisticsTask)
                         {
                             Exception ex = null;
                             try
                             {
                                 QueryFilter internalFilter = this.InternalFilter;
                                 if (internalFilter != null && !OpathFilterEvaluator.FilterMatches(internalFilter, (Microsoft.Exchange.Data.Mapi.MailboxStatistics)((object)tpresentationObject)))
                                 {
                                     flag = false;
                                 }
                             }
                             catch (InvalidCastException ex2)
                             {
                                 ex = ex2;
                             }
                             catch (ParsingException ex3)
                             {
                                 ex = ex3;
                             }
                             catch (ArgumentOutOfRangeException ex4)
                             {
                                 ex = ex4;
                             }
                             if (ex != null)
                             {
                                 base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidMailboxStatisticsFilter(this.InternalFilter.ToString())), ErrorCategory.InvalidArgument, this.InternalFilter);
                             }
                         }
                         if (flag)
                         {
                             this.WriteResult(tpresentationObject);
                         }
                         if (this.Identity != null && this.isRunningMailboxStatisticsTask)
                         {
                             TaskLogger.LogExit();
                             return;
                         }
                     }
                 }
                 finally
                 {
                     if (tpresentationObject != null)
                     {
                         tpresentationObject.Dispose();
                     }
                 }
             }
         }
         catch (DatabaseUnavailableException ex5)
         {
             if (this.Identity == null && this.Database == null)
             {
                 base.WriteWarning(ex5.Message);
             }
             else
             {
                 base.WriteError(ex5, ErrorCategory.ResourceUnavailable, database);
             }
         }
         catch (MapiObjectNotFoundException exception2)
         {
             if (this.Identity == null || !this.isRunningMailboxStatisticsTask)
             {
                 base.WriteError(exception2, ErrorCategory.ObjectNotFound, this.Identity);
             }
         }
     }
     if (this.Identity != null && this.isRunningMailboxStatisticsTask)
     {
         TIdentity tidentity = this.Identity;
         this.WriteWarning(Strings.WarningMailboxNeverBeenLoggedOn(tidentity.ToString(), this.identity.ToString()));
     }
     TaskLogger.LogExit();
 }