// Token: 0x06000C41 RID: 3137 RVA: 0x00036478 File Offset: 0x00034678 public static bool IsServerRcrSource(IADDatabase db, IADServer server, out DatabaseLocationInfo activeLocation) { ActiveManager noncachingActiveManagerInstance = ActiveManager.GetNoncachingActiveManagerInstance(); activeLocation = noncachingActiveManagerInstance.GetServerForDatabase(db.Guid, GetServerForDatabaseFlags.BasicQuery); return(Cluster.StringIEquals(activeLocation.ServerFqdn, server.Fqdn)); }
private DatabaseLocationInfo GetServerForDatabase(ActiveManager activeManager, Guid dbGuid) { DatabaseLocationInfo result = null; try { result = activeManager.GetServerForDatabase(dbGuid); } catch (DatabaseNotFoundException) { base.WriteWarning(string.Format("Caught DatabaseNotFoundException when trying to get the server for database {0} from activemanager; will use the server info from AD.", dbGuid)); } catch (ObjectNotFoundException) { base.WriteWarning(string.Format("Caught ObjectNotFoundException when trying to get the server for database {0} from activemanager; will use the server info from AD.", dbGuid)); } catch (StoragePermanentException) { base.WriteWarning(string.Format("Caught StoragePermanentException when trying to get the server for database {0} from activemanager; will use the server info from AD.", dbGuid)); } catch (StorageTransientException) { base.WriteWarning(string.Format("Caught StorageTransientException when trying to get the server for database {0} from activemanager; will use the server info from AD.", dbGuid)); } return(result); }
// Token: 0x06001204 RID: 4612 RVA: 0x00037D00 File Offset: 0x00035F00 private static DatabaseLocationInfo GetServerForActiveDatabaseCopy(MailboxDatabase database, ActiveManager activeManager, LogMessageDelegate logger) { Exception ex = null; DatabaseLocationInfo result = null; try { result = activeManager.GetServerForDatabase(database.Id.ObjectGuid); } catch (DatabaseNotFoundException ex2) { ex = ex2; } catch (ObjectNotFoundException ex3) { ex = ex3; } catch (StoragePermanentException ex4) { ex = ex4; } catch (StorageTransientException ex5) { ex = ex5; } if (ex != null) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseDatabaseNotFound(database.Id.ObjectGuid.ToString(), ex.Message), logger); } return(result); }
private void CallMailboxAssociationReplicationAssistant(ADUser groupMailbox) { Exception ex = null; try { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(groupMailbox.Database.ObjectGuid); base.WriteVerbose("Group mailbox database is on server {0}", new object[] { serverForDatabase.ServerFqdn }); using (AssistantsRpcClient assistantsRpcClient = new AssistantsRpcClient(serverForDatabase.ServerFqdn)) { assistantsRpcClient.StartWithParams("MailboxAssociationReplicationAssistant", groupMailbox.ExchangeGuid, groupMailbox.Database.ObjectGuid, string.Empty); } base.WriteVerbose("Started update of the user mailboxes for the new ExternalDirectoryObjectId", new object[0]); } catch (RpcException ex2) { ex = ex2; } catch (LocalizedException ex3) { ex = ex3; } if (ex != null) { base.WriteVerbose("Failed to call RPC to MailboxAssociationReplicationAssistant due the following exception: {0}", new object[] { ex }); this.WriteWarning(Strings.WarningUnableToUpdateUserMailboxes); } }
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); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (this.unlockMoveTarget) { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databaseObject.Guid); string serverFqdn = serverForDatabase.ServerFqdn; if (!this.DetectOnly) { UnlockMoveTargetUtil.UnlockMoveTarget(serverFqdn, this.databaseObject.Guid, this.mailboxGuid, this.organizationId); this.WriteResult(this.DataObject); } } else { StoreIntegrityCheckRequestFlags requestFlags = this.GetRequestFlags(); StoreIntegrityCheckJob storeIntegrityCheckJob = StoreIntegrityCheckAdminRpc.CreateStoreIntegrityCheckJob(this.databaseObject, this.mailboxGuid, requestFlags, this.CorruptionType, new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); if (storeIntegrityCheckJob != null) { this.WriteResult(storeIntegrityCheckJob); } } TaskLogger.LogExit(); }
private AmServerName GetCurrentActiveServer(Guid dbGuid) { ActiveManager noncachingActiveManagerInstance = ActiveManager.GetNoncachingActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = noncachingActiveManagerInstance.GetServerForDatabase(dbGuid); return(new AmServerName(serverForDatabase.ServerFqdn)); }
internal static List <Database> PopulateDatabasesFromServer(ActiveManager activeManager, Server server, bool includePassive) { if (activeManager == null) { throw new ArgumentNullException("activeManager"); } if (server == null) { throw new ArgumentNullException("server"); } List <Database> list = new List <Database>(); IEnumerable <Database> databases = server.GetDatabases(); if (databases != null) { foreach (Database database in databases) { if (includePassive) { list.Add(database); } else { DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(database.Guid); if ((serverForDatabase != null && serverForDatabase.ServerGuid == server.Guid) || (serverForDatabase == null && database.Server.ObjectGuid == server.Guid)) { list.Add(database); } } } } return(list); }
private ExRpcAdmin GetExRpcAdminForDatabase(DirectoryDatabase database) { ActiveManager activeManager = LoadBalanceADSettings.Instance.Value.UseCachingActiveManager ? ActiveManager.GetCachingActiveManagerInstance() : ActiveManager.GetNoncachingActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(database.Guid, true); return(ExRpcAdmin.Create("Client=MSExchangeMailboxLoadBalance", serverForDatabase.ServerFqdn, null, null, null)); }
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); } }
// 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; }
private bool IsFirstActiveMdbLocallyMounted() { IList <Database> list; if (!base.SourceMailboxServer.IsMailboxServer || !CrossPremiseTestMailFlowHelper.TryLoadAdObjects <Database>(base.Task.ConfigurationSession, this.adAdminGroups, out list)) { return(false); } ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance(); SortedList <Guid, string> sortedList = new SortedList <Guid, string>(); try { foreach (Database database in list) { DatabaseLocationInfo serverForDatabase = cachingActiveManagerInstance.GetServerForDatabase(database.Guid, GetServerForDatabaseFlags.None); if (serverForDatabase != null && serverForDatabase.ServerSite != null && serverForDatabase.ServerSite.Equals(this.localSite) && !string.IsNullOrEmpty(serverForDatabase.ServerFqdn)) { sortedList.Add(database.Guid, serverForDatabase.ServerFqdn); } } using (IEnumerator <KeyValuePair <Guid, string> > enumerator2 = sortedList.GetEnumerator()) { while (enumerator2.MoveNext()) { KeyValuePair <Guid, string> kvp = enumerator2.Current; Database database2 = list.ToList <Database>().Find(delegate(Database db) { Guid guid = db.Guid; KeyValuePair <Guid, string> kvp3 = kvp; return(guid == kvp3.Key); }); Database mdb = database2; KeyValuePair <Guid, string> kvp4 = kvp; if (base.IsMdbMounted(mdb, kvp4.Value)) { KeyValuePair <Guid, string> kvp2 = kvp; return(kvp2.Value.Equals(base.SourceMailboxServer.Fqdn, StringComparison.OrdinalIgnoreCase)); } } } return(false); } catch (ObjectNotFoundException ex) { base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex.ToString())); } catch (StoragePermanentException ex2) { base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex2.ToString())); } catch (StorageTransientException ex3) { base.Task.WriteWarning(Strings.CrossPremiseMapMdbToServerFailure(ex3.ToString())); } return(false); }
private static void ExecuteAdminRpc(Guid databaseGuid, Action <ExRpcAdmin, string> action, Task.TaskErrorLoggingDelegate writeError, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose) { ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(databaseGuid); string serverFqdn = serverForDatabase.ServerFqdn; using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=Management", serverFqdn, null, null, null)) { action(exRpcAdmin, serverFqdn); } }
// Token: 0x06000C42 RID: 3138 RVA: 0x000364AC File Offset: 0x000346AC public static bool IsServerRcrSource(IADDatabase db, string serverName, ITopologyConfigurationSession adSession, out DatabaseLocationInfo activeLocation) { bool result; using (ActiveManager activeManager = ActiveManager.CreateCustomActiveManager(false, null, null, null, null, null, null, adSession, true)) { activeLocation = activeManager.GetServerForDatabase(db.Guid, GetServerForDatabaseFlags.BasicQuery); result = Cluster.StringIEquals(new AmServerName(activeLocation.ServerFqdn).NetbiosName, serverName); } return(result); }
// Token: 0x06000818 RID: 2072 RVA: 0x00021380 File Offset: 0x0001F580 private BackEndServer GetLegacyServerForDatabase(Guid databaseGuid) { this.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "[MailboxServerLocator.GetLegacyServerForDatabase] Resolving legacy server for database {0}.", databaseGuid); ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = cachingActiveManagerInstance.GetServerForDatabase(databaseGuid); if (serverForDatabase != null) { this.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "[MailboxServerLocator.GetLegacyServerForDatabase] Active manager returns server {1} for database {0}.", databaseGuid, serverForDatabase.ServerFqdn); return(new BackEndServer(serverForDatabase.ServerFqdn, serverForDatabase.ServerVersion)); } throw new MailboxServerLocatorException(this.DatabaseGuid.ToString()); }
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); } }
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); } }
private Server GetActiveServer(Guid dbGuid) { if (dbGuid == Guid.Empty) { throw new ArgumentNullException("dbGuid"); } ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(dbGuid); Server server = base.GlobalConfigSession.FindServerByFqdn(serverForDatabase.ServerFqdn); if (server == null) { throw new RecipientTaskException(new LocalizedString(new ServerNotFoundException("couldn't find server", serverForDatabase.ServerFqdn).Message)); } return(server); }
private void PopulateDatabaseCache() { if (this.m_databaseTable == null || this.m_databaseTable.Count == 0) { Database[] databases = this.m_sourceServer.GetDatabases(); Dictionary <Guid, DatabaseLocationInfo> dbInfoTable = new Dictionary <Guid, DatabaseLocationInfo>(databases.Length); ActiveManager noncachingActiveManagerInstance = ActiveManager.GetNoncachingActiveManagerInstance(); foreach (Database database in databases) { DatabaseLocationInfo serverForDatabase = noncachingActiveManagerInstance.GetServerForDatabase(database.Guid); dbInfoTable[database.Guid] = serverForDatabase; } IEnumerable <Database> source = from db in databases where this.IsDatabaseActiveOnSourceServer(db, dbInfoTable) select db; this.m_databaseTable = source.ToDictionary((Database db) => db.Guid); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); this.unlockMoveTarget = false; foreach (MailboxCorruptionType mailboxCorruptionType in this.CorruptionType) { MailboxCorruptionType mailboxCorruptionType2 = mailboxCorruptionType; if (mailboxCorruptionType2 == MailboxCorruptionType.LockedMoveTarget) { this.unlockMoveTarget = true; } } if (this.unlockMoveTarget) { ADUser aduser = ((ADRecipient)base.GetDataObject <ADRecipient>(this.Mailbox, this.RecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Mailbox.ToString())))) as ADUser; if (this.CorruptionType.Length != 1) { base.WriteError(new CorruptionTypeParameterIncompatibleException(MailboxCorruptionType.LockedMoveTarget.ToString()), ErrorCategory.InvalidArgument, this.CorruptionType); } if (UnlockMoveTargetUtil.IsValidLockedStatus(aduser.MailboxMoveStatus)) { base.WriteError(new UnableToUnlockMailboxDueToOutstandingMoveRequestException(this.Mailbox.ToString(), aduser.MailboxMoveStatus.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databaseObject.Guid); if (!UnlockMoveTargetUtil.IsMailboxLocked(serverForDatabase.ServerFqdn, this.databaseObject.Guid, aduser.ExchangeGuid)) { base.WriteError(new MailboxIsNotLockedException(this.Mailbox.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } } if (!this.databaseObject.IsMailboxDatabase) { base.WriteError(new OnlineIsIntegException(this.databaseObject.Name, Strings.NotMailboxDatabase, null), ErrorCategory.InvalidArgument, null); } Guid guid; if (this.StoreMailbox != null && !Guid.TryParse(this.StoreMailbox.RawIdentity, out guid)) { throw new ArgumentException("StoreMailbox"); } TaskLogger.LogExit(); }
private void FilterActiveDatabases(ActiveManager activeManager, IEnumerable <Database> databases) { AmServerName amServerName = new AmServerName(this.server); foreach (Database database in databases) { if (this.IncludePassive) { this.databases.Add(database); } else { DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(database.Guid); AmServerName dst = new AmServerName(serverForDatabase.ServerFqdn); if (amServerName.Equals(dst)) { this.databases.Add(database); } } } }
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(); } } }
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; }
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"); }
// Token: 0x0600135A RID: 4954 RVA: 0x0004EAB0 File Offset: 0x0004CCB0 private static AmServerName GetActiveServerForDatabase(Guid dbGuid, ActiveManager activeManager) { AmServerName result = null; Exception ex = null; try { DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(dbGuid, GetServerForDatabaseFlags.BasicQuery); result = new AmServerName(serverForDatabase.ServerFqdn, false); } catch (DatabaseNotFoundException ex2) { ex = ex2; } catch (ObjectNotFoundException ex3) { ex = ex3; } catch (StoragePermanentException ex4) { ex = ex4; } catch (StorageTransientException ex5) { ex = ex5; } catch (AmCommonTransientException ex6) { ex = ex6; } if (ex != null) { ExTraceGlobals.MonitoringTracer.TraceError <Guid, Exception>(0L, "CopyStatusHelper.GetActiveServerForDatabase(): Returning NULL. Got exception for database {0}: {1}", dbGuid, ex); } return(result); }
private bool AcquireADObjectsForPrivateMdb() { if (MdbSystemMailboxPinger.OnTestPing != null) { return(true); } bool flag = false; try { if (this.principal != null) { if (!this.VerifyLocalBoxCall(this.principal.MailboxInfo.Location.ServerFqdn)) { return(false); } flag = true; return(true); } else { if ((this.pingerState == MdbSystemMailboxPinger.PingerState.NeedReinitialization || this.pingerState == MdbSystemMailboxPinger.PingerState.NotInitialized) && TimeProvider.UtcNow - this.lastSessionAttemptUtc < MdbSystemMailboxPinger.OpenSessionAttemptInterval) { ExTraceGlobals.DatabasePingerTracer.TraceDebug((long)this.GetHashCode(), "Need to acquire principal, but not enough time has passed between attempts."); return(false); } this.lastSessionAttemptUtc = TimeProvider.UtcNow; ActiveManager noncachingActiveManagerInstance = ActiveManager.GetNoncachingActiveManagerInstance(); DatabaseLocationInfo serverForDatabase = noncachingActiveManagerInstance.GetServerForDatabase(this.databaseGuid, true); if (!this.VerifyLocalBoxCall(serverForDatabase.ServerFqdn)) { return(false); } ADSessionSettings adsessionSettings = ADSessionSettings.FromRootOrgScopeSet(); ADSystemMailbox adSystemMailbox = this.FindSystemMailbox(adsessionSettings); Server server = this.FindMdbServer(adsessionSettings, serverForDatabase.ServerFqdn); if (server == null) { ExTraceGlobals.DatabasePingerTracer.TraceError <string>((long)this.GetHashCode(), "[MdbSystemMailboxPinger.AcquireADObjectsForPrivateMdb] Failed to find server with FQDN: '{0}'", serverForDatabase.ServerFqdn); return(false); } this.principal = ExchangePrincipal.FromADSystemMailbox(adsessionSettings, adSystemMailbox, server); this.accessInfo = new MailboxAccessInfo(new WindowsPrincipal(WindowsIdentity.GetCurrent())); flag = true; } } catch (StoragePermanentException arg) { ExTraceGlobals.DatabasePingerTracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "Encountered StoragePermanentException obtaining ExchangePrincipal. Exception: {0}", arg); } catch (StorageTransientException arg2) { ExTraceGlobals.DatabasePingerTracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "Encountered StorageTransientException obtaining ExchangePrincipal. Exception: {0}", arg2); } catch (DataSourceOperationException arg3) { ExTraceGlobals.DatabasePingerTracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "EncounteredDataSourceOperationException obtaining ExchangePrincipal. Exception :{0}", arg3); } catch (DataSourceTransientException arg4) { ExTraceGlobals.DatabasePingerTracer.TraceError <DataSourceTransientException>((long)this.GetHashCode(), "Encountered DataSourceTransientException obtaining ExchangePrincipal. Exception :{0}", arg4); } finally { if (!flag) { this.principal = null; this.DisposeAccessInfo(); } } return(flag); }
protected override void WriteResult <T>(IEnumerable <T> dataObjects) { TaskLogger.LogEnter(new object[] { dataObjects }); if (!this.Status) { using (IEnumerator <T> enumerator = dataObjects.GetEnumerator()) { while (enumerator.MoveNext()) { T t = enumerator.Current; IConfigurable configurable = t; Database database = (Database)configurable; bool flag = false; Server server = database.GetServer(); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(database.Identity.ToString())), ErrorCategory.InvalidOperation, database.Identity); } else { flag = server.IsE15OrLater; } if (this.AllowLegacy || flag) { this.WriteResult(database); } } goto IL_66D; } } Dictionary <string, Collection <Database> > dictionary = new Dictionary <string, Collection <Database> >(); foreach (T t2 in dataObjects) { IConfigurable configurable2 = t2; Database database2 = (Database)configurable2; string text = null; bool flag2 = false; Server server2 = database2.GetServer(); if (server2 == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(database2.Identity.ToString())), ErrorCategory.InvalidOperation, database2.Identity); } else { flag2 = server2.IsE15OrLater; } bool flag3; if (flag2) { ActiveManager activeManager = null; Exception ex = null; try { activeManager = ActiveManager.CreateCustomActiveManager(false, null, null, null, null, null, null, (ITopologyConfigurationSession)this.ConfigurationSession, false); DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(database2.Guid, GetServerForDatabaseFlags.IgnoreAdSiteBoundary); text = serverForDatabase.ServerFqdn; } catch (DatabaseNotFoundException ex2) { ex = ex2; } catch (ObjectNotFoundException ex3) { ex = ex3; } catch (ServerForDatabaseNotFoundException ex4) { ex = ex4; } finally { if (activeManager != null) { activeManager.Dispose(); activeManager = null; } } if (ex != null) { TaskLogger.Trace("GetDatabase.WriteResult() raised exception from AM.GetServerForDatabase() for database '{0}': {1}", new object[] { database2.Name, ex.ToString() }); this.WriteResult(database2); this.WriteWarning(Strings.ErrorFailedToQueryActiveServerForDatabase(database2.Name, ex.Message)); continue; } database2.MountedOnServer = text; flag3 = true; } else { text = server2.Fqdn; database2.MountedOnServer = text; flag3 = this.AllowLegacy; } if (flag3) { Collection <Database> collection; if (!dictionary.TryGetValue(text, out collection)) { collection = new Collection <Database>(); dictionary.Add(text, collection); } collection.Add(database2); } } foreach (string text2 in dictionary.Keys) { Collection <Database> collection2 = dictionary[text2]; try { base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(text2)); using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=Management", text2, null, null, null)) { Guid[] array = new Guid[collection2.Count]; for (int i = 0; i < collection2.Count; i++) { array[i] = collection2[i].Guid; base.WriteVerbose(Strings.VerboseCheckDatabaseStatus(array[i].ToString())); } MdbStatus[] array2 = exRpcAdmin.ListMdbStatus(array); for (int j = 0; j < collection2.Count; j++) { collection2[j].Mounted = new bool?((array2[j].Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline); collection2[j].OnlineMaintenanceInProgress = new bool?((array2[j].Status & MdbStatusFlags.Isinteg) == MdbStatusFlags.Offline); collection2[j].BackupInProgress = new bool?((array2[j].Status & MdbStatusFlags.Backup) != MdbStatusFlags.Offline); if (collection2[j].Mounted.Value) { this.FillLastBackupTimes(exRpcAdmin, collection2[j]); if (collection2[j].LastFullBackup != null) { collection2[j].LastFullBackup = new DateTime?(collection2[j].LastFullBackup.Value.ToLocalTime()); } if (collection2[j].LastIncrementalBackup != null) { collection2[j].LastIncrementalBackup = new DateTime?(collection2[j].LastIncrementalBackup.Value.ToLocalTime()); } if (collection2[j].LastDifferentialBackup != null) { collection2[j].LastDifferentialBackup = new DateTime?(collection2[j].LastDifferentialBackup.Value.ToLocalTime()); } if (collection2[j].LastCopyBackup != null) { collection2[j].LastCopyBackup = new DateTime?(collection2[j].LastCopyBackup.Value.ToLocalTime()); } this.FillDatabaseSize(exRpcAdmin, collection2[j]); if (collection2[j].GetServer().IsE15OrLater) { this.FillDatabaseProcessInfo(exRpcAdmin, collection2[j]); } } else { TaskLogger.Trace("Database {0} is not mounted, not getting the last backup times of it", new object[] { collection2[j].Name }); } this.WriteResult(collection2[j]); } } } catch (MapiPermanentException ex5) { TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.WriteResult() raises exception while connecting to server '{0}': {1}", new object[] { text2, ex5.Message }), new object[0]); foreach (Database dataObject in collection2) { this.WriteResult(dataObject); this.WriteWarning(Strings.ErrorFailedToConnectToStore(text2)); } } catch (MapiRetryableException ex6) { TaskLogger.Trace(string.Format(CultureInfo.InvariantCulture, "GetDatabase.WriteResult() raises exception while connecting to server '{0}': {1}", new object[] { text2, ex6.Message }), new object[0]); foreach (Database dataObject2 in collection2) { this.WriteResult(dataObject2); this.WriteWarning(Strings.ErrorFailedToConnectToStore(text2)); } } } IL_66D: TaskLogger.LogExit(); }
public static ReplayConfiguration GetReplayConfiguration(IADDatabaseAvailabilityGroup dag, IADDatabase mdb, IADServer hostServer, ActiveManager activeManager, out bool fSource, out Exception ex) { ReplayConfiguration result = null; fSource = false; ex = null; try { DatabaseLocationInfo serverForDatabase = activeManager.GetServerForDatabase(mdb.Guid, GetServerForDatabaseFlags.BasicQuery); if (string.IsNullOrEmpty(serverForDatabase.ServerFqdn)) { ReplayConfiguration.Tracer.TraceDebug <string>(0L, "GetReplayConfiguration({0}) Performing a BasicQuery was insufficient. Calling again with AD access.", mdb.Name); serverForDatabase = activeManager.GetServerForDatabase(mdb.Guid); } else { ReplayConfiguration.Tracer.TraceDebug <string>(0L, "GetReplayConfiguration({0}) Performing a BasicQuery was sufficient. AD calls were avoided!", mdb.Name); } AmServerName amServerName = new AmServerName(serverForDatabase.ServerFqdn); AmServerName amServerName2 = new AmServerName(hostServer.Fqdn); ReplayConfiguration.Tracer.TraceDebug <string, string, string>(0L, "GetReplayConfiguration({0}): GSFD returned active server of: {1}, hostServerFqdn is: {2}", mdb.Name, amServerName.Fqdn, amServerName2.Fqdn); if (AmServerName.IsEqual(amServerName, amServerName2)) { fSource = true; } if (fSource) { if (mdb.ReplicationType == ReplicationType.None) { result = new SingleCopyReplayConfiguration(dag, mdb, hostServer, LockType.ReplayService); } else { result = RemoteReplayConfiguration.ServiceGetReplayConfig(dag, mdb, hostServer, serverForDatabase.ServerFqdn, ReplayConfigType.RemoteCopySource); } } else { if (mdb.ReplicationType != ReplicationType.Remote) { throw new ReplayConfigNotFoundException(mdb.Name, hostServer.Name); } result = RemoteReplayConfiguration.ServiceGetReplayConfig(dag, mdb, hostServer, serverForDatabase.ServerFqdn, ReplayConfigType.RemoteCopyTarget); } } catch (DatabaseNotFoundException ex2) { ex = ex2; } catch (ServerForDatabaseNotFoundException ex3) { ex = ex3; } catch (ObjectNotFoundException ex4) { ex = ex4; } catch (TransientException ex5) { ex = ex5; } return(result); }
// 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))); }
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); } } }