private string GetDatabaseIdentityString(DatabaseId databaseId) { this.DisposeCheck(); if (null == databaseId) { throw new ArgumentNullException("databaseId"); } if (string.IsNullOrEmpty(databaseId.DatabaseName)) { try { MdbStatus databaseStatus = this.GetDatabaseStatus(databaseId, false); if (databaseStatus == null) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId>((long)this.GetHashCode(), "Cannot get status for database '{0}'", databaseId); } else { databaseId = new DatabaseId(databaseId.MapiEntryId, databaseStatus.VServerName, databaseStatus.MdbName, databaseId.Guid); } } catch (MapiTransientException ex) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId, string>((long)this.GetHashCode(), "Getting status for database '{0}' caught an exception: '{1}'", databaseId, ex.Message); } catch (MapiOperationException ex2) { ExTraceGlobals.MapiSessionTracer.TraceError <DatabaseId, string>((long)this.GetHashCode(), "Getting status for database '{0}' caught an exception: '{1}'", databaseId, ex2.Message); } } return(databaseId.ToString()); }
protected sealed override void UpdateIdentity(MapiObject.UpdateIdentityFlags flags) { MapiEntryId mapiEntryId = this.Identity.MapiEntryId; DatabaseId mailboxDatabaseId = this.Identity.MailboxDatabaseId; Guid mailboxGuid = this.Identity.MailboxGuid; string mailboxExchangeLegacyDn = this.Identity.MailboxExchangeLegacyDn; this.Identity = new MailboxId(mapiEntryId, mailboxDatabaseId, mailboxGuid, mailboxExchangeLegacyDn); }
public MdbStatus GetDatabaseStatus(DatabaseId databaseId, bool basicInformation) { MdbStatus[] databaseStatus = this.GetDatabaseStatus(new DatabaseId[] { databaseId }, basicInformation); if (databaseStatus.Length != 0) { return(databaseStatus[0]); } return(null); }
protected sealed override void UpdateIdentity(MapiObject.UpdateIdentityFlags flags) { bool flag = MapiObject.UpdateIdentityFlags.Nop == (MapiObject.UpdateIdentityFlags.SkipIfExists & flags); MapiEntryId mapiEntryId = this.Identity.MapiEntryId; DatabaseId mailboxDatabaseId = this.Identity.MailboxDatabaseId; Guid mailboxGuid = this.Identity.MailboxGuid; string mailboxExchangeLegacyDn = this.Identity.MailboxExchangeLegacyDn; if ((MapiObject.UpdateIdentityFlags.LegacyDistinguishedName & flags) != MapiObject.UpdateIdentityFlags.Nop && (string.IsNullOrEmpty(this.Identity.MailboxExchangeLegacyDn) || flag)) { mailboxExchangeLegacyDn = (string)this[LogonStatisticsSchema.FullMailboxDirectoryName]; } this.Identity = new MailboxId(mapiEntryId, mailboxDatabaseId, mailboxGuid, mailboxExchangeLegacyDn); }
protected override void UpdateIdentity(MapiObject.UpdateIdentityFlags flags) { bool flag = MapiObject.UpdateIdentityFlags.Nop == (MapiObject.UpdateIdentityFlags.SkipIfExists & flags); MapiEntryId entryId = this.Identity.MapiEntryId; DatabaseId mailboxDatabaseId = this.Identity.MailboxDatabaseId; Guid? guid = new Guid?(this.Identity.MailboxGuid); string mailboxExchangeLegacyDn = this.Identity.MailboxExchangeLegacyDn; if ((MapiObject.UpdateIdentityFlags.EntryIdentity & flags) != MapiObject.UpdateIdentityFlags.Nop && (null == this.Identity.MapiEntryId || flag)) { entryId = (MapiEntryId)this[MapiPropertyDefinitions.EntryId]; } if ((MapiObject.UpdateIdentityFlags.MailboxGuid & flags) != MapiObject.UpdateIdentityFlags.Nop && (Guid.Empty == this.Identity.MailboxGuid || flag)) { guid = (Guid?)this[MapiPropertyDefinitions.MailboxGuid]; } if ((MapiObject.UpdateIdentityFlags.LegacyDistinguishedName & flags) != MapiObject.UpdateIdentityFlags.Nop && (string.IsNullOrEmpty(this.Identity.MailboxExchangeLegacyDn) || flag)) { mailboxExchangeLegacyDn = (string)this[MapiPropertyDefinitions.LegacyDN]; } this.Identity = new MailboxId(entryId, mailboxDatabaseId, guid ?? Guid.Empty, mailboxExchangeLegacyDn); }
internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize) { if (!base.GetType().IsAssignableFrom(typeof(T))) { throw new ArgumentException("T"); } DatabaseId databaseId = root as DatabaseId; if (!(null != databaseId)) { throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid); } if (MapiObject.RetrievePropertiesScope.Database != this.RetrievePropertiesScopeForFinding && this.RetrievePropertiesScopeForFinding != MapiObject.RetrievePropertiesScope.Instance) { 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 MapiInvalidOperationException(Strings.ExceptionSessionNull); } base.EnableDisposeTracking(); PropTag[] tagsToRead; using (LogonStatisticsEntry logonStatisticsEntry = (LogonStatisticsEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)))) { tagsToRead = logonStatisticsEntry.GetPropertyTagsToRead(); } if (tagsToRead == null || tagsToRead.Length == 0) { tagsToRead = new PropTag[] { PropTag.MailboxDN }; } MdbFlags[] flagsSetToBeTried = new MdbFlags[] { MdbFlags.Private | MdbFlags.System | MdbFlags.User, MdbFlags.Public | MdbFlags.System | MdbFlags.User }; int count = 0; MdbFlags[] array = flagsSetToBeTried; for (int i = 0; i < array.Length; i++) { LogonStatisticsEntry.< > c__DisplayClass5 <T> CS$ < > 8__locals3 = new LogonStatisticsEntry.< > c__DisplayClass5 <T>(); CS$ < > 8__locals3.flags = array[i]; PropValue[][] entries = null; base.MapiSession.InvokeWithWrappedException(delegate() { ExTraceGlobals.LogonStatisticsTracer.TraceDebug <DatabaseId, string, MdbFlags>((long)this.GetHashCode(), "To Find LogonStatistics from in the database '{0}' on server '{1}' with flag '{2}'.", databaseId, this.MapiSession.ServerName, CS$ < > 8__locals3.flags); entries = this.MapiSession.Administration.GetLogonTable(CS$ < > 8__locals3.flags, databaseId.Guid, tagsToRead); }, Strings.ExceptionFindObject(typeof(T).Name, (null == root) ? Strings.ConstantNull : root.ToString()), databaseId); foreach (PropValue[] entry in entries) { LogonStatisticsEntry logonStatisitcs = (LogonStatisticsEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); try { logonStatisitcs.Instantiate(entry); logonStatisitcs.MapiSession = base.MapiSession; logonStatisitcs.UpdateIdentity(logonStatisitcs.UpdateIdentityFlagsForFinding); logonStatisitcs.OriginatingServer = Fqdn.Parse(logonStatisitcs.MapiSession.ServerName); logonStatisitcs.ResetChangeTrackingAndObjectState(); } finally { logonStatisitcs.Dispose(); } yield return((T)((object)logonStatisitcs)); count++; if (0 < maximumResultsSize && count == maximumResultsSize) { yield break; } } if (0 < count) { break; } } yield break; }
internal static void ThrowWrappedException(LocalizedException exception, LocalizedString message, MapiObjectId source, MapiSession mapiSession) { if (exception is MapiExceptionNotFound) { if (source is PublicFolderId) { throw new PublicFolderNotFoundException(source.ToString(), exception); } if (source is MailboxId) { mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception); } throw new MapiObjectNotFoundException(message, exception); } else if (exception is MapiExceptionLogonFailed) { if (source is PublicFolderId) { throw new PublicStoreLogonFailedException(mapiSession.ServerName, exception); } if (source is MailboxId) { mapiSession.AnalyzeMailboxLogonFailedAndThrow((MailboxId)source, exception); } throw new MapiLogonFailedException(Strings.LogonFailedExceptionError(message, mapiSession.ServerName), exception); } else { if (exception is MapiExceptionSessionLimit) { throw new MapiLogonFailedException(Strings.SessionLimitExceptionError, exception); } if (exception is MapiExceptionUnknownMailbox) { if (source is MailboxId) { mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception); } throw new MapiObjectNotFoundException(message, exception); } if (exception is MapiExceptionMdbOffline) { if (mapiSession == null) { throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionErrorSimple, exception); } DatabaseId databaseId = null; if (source is MailboxId && null != ((MailboxId)source).MailboxDatabaseId) { databaseId = ((MailboxId)source).MailboxDatabaseId; } else if (source is DatabaseId) { databaseId = (DatabaseId)source; } if (null == databaseId) { throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionError(mapiSession.ServerName), exception); } throw new DatabaseUnavailableException(Strings.DatabaseUnavailableByIdentityExceptionError(mapiSession.GetDatabaseIdentityString(databaseId), mapiSession.ServerName), exception); } else { if (exception is MapiExceptionPartialCompletion) { throw new MapiPartialCompletionException(message, exception); } if (exception is MapiExceptionNetworkError) { if (mapiSession != null) { throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionError(mapiSession.ServerName), exception); } throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionErrorSimple, exception); } else if (exception is MapiExceptionNoAccess) { if (null != source) { throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionError(source.ToString()), exception); } throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionErrorSimple, exception); } else { if (exception is MapiRetryableException) { throw new MapiTransientException(message, exception); } if (exception is MapiPermanentException) { throw new MapiOperationException(message, exception); } if (exception is MapiInvalidOperationException) { throw new MapiOperationException(message, exception); } return; } } } }
public MdbStatus GetDatabaseStatus(DatabaseId databaseId) { return(this.GetDatabaseStatus(databaseId, true)); }
internal MailboxId(MapiEntryId entryId, DatabaseId mailboxDatabaseId, Guid mailboxGuid, string mailboxExchangeLegacyDn) : base(entryId) { this.mailboxDatabaseId = mailboxDatabaseId; this.mailboxGuid = mailboxGuid; this.mailboxExchangeLegacyDn = mailboxExchangeLegacyDn; }
public MailboxId(DatabaseId mailboxDatabaseId, Guid mailboxGuid) { this.mailboxDatabaseId = mailboxDatabaseId; this.mailboxGuid = mailboxGuid; }