private List <MessageTrackingLogEntry> GetMessageLog(RpcReason rpcReason, ILogReader logReader, TrackingLogPrefix logPrefix, string messageId) { Fqdn key = Fqdn.Parse(logReader.Server); Dictionary <string, List <MessageTrackingLogEntry>[]> dictionary = null; List <MessageTrackingLogEntry>[] array = null; if (!this.cache.TryGetValue(key, out dictionary)) { dictionary = new Dictionary <string, List <MessageTrackingLogEntry>[]>(); this.cache.Add(key, dictionary); } if (!dictionary.TryGetValue(messageId, out array)) { array = new List <MessageTrackingLogEntry> [LogCache.prefixValues.Length]; for (int i = 0; i < LogCache.prefixValues.Length; i++) { List <MessageTrackingLogEntry> list = logReader.ReadLogs(rpcReason, LogCache.prefixValues[i], messageId, this.startTime, this.endTime, this.eventBudget); if (logReader.MtrSchemaVersion >= MtrSchemaVersion.E15RTM) { list.RemoveAll((MessageTrackingLogEntry entry) => entry.EventId == MessageTrackingEvent.RECEIVE && entry.Source == MessageTrackingSource.STOREDRIVER); list.RemoveAll((MessageTrackingLogEntry entry) => entry.EventId == MessageTrackingEvent.HADISCARD && entry.Source == MessageTrackingSource.SMTP); list.RemoveAll((MessageTrackingLogEntry entry) => entry.EventId == MessageTrackingEvent.AGENTINFO && entry.Source == MessageTrackingSource.AGENT); } array[i] = list; } dictionary.Add(messageId, array); } return(array[(int)logPrefix]); }
public LogDataAnalyzer(TrackingContext context) { this.context = context; this.startingServer = Fqdn.Parse(this.context.StartingEventId.Server); this.cache = context.Cache; this.remainingTrackers = new Queue <MailItemTracker>(); }
// Token: 0x06000453 RID: 1107 RVA: 0x0000F6CC File Offset: 0x0000D8CC private static void GetServerForDatabase(Guid publicFolderDatabaseGuid, out string serverLegacyDn, out Fqdn serverFqdn) { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(publicFolderDatabaseGuid, GetServerForDatabaseFlags.ThrowServerForDatabaseNotFoundException); serverFqdn = Fqdn.Parse(serverForDatabase.ServerFqdn); serverLegacyDn = serverForDatabase.ServerLegacyDN; }
protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); ClientAccessServer clientAccessServer = new ClientAccessServer((Server)dataObject); if (this.IncludeAlternateServiceAccountCredentialPassword.ToBool()) { SetClientAccessServer.EnsureRunningOnTargetServer(this, (Server)dataObject); clientAccessServer.AlternateServiceAccountConfiguration = AlternateServiceAccountConfiguration.LoadWithPasswordsFromRegistry(); } else if (this.IncludeAlternateServiceAccountCredentialStatus.ToBool()) { clientAccessServer.AlternateServiceAccountConfiguration = AlternateServiceAccountConfiguration.LoadFromRegistry(clientAccessServer.Fqdn); } IConfigurable[] array = this.ConfigurationSession.Find <ADRpcHttpVirtualDirectory>((ADObjectId)clientAccessServer.Identity, QueryScope.SubTree, null, null, 1); clientAccessServer.OutlookAnywhereEnabled = new bool?(array.Length > 0); QueryFilter filter = ExchangeScpObjects.AutodiscoverUrlKeyword.Filter; array = this.ConfigurationSession.Find <ADServiceConnectionPoint>((ADObjectId)clientAccessServer.Identity, QueryScope.SubTree, filter, null, 2); if (array.Length == 1) { ADServiceConnectionPoint adserviceConnectionPoint = array[0] as ADServiceConnectionPoint; if (adserviceConnectionPoint.ServiceBindingInformation.Count > 0) { clientAccessServer.AutoDiscoverServiceInternalUri = new Uri(adserviceConnectionPoint.ServiceBindingInformation[0]); } clientAccessServer.AutoDiscoverServiceGuid = new Guid?(GetClientAccessServer.ScpUrlGuid); clientAccessServer.AutoDiscoverServiceCN = Fqdn.Parse(adserviceConnectionPoint.ServiceDnsName); clientAccessServer.AutoDiscoverServiceClassName = adserviceConnectionPoint.ServiceClassName; if (adserviceConnectionPoint.Keywords != null && adserviceConnectionPoint.Keywords.Count > 1) { MultiValuedProperty <string> multiValuedProperty = null; foreach (string text in adserviceConnectionPoint.Keywords) { if (text.StartsWith("site=", StringComparison.OrdinalIgnoreCase)) { if (multiValuedProperty == null) { multiValuedProperty = new MultiValuedProperty <string>(); } multiValuedProperty.Add(text.Substring(5)); } } if (multiValuedProperty != null && multiValuedProperty.Count > 0) { clientAccessServer.AutoDiscoverSiteScope = multiValuedProperty; } } } base.WriteResult(clientAccessServer); TaskLogger.LogExit(); }
private List <MessageTrackingLogEntry> GetMessageLog(RpcReason rpcReason, ILogReader logReader, TrackingLogPrefix logPrefix, ProxyAddressCollection senderAddresses) { Fqdn key = Fqdn.Parse(logReader.Server); Dictionary <ProxyAddressCollection, List <MessageTrackingLogEntry>[]> dictionary = null; List <MessageTrackingLogEntry>[] array = null; if (!this.cacheBySender.TryGetValue(key, out dictionary)) { dictionary = new Dictionary <ProxyAddressCollection, List <MessageTrackingLogEntry>[]>(1, LogCache.proxyAddressCollectionComparer); this.cacheBySender.Add(key, dictionary); } if (!dictionary.TryGetValue(senderAddresses, out array)) { array = new List <MessageTrackingLogEntry> [LogCache.prefixValues.Length]; for (int i = 0; i < LogCache.prefixValues.Length; i++) { List <MessageTrackingLogEntry> list = logReader.ReadLogs(rpcReason, LogCache.prefixValues[i], senderAddresses, this.startTime, this.endTime, this.eventBudget); array[i] = list; Dictionary <string, List <MessageTrackingLogEntry>[]> dictionary2 = null; bool flag = !this.cache.TryGetValue(key, out dictionary2); HashSet <string> hashSet = new HashSet <string>(); foreach (MessageTrackingLogEntry messageTrackingLogEntry in list) { if (!flag && !dictionary2.ContainsKey(messageTrackingLogEntry.MessageId) && !hashSet.Contains(messageTrackingLogEntry.MessageId)) { hashSet.Add(messageTrackingLogEntry.MessageId); } } if (flag) { dictionary2 = new Dictionary <string, List <MessageTrackingLogEntry>[]>(hashSet.Count); this.cache.Add(key, dictionary2); } foreach (MessageTrackingLogEntry messageTrackingLogEntry2 in list) { if (hashSet.Contains(messageTrackingLogEntry2.MessageId)) { List <MessageTrackingLogEntry>[] array2; if (!dictionary2.TryGetValue(messageTrackingLogEntry2.MessageId, out array2)) { array2 = new List <MessageTrackingLogEntry> [LogCache.prefixValues.Length]; dictionary2.Add(messageTrackingLogEntry2.MessageId, array2); } if (array2[i] == null) { array2[i] = new List <MessageTrackingLogEntry>(); } array2[i].Add(messageTrackingLogEntry2); } } } dictionary.Add(senderAddresses, array); } return(array[(int)logPrefix]); }
protected override IConfigDataProvider CreateSession() { TaskLogger.LogEnter(); if (this.mapiSession == null) { this.mapiSession = new MapiAdministrationSession(this.server.ExchangeLegacyDN, Fqdn.Parse(this.server.Fqdn)); } else { this.mapiSession.RedirectServer(this.server.ExchangeLegacyDN, Fqdn.Parse(this.server.Fqdn)); } TaskLogger.LogExit(); return(this.mapiSession); }
public static void SaveMailboxSecurityDescriptor(ADUser mailbox, ActiveDirectorySecurity adSecurity, IConfigDataProvider writableAdSession, ref MapiMessageStoreSession storeSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError) { if (writableAdSession == null) { throw new ArgumentException("writableAdSession"); } RawSecurityDescriptor rawSd = new RawSecurityDescriptor(adSecurity.GetSecurityDescriptorBinaryForm(), 0); PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError); string text = null; try { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid); text = serverForDatabase.ServerFqdn; if (storeSession == null) { storeSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn)); } else { storeSession.RedirectServer(serverForDatabase.ServerLegacyDN, Fqdn.Parse(serverForDatabase.ServerFqdn)); } MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid); logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), storeSession.ServerName)); storeSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid); } catch (DatabaseNotFoundException) { logVerbose(Strings.ErrorMailboxDatabaseNotFound(mailbox.Database.ToString())); } catch (MapiExceptionNetworkError) { logVerbose(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty)); } catch (FormatException) { logVerbose(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString())); } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException) { logVerbose(Strings.VerboseMailboxNotExistInStore(mailbox.DistinguishedName)); } if (mailbox.HasLocalArchive) { PermissionTaskHelper.SaveArchiveSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError); } }
protected override IConfigDataProvider CreateSession() { TaskLogger.LogEnter(); this.readOnlyRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 159, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MapiTasks\\Mailbox\\GetStatisticsBase.cs"); if (base.DomainController == null) { this.readOnlyRecipientSession.UseGlobalCatalog = true; } this.isRunningMailboxStatisticsTask = (typeof(TDataObject) == typeof(Microsoft.Exchange.Data.Mapi.MailboxStatistics)); this.isRunningLogonStatisticsTask = (typeof(TDataObject) == typeof(LogonStatistics)); this.isRunningResourceMonitorDigestTask = (typeof(TDataObject) == typeof(MailboxResourceMonitor)); if (this.Database != null && this.isRunningMailboxStatisticsTask && this.StoreMailboxId != null) { Guid mailboxGuid; if (Guid.TryParse(this.StoreMailboxId.ToString(), out mailboxGuid)) { this.identity = new MailboxId(null, mailboxGuid); } else { base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidGuidFormat), ErrorCategory.InvalidArgument, this.StoreMailboxId.ToString()); } } else { this.identity = new MailboxId(); } this.databases.Clear(); this.server = null; this.ResolveDatabaseAndServer(); if (this.mapiSession == null) { this.mapiSession = new MapiAdministrationSession(this.server.ExchangeLegacyDN, Fqdn.Parse(this.server.Fqdn)); } else { this.mapiSession.RedirectServer(this.server.ExchangeLegacyDN, Fqdn.Parse(this.server.Fqdn)); } TaskLogger.LogExit(); return(this.mapiSession); }
internal override void Delete() { if (ObjectState.Deleted == base.ObjectState) { throw new MapiInvalidOperationException(Strings.ExceptionObjectStateInvalid(base.ObjectState.ToString())); } if (base.ObjectState == ObjectState.New) { base.MarkAsDeleted(); return; } if (null == this.Identity) { throw new MapiInvalidOperationException(Strings.ExceptionIdentityNull); } if ((null == this.Identity.MailboxDatabaseId || Guid.Empty == this.Identity.MailboxDatabaseId.Guid || Guid.Empty == this.Identity.MailboxGuid) && this.Identity.MailboxExchangeLegacyDn == null) { throw new MapiInvalidOperationException(Strings.ExceptionIdentityInvalid); } if (!(base.MapiSession is MapiAdministrationSession)) { throw new MapiInvalidOperationException(Strings.ExceptionSessionInvalid); } base.EnableDisposeTracking(); try { ((MapiAdministrationSession)base.MapiSession).DeleteMailbox(this.Identity); if (!base.IsOriginatingServerRetrieved) { base.OriginatingServer = Fqdn.Parse(base.MapiSession.ServerName); } } finally { base.Dispose(); } base.ResetChangeTracking(); base.MarkAsDeleted(); }
public void Refresh(ADUser mailbox, IRecipientSession writableAdSession) { if (mailbox == null) { throw new ArgumentNullException("mailbox"); } if (writableAdSession == null) { throw new ArgumentNullException("writableAdSession"); } MapiMessageStoreSession mapiMessageStoreSession = null; try { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid); mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, TeamMailboxSecurityRefresher.CalculateSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn)); MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid); try { mapiMessageStoreSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid); } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex) { throw new ObjectNotFoundException(new LocalizedString(ex.ToString())); } catch (DatabaseUnavailableException ex2) { throw new ObjectNotFoundException(new LocalizedString(ex2.ToString())); } } finally { if (mapiMessageStoreSession != null) { mapiMessageStoreSession.Dispose(); } } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); ADObjectId adobjectId = null; Guid guid = Guid.Empty; string text = string.Empty; bool flag = this.ShouldSoftDeleteObject(); ADUser dataObject = base.DataObject; if (Globals.IsMicrosoftHostedOnly) { if (flag) { bool flag2 = SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId); bool includeInGarbageCollection = (!flag2 || base.ForReconciliation) && !this.isToInactiveMailbox; SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, includeInGarbageCollection, this.isToInactiveMailbox); } else { if (this.isDisconnectInactiveMailbox) { SoftDeletedTaskHelper.UpdateMailboxForDisconnectInactiveMailbox(dataObject); base.DataSession.Save(dataObject); TaskLogger.LogExit(); this.LogRemoveMailboxDetails(dataObject); return; } dataObject.RecipientSoftDeletedStatus = 0; } } if (this.Identity != null) { adobjectId = base.DataObject.Database; guid = base.DataObject.ExchangeGuid; if (adobjectId == null) { TaskLogger.Trace("The homeMDB is empty for this user, we just try to remove the user AD object", new object[0]); } else if (guid == Guid.Empty) { TaskLogger.Trace("The ExchangeGuid is empty for this user, we just try to remove the user AD object", new object[0]); } else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.MailboxPlan) { TaskLogger.Trace("This user is MailboxPlan, we just try to remove the user AD object", new object[0]); } else if (!flag) { try { DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(adobjectId.ObjectGuid); } catch (ObjectNotFoundException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null); } if (databaseLocationInfo == null) { if (this.Permanent) { base.WriteError(new TaskInvalidOperationException(Strings.ErrorGetServerNameFromMailbox(base.DataObject.Identity.ToString())), ExchangeErrorCategory.ServerOperation, base.DataObject); } else { TaskLogger.Trace("cannot get the server name for mailbox {0}", new object[] { base.DataObject.Identity }); } } else { text = databaseLocationInfo.ServerFqdn; base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(text)); this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(text)); } } catch (MapiPermanentException ex) { if (this.Permanent) { base.WriteError(ex, ExchangeErrorCategory.ServerOperation, this.Identity); } else { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex }); } } catch (MapiRetryableException ex2) { if (this.Permanent) { base.WriteError(ex2, ExchangeErrorCategory.ServerTransient, this.Identity); } else { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex2 }); } } try { if (dataObject != null && base.ForReconciliation) { base.DataObject.ExternalDirectoryObjectId = string.Empty; } base.DataObject.PreviousDatabase = base.DataObject.Database; base.DataSession.Save(base.DataObject); } catch (DataSourceTransientException exception2) { base.WriteError(exception2, ExchangeErrorCategory.ServerTransient, null); } catch (InvalidObjectOperationException) { } catch (DataValidationException) { } catch (ADOperationException) { } } base.InternalProcessRecord(); this.LogRemoveMailboxDetails(dataObject); } if (this.StoreMailboxIdentity != null || this.Permanent) { if (this.Permanent) { if (!(guid != Guid.Empty) || adobjectId == null) { goto IL_5A0; } try { base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(guid.ToString(), adobjectId.ToString())); this.mapiSession.DeleteMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid)); goto IL_5A0; } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex3) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex3 }); base.WriteVerbose(ex3.LocalizedString); goto IL_5A0; } catch (DataSourceOperationException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerOperation, base.DataObject); goto IL_5A0; } } try { base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(this.mailboxStatistics.MailboxGuid.ToString(), this.mailboxStatistics.Database.ToString())); ((IConfigDataProvider)this.mapiSession).Delete(this.mailboxStatistics); goto IL_5A0; } catch (DataSourceOperationException exception4) { base.WriteError(exception4, ExchangeErrorCategory.ServerOperation, (this.Identity == null) ? this.StoreMailboxIdentity : this.Identity); goto IL_5A0; } } if (this.mapiSession != null) { try { TIdentity identity = this.Identity; base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(identity.ToString(), base.DataObject.Database.ToString(), text)); bool flag3 = true; if (base.DataObject.Database == null || Guid.Empty == base.DataObject.Database.ObjectGuid) { flag3 = false; TaskLogger.Trace("Cannot get the database for mailbox '{0}'", new object[] { base.DataObject.Identity }); } if (Guid.Empty == base.DataObject.ExchangeGuid) { flag3 = false; TaskLogger.Trace("Cannot get the mailbox guid for mailbox '{0}'", new object[] { base.DataObject.Identity }); } if (flag3) { this.mapiSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(base.DataObject.Database), base.DataObject.ExchangeGuid)); } } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex4) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex4 }); base.WriteVerbose(ex4.LocalizedString); } catch (DataSourceTransientException ex5) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex5 }); this.WriteWarning(ex5.LocalizedString); } catch (DataSourceOperationException ex6) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex6 }); this.WriteWarning(ex6.LocalizedString); } } IL_5A0: if (!flag && this.mailboxStatistics != null) { this.mailboxStatistics.Dispose(); this.mailboxStatistics = null; } this.DisposeMapiSession(); TaskLogger.LogExit(); }
private void InternalValidateStoreMailboxIdentity() { TaskLogger.LogEnter(); MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString())), ExchangeErrorCategory.Client); if (mailboxDatabase.Recovery) { base.WriteError(new TaskArgumentException(Strings.ErrorInvalidOperationOnRecoveryMailboxDatabase(this.Database.ToString())), ExchangeErrorCategory.Client, this.StoreMailboxIdentity); } DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(mailboxDatabase.Id.ObjectGuid); } catch (ObjectNotFoundException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null); } try { base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(databaseLocationInfo.ServerFqdn)); this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(databaseLocationInfo.ServerFqdn)); } catch (MapiPermanentException exception2) { base.WriteError(exception2, ExchangeErrorCategory.ServerOperation, null); } catch (MapiRetryableException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, null); } this.database = mailboxDatabase; TaskLogger.LogExit(); }
internal static bool CheckFullAccessPermissions(ADUser executingAdUser, ADUser accessRequestedForADUser, IRecipientSession session) { ExTraceGlobals.TaskTracer.TraceDebug <string, string>(0L, "Checking if {0} has full access for mailbox {1}", executingAdUser.Alias, accessRequestedForADUser.Alias); ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(accessRequestedForADUser.Database.ObjectGuid); RawSecurityDescriptor rawSecurityDescriptor = null; using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, Server.GetSystemAttendantLegacyDN(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn))) { MailboxId mailboxId = new MailboxId(new DatabaseId(accessRequestedForADUser.Database.ObjectGuid), accessRequestedForADUser.ExchangeGuid); try { rawSecurityDescriptor = mapiMessageStoreSession.GetMailboxSecurityDescriptor(mailboxId); } catch (MailboxNotFoundException) { ExTraceGlobals.TaskTracer.TraceDebug <MailboxId>(0L, "Could not find mailbox {0} when attempting to read its security descriptor.", mailboxId); return(false); } } byte[] array = new byte[rawSecurityDescriptor.BinaryLength]; rawSecurityDescriptor.GetBinaryForm(array, 0); ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity(); activeDirectorySecurity.SetSecurityDescriptorBinaryForm(array); int num = AuthzAuthorization.CheckGenericPermission(executingAdUser.Sid, rawSecurityDescriptor, AccessMask.CreateChild); return((num & 1) == 1); }
// Token: 0x06000457 RID: 1111 RVA: 0x0000F83C File Offset: 0x0000DA3C internal static MapiAdministrationSession GetAdminSession(ActiveManager activeManager, Guid databaseGuid) { DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(databaseGuid); return(new MapiAdministrationSession(serverForDatabase.ServerLegacyDN, Fqdn.Parse(serverForDatabase.ServerFqdn))); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { MailboxState?mailboxState = null; Database database = null; database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, base.DataSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString())), ExchangeErrorCategory.Client); if (database.Recovery) { base.WriteError(new TaskArgumentException(Strings.ErrorInvalidOperationOnRecoveryMailboxDatabase(this.Database.ToString())), ExchangeErrorCategory.Client, this.Identity); } DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(database.Id.ObjectGuid); } catch (ObjectNotFoundException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null); } if (base.IsVerboseOn) { base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(databaseLocationInfo.ServerFqdn)); } this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(databaseLocationInfo.ServerFqdn)); this.guidMdb = database.Guid; this.Identity.Flags |= 1UL; this.mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.Identity, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.Identity.ToString(), this.Database.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.Identity.ToString(), this.Database.ToString()))); this.guidMailbox = this.mailboxStatistics.MailboxGuid; mailboxState = this.mailboxStatistics.DisconnectReason; if (mailboxState == null) { this.mapiSession.Administration.SyncMailboxWithDS(this.guidMdb, this.guidMailbox); this.mailboxStatistics.Dispose(); this.mailboxStatistics = null; this.mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.Identity, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.Identity.ToString(), this.Database.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.Identity.ToString(), this.Database.ToString()))); mailboxState = this.mailboxStatistics.DisconnectReason; if (mailboxState == null) { base.WriteError(new RemoveNotDisconnectedStoreMailboxPermanentException(this.Identity.ToString()), ErrorCategory.InvalidArgument, this.Identity); } } if (MailboxStateParameter.SoftDeleted == this.MailboxState && Microsoft.Exchange.Data.Mapi.MailboxState.SoftDeleted == mailboxState) { this.deleteMailboxFlags = 18; } else if (MailboxStateParameter.Disabled == this.MailboxState && Microsoft.Exchange.Data.Mapi.MailboxState.Disabled == mailboxState) { this.deleteMailboxFlags = 2; } else { base.WriteError(new UnexpectedRemoveStoreMailboxStatePermanentException(this.Identity.ToString(), mailboxState.ToString(), this.MailboxState.ToString()), ErrorCategory.InvalidArgument, this.Identity); } } catch (MapiPermanentException exception2) { base.WriteError(exception2, ExchangeErrorCategory.ServerOperation, this.Identity); } catch (MapiRetryableException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, this.Identity); } finally { TaskLogger.LogExit(); } }
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; }
private static void SaveArchiveSecurityDescriptor(ADUser mailbox, IConfigDataProvider writableAdSession, RawSecurityDescriptor rawSd, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError) { ADObjectId adobjectId = mailbox.ArchiveDatabase ?? mailbox.Database; MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), mailbox.ArchiveGuid); try { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(adobjectId.ObjectGuid); using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn))) { logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName)); mapiMessageStoreSession.ForceStoreToRefreshMailbox(mailboxId); } } catch (FormatException) { logError(new TaskInvalidOperationException(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString())), ExchangeErrorCategory.ServerOperation, null); } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException) { logVerbose(Strings.VerboseArchiveNotExistInStore(mailbox.Name)); PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError); } catch (LocalizedException exception) { logError(new SetArchivePermissionException(mailbox.Name, exception), ExchangeErrorCategory.ServerOperation, null); } }
private void InternalValidateDatabaseMode() { base.InternalValidate(); if (base.HasErrors) { return; } this.m_database = this.DataObject; this.ResolveParameters(); this.CheckDatabaseObject(); if (this.m_database.MasterType != MasterType.DatabaseAvailabilityGroup) { this.m_output.WriteError(new InvalidOperationException(Strings.ErrorSingleDbCopyMove(this.m_database.Name, this.m_database.ServerName)), ErrorCategory.InvalidOperation, this.m_database.Identity); } this.m_dag = DagTaskHelper.ReadDag(this.m_database.MasterServerOrAvailabilityGroup, base.DataSession); if (this.m_dag == null) { this.m_output.WriteError(new InconsistentADException(Strings.InconsistentADDbMasterServerNotADag(this.m_database.Name, this.m_database.MasterServerOrAvailabilityGroup.ToString())), ErrorCategory.InvalidOperation, this.m_database.Identity); } if (this.m_dag.ThirdPartyReplication == ThirdPartyReplicationMode.Enabled) { this.m_output.WriteError(new InvalidTPRTaskException(base.MyInvocation.MyCommand.Name), ErrorCategory.InvalidOperation, this.m_database.Identity); } this.m_startingServer = this.GetCurrentActiveServer(this.m_database.Guid); base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, DatabaseTasksHelper.GetServerObject(new ServerIdParameter(Fqdn.Parse(this.m_startingServer.Fqdn)), (IConfigurationSession)base.DataSession, this.RootId, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <Server>)), true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope)); this.PreventMoveOfActiveSeedingSource(this.m_startingServer, new Database[] { this.m_database }); if (this.TargetServerSpecified) { this.PerformTargetServerValidation(); } }
internal bool GetMailboxQuarantineStatus() { if (this.mapiSession == null) { this.mapiSession = new MapiAdministrationSession(this.DbLocationInfo.ServerLegacyDN, Fqdn.Parse(this.DbLocationInfo.ServerFqdn)); } StoreMailboxIdParameter id = StoreMailboxIdParameter.Parse(this.exchangeGuid.ToString()); bool isQuarantined; using (MailboxStatistics mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(id, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(this.database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.Identity.ToString(), this.Database.Identity.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.Identity.ToString(), this.Database.Identity.ToString())))) { isQuarantined = mailboxStatistics.IsQuarantined; } return(isQuarantined); }
protected override IConfigDataProvider CreateSession() { this.ownerMailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, this.ResourceForestSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString()))); if (this.OwnerMailboxDatabase.Recovery) { base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxResidesInRDB(this.Identity.ToString())), ErrorCategory.InvalidArgument, this.Identity); } this.databaseLocationInfo = this.ActiveManager.GetServerForDatabase(this.OwnerMailboxDatabase.Guid); Server server = this.ownerMailboxDatabase.GetServer(); if (!server.IsE15OrLater) { base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxDatabaseNotOnE15Server(this.Database.ToString())), ErrorCategory.InvalidArgument, this.Identity); } if (this.mapiAdministrationSession == null) { this.mapiAdministrationSession = new MapiAdministrationSession(server.ExchangeLegacyDN, Fqdn.Parse(server.Fqdn)); } return(this.mapiAdministrationSession); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); if (this.PublicFolder) { MailboxTaskHelper.RemoveOrDisablePublicFolderMailbox(this.DataObject, this.exchangeGuid, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), true, false); } base.InternalProcessRecord(); if ("Archive" == base.ParameterSetName || "RemoteArchive" == base.ParameterSetName) { TaskLogger.Trace("DisableMailbox -Archive or -RemoteArchive skipping InternalProcessRecord", new object[0]); TaskLogger.LogExit(); return; } try { MailboxDatabase mailboxDatabase = null; if (this.mdbId != null) { mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.mdbId) { AllowLegacy = true }, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.mdbId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.mdbId.ToString()))); } if (mailboxDatabase != null && this.exchangeGuid != Guid.Empty) { Server server = mailboxDatabase.GetServer(); if (server == null) { this.WriteWarning(Strings.ErrorDBOwningServerNotFound(mailboxDatabase.Identity.ToString())); } else if (string.IsNullOrEmpty(server.ExchangeLegacyDN)) { this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.ExchangeLegacyDN.Name)); } else if (string.IsNullOrEmpty(server.Fqdn)) { this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.Fqdn.Name)); } else { base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(server.Fqdn)); using (MapiAdministrationSession mapiAdministrationSession = new MapiAdministrationSession(server.ExchangeLegacyDN, Fqdn.Parse(server.Fqdn))) { base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(this.Identity.ToString(), this.mdbId.ToString(), server.Fqdn)); mapiAdministrationSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(this.mdbId), this.exchangeGuid)); } } } } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex }); base.WriteVerbose(ex.LocalizedString); } catch (DataSourceTransientException ex2) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex2 }); this.WriteWarning(ex2.LocalizedString); } catch (DataSourceOperationException ex3) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex3 }); this.WriteWarning(ex3.LocalizedString); } TaskLogger.LogExit(); }
internal void RefreshStoreCache() { this.AddVerboseLog("Start: RefreshStoreCache"); bool flag = this.groupMailbox.WhenMailboxCreated == null || this.groupMailbox.WhenMailboxCreated.Value.AddMinutes(15.0).ToUniversalTime() > DateTime.UtcNow; if (flag) { return; } string text = null; try { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.groupMailbox.Database.ObjectGuid); text = serverForDatabase.ServerFqdn; using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, serverForDatabase.ServerLegacyDN + "/cn=Microsoft System Attendant", Fqdn.Parse(serverForDatabase.ServerFqdn))) { MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(this.groupMailbox.Database), this.groupMailbox.ExchangeGuid); this.AddVerboseLog(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName)); mapiMessageStoreSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid); } } catch (DatabaseNotFoundException) { this.AddVerboseLog(Strings.ErrorMailboxDatabaseNotFound(this.groupMailbox.Database.ToString())); } catch (MapiExceptionNetworkError) { this.AddVerboseLog(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty)); } catch (MailboxNotFoundException) { this.AddVerboseLog(Strings.VerboseMailboxNotExistInStore(this.groupMailbox.DistinguishedName)); } this.AddVerboseLog("End: RefreshStoreCache"); }
internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize) { MailboxResourceMonitorEntry.< > c__DisplayClass1 <T> CS$ < > 8__locals1 = new MailboxResourceMonitorEntry.< > c__DisplayClass1 <T>(); CS$ < > 8__locals1.< > 4__this = this; 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 (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 (MailboxResourceMonitorEntry mailboxResourceMonitorEntry2 = (MailboxResourceMonitorEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)))) { tagsToRead = mailboxResourceMonitorEntry2.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.GetResourceMonitorDigest(CS$ < > 8__locals1.databaseId.Guid, 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; } foreach (PropValue[] entry in entries) { MailboxResourceMonitorEntry mailboxResourceMonitorEntry = (MailboxResourceMonitorEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); try { mailboxResourceMonitorEntry.Instantiate(entry); mailboxResourceMonitorEntry.MapiSession = base.MapiSession; if (mailboxResourceMonitorEntry[MapiPropertyDefinitions.MailboxGuid] != null) { mailboxResourceMonitorEntry.Identity = new MailboxId(CS$ < > 8__locals1.databaseId, (Guid)mailboxResourceMonitorEntry[MapiPropertyDefinitions.MailboxGuid]); } mailboxResourceMonitorEntry.UpdateIdentity(mailboxResourceMonitorEntry.UpdateIdentityFlagsForFinding); mailboxResourceMonitorEntry.OriginatingServer = Fqdn.Parse(mailboxResourceMonitorEntry.MapiSession.ServerName); mailboxResourceMonitorEntry.ResetChangeTracking(true); } finally { mailboxResourceMonitorEntry.Dispose(); } yield return((T)((object)mailboxResourceMonitorEntry)); } yield break; yield break; }
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; }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { Database database = null; database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, base.DataSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString())), ExchangeErrorCategory.Client); if (database.Recovery) { base.WriteError(new TaskArgumentException(Strings.ErrorInvalidOperationOnRecoveryMailboxDatabase(this.Database.ToString())), ExchangeErrorCategory.Client, this.Identity); } DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(database.Id.ObjectGuid); } catch (ObjectNotFoundException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null); } if (base.IsVerboseOn) { base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(databaseLocationInfo.ServerFqdn)); } this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(databaseLocationInfo.ServerFqdn)); this.guidMdb = database.Guid; if (!Guid.TryParse(this.Identity.ToString(), out this.guidMailbox)) { base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidGuidFormat), ErrorCategory.InvalidArgument, this.Identity.ToString()); } } catch (MapiPermanentException exception2) { base.WriteError(exception2, ExchangeErrorCategory.ServerOperation, this.Identity); } catch (MapiRetryableException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, this.Identity); } finally { TaskLogger.LogExit(); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder); bool wildcardedSearch = false; if (!string.IsNullOrEmpty(base.Name)) { base.ValidateName(); base.RequestName = base.Name; } else { wildcardedSearch = true; base.RequestName = "MailboxRestore"; } this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); this.CheckForInvalidPublicFolderRestoreParameters(); if (this.targetUser.HasLocalArchive && this.targetUser.RecipientType == RecipientType.MailUser && this.targetUser.Database == null && !this.TargetIsArchive) { base.WriteError(new MissingArchiveParameterForRestorePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (this.targetUser.RecipientType != RecipientType.UserMailbox && (!this.TargetIsArchive || this.targetUser.RecipientType != RecipientType.MailUser)) { base.WriteError(new InvalidRecipientTypePermanentException(this.targetUser.ToString(), this.targetUser.RecipientType.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (this.TargetIsArchive && (this.targetUser.ArchiveGuid == Guid.Empty || this.targetUser.ArchiveDatabase == null)) { base.WriteError(new MailboxLacksArchivePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetIsArchive); } if (!this.TargetIsArchive && this.targetUser.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (base.ParameterSetName.Equals("RemoteMailboxRestore")) { if (!Guid.TryParse(this.SourceStoreMailbox.RawIdentity, out this.sourceMailboxGuid)) { base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("SourceStoreMailbox")), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } if (!base.Fields.IsModified("AllowLegacyDNMismatch") || !this.AllowLegacyDNMismatch) { base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("AllowLegacyDNMismatch")), ErrorCategory.InvalidArgument, this.AllowLegacyDNMismatch); } base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull); switch (this.RemoteRestoreType) { case RemoteRestoreType.RecoveryDatabase: this.restoreFlags |= MailboxRestoreType.Recovery; this.restoreFlags |= MailboxRestoreType.SoftDeleted; break; case RemoteRestoreType.DisconnectedMailbox: this.restoreFlags |= MailboxRestoreType.SoftDeleted; break; case RemoteRestoreType.SoftDeletedRecipient: this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient; break; default: base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("RemoteRestoreType")), ErrorCategory.InvalidArgument, this.RemoteRestoreType); break; } } else { base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull); string fqdn; string serverExchangeLegacyDn; ADObjectId adobjectId; int num; MailboxDatabase mailboxDatabase = base.CheckDatabase <MailboxDatabase>(this.SourceDatabase, NewRequest <MailboxRestoreRequest> .DatabaseSide.Source, this.SourceDatabase, out fqdn, out serverExchangeLegacyDn, out adobjectId, out num); if (mailboxDatabase.Recovery) { this.restoreFlags |= MailboxRestoreType.Recovery; } this.sourceDatabase = mailboxDatabase.Id; this.SourceStoreMailbox.Flags |= 1UL; using (MapiSession mapiSession = new MapiAdministrationSession(serverExchangeLegacyDn, Fqdn.Parse(fqdn))) { using (MailboxStatistics mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())))) { MailboxState?disconnectReason = mailboxStatistics.DisconnectReason; if (mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderPrimary || mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderSecondary) { this.restoreFlags |= MailboxRestoreType.PublicFolderMailbox; } bool flag = false; if (disconnectReason == null && !mailboxDatabase.Recovery) { mapiSession.Administration.SyncMailboxWithDS(mailboxDatabase.Guid, mailboxStatistics.MailboxGuid); using (MailboxStatistics mailboxStatistics2 = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())))) { disconnectReason = mailboxStatistics2.DisconnectReason; if (disconnectReason == null) { if (this.targetUser.OrganizationId != null && this.targetUser.OrganizationId.OrganizationalUnit != null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled) { IRecipientSession recipientSession = CommonUtils.CreateRecipientSession(mailboxStatistics.ExternalDirectoryOrganizationId, null, null); ADRecipient adrecipient = this.TargetIsArchive ? recipientSession.FindByExchangeGuidIncludingArchive(mailboxStatistics.MailboxGuid) : recipientSession.FindByExchangeGuid(mailboxStatistics.MailboxGuid); flag = (adrecipient != null && adrecipient.RecipientSoftDeletedStatus != 0); } if (!this.IsPublicFolderMailboxRestore && !flag) { base.WriteError(new CannotRestoreConnectedMailboxPermanentException(this.SourceStoreMailbox.ToString()), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } } } } if (flag) { this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient; } else if (disconnectReason != null) { if (disconnectReason != MailboxState.SoftDeleted) { this.restoreFlags |= MailboxRestoreType.Disabled; } else { this.restoreFlags |= MailboxRestoreType.SoftDeleted; } } this.sourceMailboxGuid = mailboxStatistics.MailboxGuid; this.sourceMailboxDN = mailboxStatistics.LegacyDN; } } if ((this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ArchiveGuid && this.sourceDatabase.Equals(this.targetUser.ArchiveDatabase)) || (!this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ExchangeGuid && this.sourceDatabase.Equals(this.targetUser.Database))) { base.WriteError(new CannotRestoreIntoSelfPermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } } if (this.restoreFlags.HasFlag(MailboxRestoreType.PublicFolderMailbox)) { if (this.targetUser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPublicToPrivateMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } } else if (this.targetUser.RecipientTypeDetails == RecipientTypeDetails.PublicFolderMailbox) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPrivateToPublicMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } base.RescopeToOrgId(this.targetUser.OrganizationId); if (base.ParameterSetName.Equals("RemoteMailboxRestore")) { base.PerRecordReportEntries.Add(new ReportEntry(MrsStrings.ReportRequestAllowedMismatch(base.ExecutingUserIdentity))); } else { base.ValidateLegacyDNMatch(this.sourceMailboxDN, this.targetUser, this.TargetMailbox); } ADObjectId mdbId = null; ADObjectId mdbServerSite = null; this.LocateAndChooseMdb(null, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, null, this.TargetMailbox, this.TargetMailbox, out mdbId, out mdbServerSite); base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.RequestName = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.MailboxRestore, this.TargetMailbox, wildcardedSearch); base.InternalValidate(); } finally { TaskLogger.LogExit(); } }