protected override IConfigDataProvider CreateSession() { ADObjectId rootOrgContainerId = ADSystemConfigurationSession.GetRootOrgContainerId(this.DomainController, null); ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, rootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true); this.currentOrgConfigSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(this.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 313, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\GetRequestStatistics.cs"); adsessionSettings = ADSessionSettings.RescopeToSubtree(adsessionSettings); if (MapiTaskHelper.IsDatacenter || MapiTaskHelper.IsDatacenterDedicated) { adsessionSettings.IncludeSoftDeletedObjects = true; adsessionSettings.IncludeInactiveMailbox = true; } this.gcSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(this.DomainController, true, ConsistencyMode.PartiallyConsistent, adsessionSettings, 330, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\GetRequestStatistics.cs"); this.recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(this.DomainController, true, ConsistencyMode.PartiallyConsistent, adsessionSettings, 337, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\GetRequestStatistics.cs"); this.configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromRootOrgScopeSet(), 343, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\GetRequestStatistics.cs"); if (this.rjProvider != null) { this.rjProvider.Dispose(); this.rjProvider = null; } if (base.ParameterSetName.Equals("MigrationRequestQueue")) { MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.RequestQueue, this.configSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(this.RequestQueue.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(this.RequestQueue.ToString()))); this.rjProvider = new RequestJobProvider(mailboxDatabase.Guid); } else { this.rjProvider = new RequestJobProvider(this.gcSession, this.currentOrgConfigSession); } this.rjProvider.LoadReport = this.IncludeReport; return(this.rjProvider); }
// 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); }
internal void RefreshCounters(bool updateDatabases, bool updateStatistics) { if (updateDatabases) { IEnumerable <MailboxDatabase> enumerable; if (MailboxDatabase.TryDiscoverLocalMailboxDatabases(out enumerable)) { this.currentDatabases = enumerable; } else { this.lastMailboxDatabaseNameRefresh = DateTime.MinValue; Log.LogErrorMessage("Unable to discover any mailbox databases in AD for the '{0}' server.", new object[] { Environment.MachineName }); } } if (updateStatistics && this.currentDatabases != null) { Dictionary <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > dictionary; if (MailboxDatabaseCalculatedCounters.TryCreateCounters(this.currentDatabases, out dictionary)) { this.currentCounters = dictionary; } else { this.lastStatisticsRefresh = DateTime.MinValue; Log.LogErrorMessage("Unable to create counters.", new object[0]); } } this.doingWork = false; }
private SearchTestResult GetTestResultFromMailboxDatabase(MailboxDatabase mdb) { if (mdb == null) { throw new ArgumentNullException("mdb"); } SearchTestResult defaultSearchTestResult = SearchTestResult.DefaultSearchTestResult; defaultSearchTestResult.Database = mdb.ToString(); defaultSearchTestResult.DatabaseGuid = mdb.Guid; Server activeServer = this.GetActiveServer(mdb.Guid); defaultSearchTestResult.Server = activeServer.Name; defaultSearchTestResult.ServerGuid = activeServer.Guid; ADUser monitoringMailbox = this.GetMonitoringMailbox(mdb, activeServer); if (monitoringMailbox == null) { throw new ManagementObjectNotFoundException(Strings.TestSearchMdbMonitorMbxIsNull(mdb.ToString())); } defaultSearchTestResult.UserLegacyExchangeDN = monitoringMailbox.LegacyExchangeDN; defaultSearchTestResult.Mailbox = monitoringMailbox.DisplayName; defaultSearchTestResult.MailboxGuid = monitoringMailbox.ExchangeGuid; return(defaultSearchTestResult); }
public IEnumerable <DirectoryDatabase> GetDatabasesOwnedByServer(DirectoryServer server) { IOperationRetryManager retryManager = LoadBalanceOperationRetryManager.Create(this.logger); foreach (MailboxDatabase database in this.ConfigurationSession.GetDatabasesOnServer(server.Identity)) { DirectoryDatabase result = null; MailboxDatabase databaseCopy = database; OperationRetryManagerResult operationResult = retryManager.TryRun(delegate { result = this.DirectoryDatabaseFromDatabase(databaseCopy); }); if (!operationResult.Succeeded) { this.logger.LogError(operationResult.Exception, "Could not retrieve database {0} for server {1}.", new object[] { databaseCopy.Name, server.Name }); } else if (result != null) { yield return(result); } } yield break; }
private string GetOabObjectId(ADUser user) { if (user.OfflineAddressBook != null) { return(user.OfflineAddressBook.ObjectGuid.ToString()); } MailboxDatabase mailboxDatabase = base.ConfigSession.Read <MailboxDatabase>(user.Database); if (mailboxDatabase == null) { base.WriteError(new TestWebServicesTaskException(Strings.ErrorOabNotFoundForUser(user.Identity.ToString())), ErrorCategory.InvalidData, null); } else if (mailboxDatabase.OfflineAddressBook != null) { return(mailboxDatabase.OfflineAddressBook.ObjectGuid.ToString()); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(user.Id), 258, "GetOabObjectId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AutoDiscover\\TestOutlookWebServicesTask.cs"); OfflineAddressBook[] array = tenantOrTopologyConfigurationSession.Find <OfflineAddressBook>(null, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, OfflineAddressBookSchema.IsDefault, true), null, 1); if (array.Length > 0) { return(array[0].Id.ObjectGuid.ToString()); } base.WriteError(new TestWebServicesTaskException(Strings.ErrorOabNotFoundForUser(user.Identity.ToString())), ErrorCategory.InvalidData, null); return(null); }
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(); }
// Token: 0x06001203 RID: 4611 RVA: 0x00037B14 File Offset: 0x00035D14 private static MailboxDatabaseWithLocationInfo FindDatabaseAndLocation(IList <MailboxDatabase> allDatabases, ActiveManager activeManager, bool isInitialProvisioning, bool localSiteDatabasesOnly, LogMessageDelegate logger, int?qualifiedMinServerVersion, ref LoadBalancingReport loadBalancingReport) { int num = (int)Math.Round((double)allDatabases.Count * 0.1); num = ((num < 10) ? Math.Min(allDatabases.Count, 10) : num); List <MailboxDatabaseWithLocationInfo> list = new List <MailboxDatabaseWithLocationInfo>(); List <MailboxDatabaseWithLocationInfo> list2 = new List <MailboxDatabaseWithLocationInfo>(); Random random = new Random(); while (allDatabases.Count > 0 && list.Count + list2.Count <= num) { int index = random.Next(allDatabases.Count); MailboxDatabase mailboxDatabase = allDatabases[index]; if (isInitialProvisioning && mailboxDatabase.IsExcludedFromInitialProvisioning) { loadBalancingReport.databasesExcludedFromInitialProvisioning++; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbInitialProvisioningDatabaseExcluded(mailboxDatabase.Name), logger); } else { DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase, activeManager, logger); if (serverForActiveDatabaseCopy != null && (qualifiedMinServerVersion == null || serverForActiveDatabaseCopy.ServerVersion >= qualifiedMinServerVersion.Value)) { if (!localSiteDatabasesOnly || PhysicalResourceLoadBalancing.IsDatabaseInLocalSite(serverForActiveDatabaseCopy, logger)) { if (list2.Count < 3) { return(new MailboxDatabaseWithLocationInfo(mailboxDatabase, serverForActiveDatabaseCopy)); } list.Add(new MailboxDatabaseWithLocationInfo(mailboxDatabase, serverForActiveDatabaseCopy)); } else { list2.Add(new MailboxDatabaseWithLocationInfo(mailboxDatabase, serverForActiveDatabaseCopy)); } } } allDatabases.RemoveAt(index); } loadBalancingReport.databasesAndLocationCount = list.Count + list2.Count; loadBalancingReport.firstPreferenceDatabasesCount = list.Count; loadBalancingReport.secondPreferenceDatabasesCount = list2.Count; if (list.Count + list2.Count <= 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger); return(null); } int maxValue = (int)Math.Ceiling((double)(list.Count + list2.Count) * 0.3); int num2 = random.Next(maxValue); if (num2 < list.Count) { return(list[num2]); } MailboxDatabaseWithLocationInfo mailboxDatabaseWithLocationInfo = list2[num2 - list.Count]; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRemoteSiteDatabaseReturned(mailboxDatabaseWithLocationInfo.MailboxDatabase.Name, mailboxDatabaseWithLocationInfo.DatabaseLocationInfo.ServerFqdn), logger); return(mailboxDatabaseWithLocationInfo); }
// Token: 0x06001208 RID: 4616 RVA: 0x00037FB4 File Offset: 0x000361B4 internal static MailboxDatabaseWithLocationInfo FindDatabaseAndLocationForEnterpriseSiteMailbox(string domainController, LogMessageDelegate logger, ScopeSet scopeSet) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbEnterSiteMailboxEnterprise, logger); ITopologyConfigurationSession configSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController); List <MailboxDatabase> databasesForProvisioningCached = PhysicalResourceLoadBalancing.GetDatabasesForProvisioningCached(configSession, false, logger); if (databasesForProvisioningCached.Count == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableDatabase, logger); return(null); } List <MailboxDatabase> list = new List <MailboxDatabase>(); foreach (MailboxDatabase mailboxDatabase in databasesForProvisioningCached) { if (mailboxDatabase.AdminDisplayVersion == null) { mailboxDatabase.AdminDisplayVersion = Server.GetServerVersion(mailboxDatabase.ServerName); } if (mailboxDatabase.AdminDisplayVersion.Major >= PhysicalResourceLoadBalancing.MajorVersionE15) { list.Add(mailboxDatabase); } } if (list.Count == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoAvailableE15Database(databasesForProvisioningCached.Count), logger); return(null); } ActiveManager cachingActiveManagerInstance = ActiveManager.GetCachingActiveManagerInstance(); Random random = new Random(); while (list.Count != 0) { int index = random.Next(list.Count); MailboxDatabase mailboxDatabase2 = list[index]; list.RemoveAt(index); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGetServerForActiveDatabaseCopy(mailboxDatabase2.Name), logger); DatabaseLocationInfo serverForActiveDatabaseCopy = PhysicalResourceLoadBalancing.GetServerForActiveDatabaseCopy(mailboxDatabase2, cachingActiveManagerInstance, logger); if (serverForActiveDatabaseCopy != null) { MailboxDatabaseWithLocationInfo mailboxDatabaseWithLocationInfo = new MailboxDatabaseWithLocationInfo(mailboxDatabase2, serverForActiveDatabaseCopy); if (mailboxDatabase2.MasterType == MasterType.DatabaseAvailabilityGroup) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbRemoteSiteDatabaseReturned(mailboxDatabaseWithLocationInfo.MailboxDatabase.Name, mailboxDatabaseWithLocationInfo.DatabaseLocationInfo.ServerFqdn), logger); return(mailboxDatabaseWithLocationInfo); } mailboxDatabaseWithLocationInfo = PhysicalResourceLoadBalancing.VerifyStatusAndSelectDB(new List <MailboxDatabaseWithLocationInfo> { mailboxDatabaseWithLocationInfo }, domainController, logger, scopeSet); if (mailboxDatabaseWithLocationInfo != null) { return(mailboxDatabaseWithLocationInfo); } } } return(null); }
private void ApplyLoadBalanceSettingValuesToDatabase(MailboxDatabase database, DirectoryDatabase directoryDatabase) { QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, database.MasterServerOrAvailabilityGroup); DatabaseAvailabilityGroup ownerDag = this.ConfigurationSession.Find <DatabaseAvailabilityGroup>(null, QueryScope.SubTree, filter, null, 1).FirstOrDefault <DatabaseAvailabilityGroup>(); directoryDatabase.RelativeLoadCapacity = this.GetRelativeLoadCapacityForDatabase(database, ownerDag); directoryDatabase.MaximumSize = this.GetMaximumFileSizeForDatabase(database, ownerDag); }
private ByteQuantifiedSize GetMaximumFileSizeForDatabase(MailboxDatabase database, DatabaseAvailabilityGroup ownerDag) { if (database.MailboxLoadBalanceMaximumEdbFileSize != null) { return(database.MailboxLoadBalanceMaximumEdbFileSize.Value); } return(this.GetMaximumDatabaseFileSizeForDag(ownerDag)); }
private MailboxDatabase LocateAndVerifyMdb(DatabaseIdParameter databaseId, out ServerVersion targetServerVersion) { MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseId, base.ConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseId.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseId.ToString()))); DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mailboxDatabase.Id.ObjectGuid, null, null, FindServerFlags.None); targetServerVersion = new ServerVersion(databaseInformation.ServerVersion); this.EnsureSupportedServerVersion(databaseInformation.ServerVersion); return(mailboxDatabase); }
public DirectoryDatabase GetDatabase(Guid guid) { MailboxDatabase mailboxDatabase = this.ConfigurationSession.Read <MailboxDatabase>(new ADObjectId(guid)); if (mailboxDatabase == null) { throw new DatabaseNotFoundException(guid.ToString()); } return(this.DirectoryDatabaseFromDatabase(mailboxDatabase)); }
private DirectoryDatabase DirectoryDatabaseFromDatabase(MailboxDatabase database) { bool isExcludedFromProvisioning = (bool)database[MailboxDatabaseSchema.IsExcludedFromProvisioning]; bool isExcludedFromInitialProvisioning = (bool)database[MailboxDatabaseSchema.IsExcludedFromInitialProvisioning]; DirectoryIdentity identity = DirectoryIdentity.CreateFromADObjectId(database.Id, DirectoryObjectType.Database); DirectoryDatabase directoryDatabase = new DirectoryDatabase(this, identity, this.clientFactory, isExcludedFromProvisioning, isExcludedFromInitialProvisioning, database.MailboxProvisioningAttributes); this.ApplyLoadBalanceSettingValuesToDatabase(database, directoryDatabase); return(directoryDatabase); }
private static bool FindServerInSameDagButDontHaveTheDatabase(DataRow inputRow, DataRow row, DataObjectStore store) { if (DBNull.Value.Equals(row["DatabaseAvailabilityGroup"])) { return(false); } MailboxDatabase mailboxDatabase = (MailboxDatabase)store.GetDataObject("MailboxDatabase"); string b = (string)row["DatabaseAvailabilityGroup"]; string serverName = (string)row["Name"]; return(mailboxDatabase.MasterServerOrAvailabilityGroup.Name == b && !mailboxDatabase.Servers.Any((ADObjectId x) => serverName.Equals(x.Name, StringComparison.OrdinalIgnoreCase))); }
private int GetRelativeLoadCapacityForDatabase(MailboxDatabase database, DatabaseAvailabilityGroup ownerDag) { if (database.MailboxLoadBalanceRelativeLoadCapacity != null) { return(database.MailboxLoadBalanceRelativeLoadCapacity.Value); } if (ownerDag != null && ownerDag.MailboxLoadBalanceRelativeLoadCapacity != null) { return(ownerDag.MailboxLoadBalanceRelativeLoadCapacity.Value); } return(this.settings.DefaultDatabaseRelativeLoadCapacity); }
internal static QueryFilter GetUMEnabledUserQueryFilter(MailboxDatabase database) { return(new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, database.Id), new TextFilter(ADRecipientSchema.EmailAddresses, ProxyAddressPrefix.UM.PrimaryPrefix, MatchOptions.Prefix, MatchFlags.Default), new ComparisonFilter(ComparisonOperator.NotEqual, ADRecipientSchema.RecipientTypeDetailsValue, RecipientTypeDetails.MailboxPlan), new ComparisonFilter(ComparisonOperator.NotEqual, ADRecipientSchema.RecipientTypeDetailsValue, RecipientTypeDetails.ArbitrationMailbox), new ComparisonFilter(ComparisonOperator.NotEqual, ADRecipientSchema.RecipientTypeDetailsValue, RecipientTypeDetails.SystemMailbox), new ComparisonFilter(ComparisonOperator.NotEqual, ADRecipientSchema.RecipientTypeDetailsValue, RecipientTypeDetails.SystemAttendantMailbox) })); }
// Token: 0x06001220 RID: 4640 RVA: 0x00039098 File Offset: 0x00037298 public MailboxDatabaseWithLocationInfo(MailboxDatabase mailboxDatabase, DatabaseLocationInfo databaseLocationInfo) { if (mailboxDatabase == null) { throw new ArgumentNullException("mailboxDatabase"); } if (databaseLocationInfo == null) { throw new ArgumentNullException("databaseLocationInfo"); } this.MailboxDatabase = mailboxDatabase; this.DatabaseLocationInfo = databaseLocationInfo; }
// Token: 0x06000AC3 RID: 2755 RVA: 0x00046B44 File Offset: 0x00044D44 private Hashtable GetUMEnabledUsersDatacenter(MailboxDatabase database) { Hashtable hashtable = new Hashtable(); if (database != null) { foreach (ADUser aduser in PartitionDataAggregator.GetUMEnabledUsersInDatabase(database)) { hashtable[aduser.ExchangeGuid] = aduser.OrganizationId; } } return(hashtable); }
protected override void InternalValidate() { if (this.Identity != null) { base.InternalValidate(); this.mailbox = (ADUser)base.GetDataObject <ADUser>(this.Identity, base.DataSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.Identity)), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.Identity))); if (!this.Archive) { MailboxDatabase item = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.mailbox.Database), base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.mailbox.Database.Name)), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.mailbox.Database.Name))); this.databases = new List <MailboxDatabase>(1); this.databases.Add(item); return; } if (this.mailbox.ArchiveDatabase != null) { if (this.mailbox.ArchiveGuid != Guid.Empty) { if (this.mailbox.ArchiveDomain != null) { base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(this.mailbox.ToString())), (ErrorCategory)1003, this.Identity); } } else { base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(this.mailbox.ToString())), ErrorCategory.InvalidArgument, this.Identity); } MailboxDatabase item2 = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.mailbox.ArchiveDatabase), base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.mailbox.ArchiveDatabase.Name)), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.mailbox.ArchiveDatabase.Name))); this.databases = new List <MailboxDatabase>(1); this.databases.Add(item2); return; } base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(this.mailbox.ToString())), ErrorCategory.InvalidArgument, this.Identity); return; } else { if (this.MailboxDatabase != null) { MailboxDatabase item3 = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.MailboxDatabase, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.MailboxDatabase.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.MailboxDatabase.ToString()))); this.databases = new List <MailboxDatabase>(1); this.databases.Add(item3); return; } if (this.Server != null) { Server server = (Server)base.GetDataObject <Server>(this.Server, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.Server)), new LocalizedString?(Strings.ErrorServerNotUnique(this.Server))); this.databases = new List <MailboxDatabase>(server.GetMailboxDatabases()); } return; } }
private MailboxDatabase GetMailboxDatabase(DatabaseIdParameter databaseId) { if (databaseId == null) { throw new ArgumentNullException("databaseId"); } MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseId, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseId.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseId.ToString()))); if (mailboxDatabase == null) { throw new DatabaseNotFoundException(databaseId.ToString()); } return(mailboxDatabase); }
private static bool FindServerInSameDatabaseButNotCurrentServer(DataRow inputRow, DataRow row, DataObjectStore store) { if (DBNull.Value.Equals(row["DatabaseAvailabilityGroup"])) { return(false); } MailboxDatabase mailboxDatabase = (MailboxDatabase)store.GetDataObject("MailboxDatabase"); string b = (string)row["DatabaseAvailabilityGroup"]; string text = (string)row["Name"]; ADObjectId currentServerId = (ADObjectId)row["Identity"]; string value = (string)inputRow["CurrentServer"]; return(mailboxDatabase.MasterServerOrAvailabilityGroup.Name == b && mailboxDatabase.Servers.Any((ADObjectId serverId) => serverId.Equals(currentServerId)) && !text.Equals(value, StringComparison.OrdinalIgnoreCase)); }
private string GetMonitoringMailboxDisplayName(MailboxDatabase mdb, Server activeServer) { foreach (DatabaseCopy databaseCopy in mdb.DatabaseCopies) { if (activeServer.Id.Equals(databaseCopy.HostServer)) { return(string.Format(CultureInfo.InvariantCulture, "HealthMailbox-{0}-{1}", new object[] { databaseCopy.HostServerName, databaseCopy.DatabaseName.Replace(" ", "-") })); } } return(null); }
// Token: 0x06000AC1 RID: 2753 RVA: 0x000469EC File Offset: 0x00044BEC private Hashtable GetUMEnabledUsersFromAD() { MailboxDatabase database = this.rootOrgConfigSession.Read <MailboxDatabase>(new ADObjectId(base.DatabaseInfo.Guid)); if (VariantConfiguration.InvariantNoFlightingSnapshot.MailboxAssistants.MwiAssistantGetUMEnabledUsersFromDatacenter.Enabled) { ExTraceGlobals.MWITracer.TraceDebug((long)this.GetHashCode(), "GetUMEnabledUsersFromAD() - Microsoft Hosted Topology."); return(this.GetUMEnabledUsersDatacenter(database)); } if (Datacenter.IsPartnerHostedOnly(true)) { ExTraceGlobals.MWITracer.TraceDebug((long)this.GetHashCode(), "GetUMEnabledUsersFromAD() - Partner Hosted Topology."); return(new Hashtable()); } ExTraceGlobals.MWITracer.TraceDebug((long)this.GetHashCode(), "GetUMEnabledUsersFromAD() - Enterprise Topology."); return(this.GetUMEnabledUsersEnterprise(database)); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (this.TargetMailbox != null) { ADUser aduser = 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), false); this.targetUserId = aduser.Id; } if (this.SourceDatabase != null) { this.SourceDatabase.AllowLegacy = true; MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.SourceDatabase, base.ConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.SourceDatabase.ToString()))); this.sourceDatabaseId = mailboxDatabase.Id; } TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); base.InternalProcessRecord(); if (this.recoverArchive && this.DataObject.ArchiveDatabase != null) { MailboxDatabase database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.DataObject.ArchiveDatabase), base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.DataObject.ArchiveDatabase.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.DataObject.ArchiveDatabase.ToString()))); using (MapiAdministrationSession adminSession = MapiTaskHelper.GetAdminSession(RecipientTaskHelper.GetActiveManagerInstance(), this.DataObject.ArchiveDatabase.ObjectGuid)) { ConnectMailbox.UpdateSDAndRefreshMailbox(adminSession, this.DataObject, database, this.DataObject.ArchiveGuid, null, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } } TaskLogger.LogExit(); }
public static void GetObjectPostAction(DataRow inputRow, DataTable dataTable, DataObjectStore store) { DataRow dataRow = dataTable.Rows[0]; if (!DBNull.Value.Equals(dataRow["IssueWarningQuota"])) { Unlimited <ByteQuantifiedSize> unlimited = (Unlimited <ByteQuantifiedSize>)dataRow["IssueWarningQuota"]; dataRow["IssueWarningQuota"] = MailboxPropertiesHelper.UnlimitedByteQuantifiedSizeToString(unlimited); } if (!DBNull.Value.Equals(dataRow["ProhibitSendQuota"])) { Unlimited <ByteQuantifiedSize> unlimited2 = (Unlimited <ByteQuantifiedSize>)dataRow["ProhibitSendQuota"]; dataRow["ProhibitSendQuota"] = MailboxPropertiesHelper.UnlimitedByteQuantifiedSizeToString(unlimited2); } if (!DBNull.Value.Equals(dataRow["ProhibitSendReceiveQuota"])) { Unlimited <ByteQuantifiedSize> unlimited3 = (Unlimited <ByteQuantifiedSize>)dataRow["ProhibitSendReceiveQuota"]; dataRow["ProhibitSendReceiveQuota"] = MailboxPropertiesHelper.UnlimitedByteQuantifiedSizeToString(unlimited3); } dataRow["MountStatus"] = ((DDIHelper.IsEmptyValue(dataRow["Mounted"]) || !(bool)dataRow["Mounted"]) ? Strings.StatusDismounted : Strings.StatusMounted); if (!DBNull.Value.Equals(dataRow["DeletedItemRetention"])) { dataRow["DeletedItemRetention"] = ((EnhancedTimeSpan)dataRow["DeletedItemRetention"]).Days.ToString(); } if (!DBNull.Value.Equals(dataRow["MailboxRetention"])) { dataRow["MailboxRetention"] = ((EnhancedTimeSpan)dataRow["MailboxRetention"]).Days.ToString(); } MailboxDatabase mailboxDatabase = store.GetDataObject("MailboxDatabase") as MailboxDatabase; if (mailboxDatabase != null) { dataRow["Servers"] = mailboxDatabase.Servers; } if (!DBNull.Value.Equals(dataRow["MaintenanceSchedule"])) { Schedule schedule = (Schedule)dataRow["MaintenanceSchedule"]; dataRow["MaintenanceSchedule"] = new ScheduleBuilder(schedule).GetEntireState(); } if (!DBNull.Value.Equals(dataRow["QuotaNotificationSchedule"])) { Schedule schedule2 = (Schedule)dataRow["QuotaNotificationSchedule"]; dataRow["QuotaNotificationSchedule"] = new ScheduleBuilder(schedule2).GetEntireState(); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); string mailboxAddress = this.Identity.ToString(); ADUser dataObject = this.DataObject; ELCTaskHelper.VerifyIsInScopes(dataObject, base.ScopeSet, new Task.TaskErrorLoggingDelegate(base.WriteError)); if (dataObject.ExchangeGuid != Guid.Empty && dataObject.RecipientType != RecipientType.MailUser && dataObject.Database != null) { MailboxDatabase mailboxDatabase = base.GlobalConfigSession.Read <MailboxDatabase>(dataObject.Database); if (mailboxDatabase == null) { base.WriteError(new ArgumentException(Strings.ElcMdbNotFound(mailboxAddress), "Mailbox"), ErrorCategory.InvalidArgument, null); } this.InternalProcessOneMailbox(dataObject.ExchangeGuid, mailboxDatabase.Guid); } if (dataObject.ArchiveState == ArchiveState.Local) { ADObjectId entryId = dataObject.ArchiveDatabase ?? dataObject.Database; MailboxDatabase mailboxDatabase2 = base.GlobalConfigSession.Read <MailboxDatabase>(entryId); if (mailboxDatabase2 == null) { base.WriteError(new ArgumentException(Strings.ElcMdbNotFound(mailboxAddress), "Archive Mailbox"), ErrorCategory.InvalidArgument, null); } if (StoreRetentionPolicyTagHelper.HasOnPremArchiveMailbox(dataObject)) { try { StoreRetentionPolicyTagHelper.SyncOptionalTagsFromPrimaryToArchive(dataObject); } catch (ElcUserConfigurationException) { this.WriteWarning(Strings.WarningArchiveMailboxNotReachable(mailboxAddress)); } } this.InternalProcessOneMailbox(dataObject.ArchiveGuid, mailboxDatabase2.Guid); } if (!this.processed) { this.WriteWarning(Strings.ElcNoLocalMbxOrArchive(mailboxAddress)); } TaskLogger.LogExit(); }
protected ADSystemMailbox GetSystemMailboxFromMdb(MailboxDatabase mdb) { ADSystemMailbox adsystemMailbox = null; GeneralMailboxIdParameter id = GeneralMailboxIdParameter.Parse(string.Format(CultureInfo.InvariantCulture, "SystemMailbox{{{0}}}", new object[] { mdb.Guid.ToString() })); IEnumerable <ADSystemMailbox> adDataObjects = this.Task.GetAdDataObjects <ADSystemMailbox>(id, this.Task.TenantGlobalCatalogSession); using (IEnumerator <ADSystemMailbox> enumerator = adDataObjects.GetEnumerator()) { adsystemMailbox = (enumerator.MoveNext() ? enumerator.Current : null); } if (adsystemMailbox == null) { this.WriteErrorAndMonitoringEvent(new RecipientTaskException(Strings.TestMailflowNoSystemMailbox), ErrorCategory.InvalidOperation, 1005); } return(adsystemMailbox); }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); base.InternalBeginProcessing(); Mailbox mailbox = (Mailbox)this.GetDynamicParameters(); if (base.Fields.IsModified("Database")) { if (this.Database != null) { MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.Database, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(this.Database.ToString())), ExchangeErrorCategory.Client); mailbox[ADMailboxRecipientSchema.Database] = (ADObjectId)mailboxDatabase.Identity; } else { mailbox[ADMailboxRecipientSchema.Database] = null; } } TaskLogger.LogExit(); }
/// <summary> /// Gets a list of Exchange database names /// </summary> /// <returns></returns> public List<MailboxDatabase> Get_ExchangeDatabases() { PowerShell powershell = null; try { // DEBUG logger.Debug("Retrieving a list of Exchange databases..."); // Start clock Stopwatch stopwatch = Stopwatch.StartNew(); // Run commands powershell = PowerShell.Create(); powershell.Runspace = runspace; // Get Databases PSCommand cmd = new PSCommand(); cmd.AddCommand("Get-MailboxDatabase"); cmd.AddParameter("Status"); cmd.AddParameter("DomainController", this.domainController); powershell.Commands = cmd; // Store what we find in this list so we can return the names of the databases List<MailboxDatabase> databases = new List<MailboxDatabase>(); // When retrieved DateTime when = DateTime.Now; // Now read the returned values Collection<PSObject> foundDatabases = powershell.Invoke(); if (foundDatabases != null) { foreach (PSObject o in foundDatabases) { MailboxDatabase db = new MailboxDatabase(); db.Identity = o.Members["Identity"].Value.ToString(); // DEBUG logger.Debug("Found database " + db.Identity); db.LogFolderPath = o.Members["LogFolderPath"].Value.ToString(); db.EDBFilePath = o.Members["EdbFilePath"].Value.ToString(); db.IsMailboxDatabase = bool.Parse(o.Members["IsMailboxDatabase"].Value.ToString()); db.IsPublicFolderDatabase = bool.Parse(o.Members["IsPublicFolderDatabase"].Value.ToString()); if (o.Members["Server"].Value != null) db.Server = o.Members["Server"].Value.ToString(); if (o.Members["DatabaseSize"].Value != null) { db.DatabaseSize = o.Members["DatabaseSize"].Value.ToString(); // DEBUG logger.Debug("Size of the database is " + o.Members["DatabaseSize"].Value.ToString()); logger.Debug("Size of the database after formatted is " + db.DatabaseSize.ToString()); } db.WhenRetrieved = when; databases.Add(db); } } // Log the powershell commands LogPowershellCommands(ref powershell); // Find all the error if (powershell.HadErrors) { // Log all errors detected foreach (ErrorRecord err in powershell.Streams.Error) { string exception = err.Exception.ToString(); // Log the exception logger.Fatal("Error retrieving mailbox database sizes: " + exception); throw err.Exception; } } // Stop the clock stopwatch.Stop(); // Log the success logger.Info("Successfully retrieved a list of databases from Exchange."); // Return values return databases; } catch (Exception ex) { throw; } finally { if (powershell != null) powershell.Dispose(); } }