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); } }
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); } }
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(); } } }
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"); }
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(); }
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(); }
protected void ResolveDatabaseAndServer() { DatabaseIdParameter databaseIdParameter = this.Database; ServerIdParameter serverIdParameter = this.Server ?? new ServerIdParameter(); ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance(); if (this.Identity != null) { bool flag = false; if (this.isRunningLogonStatisticsTask) { TIdentity tidentity = this.Identity; IEnumerable <Database> objects = tidentity.GetObjects <Database>(null, base.GlobalConfigSession); foreach (Database item in objects) { this.databases.Add(item); } if (this.databases.Count > 0) { if (this.databases[0].Server == null) { string name = typeof(Database).Name; TIdentity tidentity2 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name, tidentity2.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, this.Identity); } DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databases[0].Guid); serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn); if (string.IsNullOrEmpty(this.databases[0].ExchangeLegacyDN)) { string name2 = typeof(Database).Name; TIdentity tidentity3 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name2, tidentity3.ToString(), DatabaseSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity); } this.identity = new MailboxId(this.databases[0].ExchangeLegacyDN); flag = true; } } if (!flag) { IIdentityParameter id = this.Identity; IConfigDataProvider session = this.readOnlyRecipientSession; ObjectId rootID = null; TIdentity tidentity4 = this.Identity; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorMailboxNotFound(tidentity4.ToString())); TIdentity tidentity5 = this.Identity; ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorMailboxNotUnique(tidentity5.ToString()))); Guid guid = Guid.Empty; string mailboxExchangeLegacyDn = null; ADObjectId adobjectId = null; if (string.IsNullOrEmpty(adrecipient.LegacyExchangeDN)) { string name3 = typeof(ADRecipient).Name; TIdentity tidentity6 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name3, tidentity6.ToString(), ADRecipientSchema.LegacyExchangeDN.Name)), ErrorCategory.InvalidArgument, this.Identity); } ADUser aduser = adrecipient as ADUser; ADSystemMailbox adsystemMailbox = adrecipient as ADSystemMailbox; ADSystemAttendantMailbox adsystemAttendantMailbox = adrecipient as ADSystemAttendantMailbox; ADPublicDatabase adpublicDatabase = adrecipient as ADPublicDatabase; if (aduser != null) { if (this.isRunningMailboxStatisticsTask && aduser.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox && !this.GetAuditLogMailboxStatistics()) { TIdentity tidentity7 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.RecipientNotFoundException(tidentity7.ToString())), ErrorCategory.InvalidArgument, null); } bool archiveMailboxStatistics = this.GetArchiveMailboxStatistics(); if (aduser.RecipientType == RecipientType.MailUser && !archiveMailboxStatistics) { base.WriteError(new MdbAdminTaskException(Strings.RecipientTypeNotValid(aduser.ToString())), (ErrorCategory)1003, this.Identity); } RecipientIdParameter recipientIdParameter = this.Identity as RecipientIdParameter; if (this.isRunningMailboxStatisticsTask && recipientIdParameter != null && recipientIdParameter.RawMailboxGuidInvolvedInSearch != Guid.Empty && aduser.MailboxLocations != null) { IMailboxLocationInfo mailboxLocation = aduser.MailboxLocations.GetMailboxLocation(recipientIdParameter.RawMailboxGuidInvolvedInSearch); if (mailboxLocation != null) { guid = mailboxLocation.MailboxGuid; adobjectId = mailboxLocation.DatabaseLocation; } } if (guid == Guid.Empty || adobjectId == null) { if (archiveMailboxStatistics) { if (aduser.ArchiveGuid != Guid.Empty) { if (aduser.ArchiveDomain != null) { base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Identity); } else { guid = aduser.ArchiveGuid; adobjectId = (aduser.ArchiveDatabase ?? aduser.Database); } } else { base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Identity); } } else { guid = aduser.ExchangeGuid; adobjectId = aduser.Database; } } mailboxExchangeLegacyDn = aduser.LegacyExchangeDN; } else if (adsystemMailbox != null) { guid = adsystemMailbox.ExchangeGuid; mailboxExchangeLegacyDn = adsystemMailbox.LegacyExchangeDN; adobjectId = adsystemMailbox.Database; } else if (adsystemAttendantMailbox != null) { guid = adsystemAttendantMailbox.Guid; mailboxExchangeLegacyDn = adsystemAttendantMailbox.LegacyExchangeDN; adobjectId = adsystemAttendantMailbox.Database; } else if (adpublicDatabase != null) { mailboxExchangeLegacyDn = adpublicDatabase.LegacyExchangeDN; adobjectId = (ADObjectId)adpublicDatabase.Identity; } if (adobjectId == null) { string name4 = adrecipient.GetType().Name; TIdentity tidentity8 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name4, tidentity8.ToString(), IADMailStorageSchema.Database.Name)), ErrorCategory.InvalidArgument, adrecipient); } databaseIdParameter = new DatabaseIdParameter(adobjectId); if (this.isRunningLogonStatisticsTask) { this.identity = new MailboxId(mailboxExchangeLegacyDn); } else { this.identity = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid); } } } if (databaseIdParameter != null) { databaseIdParameter.AllowLegacy = true; LocalizedString empty = LocalizedString.Empty; LocalizedString empty2 = LocalizedString.Empty; Database database; if (this.isRunningLogonStatisticsTask) { database = (Database)base.GetDataObject <Database>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString()))); } else { database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseIdParameter.ToString()))); } if (database.Server == null) { base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(this.isRunningLogonStatisticsTask ? typeof(Database).Name : typeof(MailboxDatabase).Name, databaseIdParameter.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database); } this.databases = new List <Database>(new Database[] { database }); if (this.CopyOnServer != null) { serverIdParameter = this.CopyOnServer; } else { DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid); serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn); } } if (this.Server != null) { serverIdParameter = this.Server; this.server = MapiTaskHelper.GetMailboxServer(this.Server, base.GlobalConfigSession, new Task.ErrorLoggerDelegate(base.WriteError)); } else { this.server = (Server)base.GetDataObject <Server>(serverIdParameter, base.GlobalConfigSession, null, new LocalizedString?((this.Identity == null && this.Database == null) ? Strings.ErrorLocalMachineIsNotExchangeServer : Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))); if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer) { if (this.Identity != null) { TIdentity tidentity9 = this.Identity; base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxInNonMailboxServer(tidentity9.ToString())), ErrorCategory.InvalidArgument, this.server); } if (this.Database != null) { base.WriteError(new MdbAdminTaskException(Strings.ErrorDatabaseInNonMailboxServer(this.Database.ToString())), ErrorCategory.InvalidArgument, this.server); } base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server); } } if (string.IsNullOrEmpty(this.server.ExchangeLegacyDN)) { base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, serverIdParameter.ToString(), ServerSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity); } if (this.databases.Count == 0) { if (this.isRunningLogonStatisticsTask) { this.FilterActiveDatabases(activeManagerInstance, this.server.GetDatabases()); return; } this.FilterActiveDatabases(activeManagerInstance, this.server.GetMailboxDatabases()); } }