protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.Mailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder); if (!this.FilePath.IsUnc) { base.WriteError(new NonUNCFilePathPermanentException(this.FilePath.PathName), ErrorCategory.InvalidArgument, this.FilePath); } bool flag = !OrganizationId.ForestWideOrgId.Equals(base.ExecutingUserOrganizationId); bool flag2 = this.RemoteHostName != null; if (flag && !flag2) { base.WriteError(new RemoteMailboxImportNeedRemoteProxyException(), ErrorCategory.InvalidArgument, this); } this.user = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.Mailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); bool wildcardedSearch = false; if (!string.IsNullOrEmpty(base.Name)) { base.ValidateName(); base.RequestName = base.Name; } else { wildcardedSearch = true; base.RequestName = "MailboxImport"; } if (base.ParameterSetName.Equals("MailboxImportRequest")) { this.DisallowImportForPublicFolderMailbox(); if (this.user.RecipientType != RecipientType.UserMailbox) { base.WriteError(new InvalidRecipientTypePermanentException(this.user.ToString(), this.user.RecipientType.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } if (this.IsArchive && (this.user.ArchiveGuid == Guid.Empty || this.user.ArchiveDatabase == null)) { base.WriteError(new MailboxLacksArchivePermanentException(this.user.ToString()), ErrorCategory.InvalidArgument, this.IsArchive); } if (!this.IsArchive && this.user.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.user.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } base.RescopeToOrgId(this.user.OrganizationId); ADObjectId mdbId = null; ADObjectId mdbServerSite = null; this.LocateAndChooseMdb(null, this.IsArchive ? this.user.ArchiveDatabase : this.user.Database, null, this.Mailbox, this.Mailbox, out mdbId, out mdbServerSite); base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull); } base.RequestName = this.CheckRequestNameAvailability(base.RequestName, this.user.Id, true, MRSRequestType.MailboxImport, this.Mailbox, wildcardedSearch); base.InternalValidate(); } finally { TaskLogger.LogExit(); } }
private void RetrieveSourceMailboxInformation() { this.mailbox = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.Mailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); if (this.mailbox.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.mailbox.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } this.sourceDatabaseInformation = new DatabaseInformation?(MapiUtils.FindServerForMdb(this.mailbox.Database.ObjectGuid, null, null, FindServerFlags.None)); }
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(); }
private void RetrieveTargetContainerAndMailboxInformation() { this.targetContainer = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetContainer, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); if (this.targetContainer.UnifiedMailbox != null) { base.WriteError(new MailboxRelocationJoinTargetNotContainerOwnerException(this.targetContainer.ToString()), ErrorCategory.InvalidArgument, this.TargetContainer); } if (this.targetContainer.MailboxContainerGuid == null) { base.WriteError(new MailboxRelocationJoinTargetNotContainerException(this.targetContainer.ToString()), ErrorCategory.InvalidArgument, this.TargetContainer); } if (this.targetContainer.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.targetContainer.ToString()), ErrorCategory.InvalidArgument, this.TargetContainer); } this.targetDatabaseInformation = new DatabaseInformation?(MapiUtils.FindServerForMdb(this.targetContainer.Database.ObjectGuid, null, null, FindServerFlags.None)); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.HasErrors) { return; } if (this.InternalMailbox != null) { ADUser aduser = RequestTaskHelper.ResolveADUser(this.RecipSession, this.GCSession, base.ServerSettings, this.InternalMailbox, base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); this.userId = aduser.Id; } if (this.RequestQueue != null) { MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(this.RequestQueue, this.ConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.RequestQueue.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.RequestQueue.ToString()))); this.queueId = mailboxDatabase.Id; } if (this.Organization != null && this.AccountPartition != null) { base.WriteError(new TaskException(Strings.ErrorIncompatibleParameters("Organization", "AccountPartition")), ErrorCategory.InvalidArgument, this.Identity); } TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder); if (this.SourceMailbox != null) { this.sourceUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.SourceMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); if (this.SourceIsArchive && (this.sourceUser.ArchiveGuid == Guid.Empty || this.sourceUser.ArchiveDatabase == null)) { base.WriteError(new MailboxLacksArchivePermanentException(this.sourceUser.ToString()), ErrorCategory.InvalidArgument, this.SourceIsArchive); } if (!this.SourceIsArchive && this.sourceUser.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.sourceUser.ToString()), ErrorCategory.InvalidArgument, this.SourceMailbox); } } else { this.sourceUser = null; } if (this.TargetMailbox != null) { this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); if (this.TargetIsArchive && (this.targetUser.ArchiveGuid == Guid.Empty || this.targetUser.ArchiveDatabase == null)) { base.WriteError(new MailboxLacksArchivePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetIsArchive); } if (!this.TargetIsArchive && this.targetUser.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } } else { this.targetUser = null; } this.DisallowMergeRequestForPublicFolderMailbox(); bool wildcardedSearch = false; if (!string.IsNullOrEmpty(base.Name)) { base.ValidateName(); base.RequestName = base.Name; } else { wildcardedSearch = true; base.RequestName = "Merge"; } AuthenticationMethod authenticationMethod = this.AuthenticationMethod; switch (authenticationMethod) { case AuthenticationMethod.Basic: case AuthenticationMethod.Ntlm: goto IL_282; case AuthenticationMethod.Digest: break; default: if (authenticationMethod == AuthenticationMethod.LiveIdBasic) { goto IL_282; } break; } base.WriteError(new UnsupportedAuthMethodPermanentException(this.AuthenticationMethod.ToString()), ErrorCategory.InvalidArgument, this.AuthenticationMethod); IL_282: if (base.ParameterSetName.Equals("MigrationLocalMerge")) { if (!object.Equals(this.sourceUser.OrganizationId, this.targetUser.OrganizationId)) { base.WriteError(new UsersNotInSameOrganizationPermanentException(this.sourceUser.ToString(), this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } base.RescopeToOrgId(this.sourceUser.OrganizationId); base.ValidateLegacyDNMatch(this.sourceUser.LegacyExchangeDN, this.targetUser, this.TargetMailbox); ADObjectId mdbId = null; ADObjectId mdbServerSite = null; RequestFlags requestFlags = this.LocateAndChooseMdb(this.SourceIsArchive ? this.sourceUser.ArchiveDatabase : this.sourceUser.Database, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, this.SourceMailbox, this.TargetMailbox, this.TargetMailbox, out mdbId, out mdbServerSite); base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.Flags = (RequestFlags.IntraOrg | requestFlags); } else { base.RescopeToOrgId(this.targetUser.OrganizationId); ADObjectId mdbId2 = null; ADObjectId mdbServerSite2 = null; this.LocateAndChooseMdb(null, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, null, this.TargetMailbox, this.TargetMailbox, out mdbId2, out mdbServerSite2); base.MdbId = mdbId2; base.MdbServerSite = mdbServerSite2; base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull); } ADUser aduser; if ((base.Flags & RequestFlags.Pull) == RequestFlags.Pull) { aduser = this.targetUser; } else { aduser = this.sourceUser; } base.RequestName = this.CheckRequestNameAvailability(base.RequestName, aduser.Id, true, MRSRequestType.Merge, this.TargetMailbox, wildcardedSearch); if (base.IsFieldSet("IncrementalSyncInterval") && base.IsFieldSet("SuspendWhenReadyToComplete") && this.SuspendWhenReadyToComplete) { base.WriteError(new SuspendWhenReadyToCompleteCannotBeSetWithIncrementalSyncIntervalException(), ErrorCategory.InvalidArgument, this.SuspendWhenReadyToComplete); } DateTime utcNow = DateTime.UtcNow; if (base.IsFieldSet("StartAfter")) { RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), utcNow); } if (base.IsFieldSet("IncrementalSyncInterval")) { RequestTaskHelper.ValidateIncrementalSyncInterval(this.IncrementalSyncInterval, new Task.TaskErrorLoggingDelegate(base.WriteError)); } base.InternalValidate(); } finally { TaskLogger.LogExit(); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { if (this.Mailbox == null) { ADObjectId adObjectId; if (!base.TryGetExecutingUserId(out adObjectId)) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } this.Mailbox = new MailboxIdParameter(adObjectId); } this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.Mailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); base.RecipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(base.RecipSession, this.targetUser.OrganizationId, true); base.CurrentOrganizationId = this.targetUser.OrganizationId; base.RJProvider.IndexProvider.RecipientSession = base.RecipSession; if (this.targetUser.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.Mailbox); } if (this.AggregatedMailboxGuid != Guid.Empty) { MultiValuedProperty <Guid> multiValuedProperty = this.targetUser.AggregatedMailboxGuids ?? new MultiValuedProperty <Guid>(); if (!multiValuedProperty.Contains(this.AggregatedMailboxGuid)) { base.WriteError(new AggregatedMailboxNotFoundPermanentException(this.AggregatedMailboxGuid, this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.AggregatedMailboxGuid); } } this.DataObject.DomainControllerToUpdate = this.targetUser.OriginatingServer; bool wildcardedSearch = false; if (!string.IsNullOrEmpty(this.Name)) { base.ValidateName(); base.RequestName = this.Name; } else if (this.Olc) { base.RequestName = "OlcSync"; } else { wildcardedSearch = true; base.RequestName = "Sync"; } base.RescopeToOrgId(this.targetUser.OrganizationId); ADObjectId mdbId = null; ADObjectId mdbServerSite = null; RequestFlags requestFlags = this.LocateAndChooseMdb(null, this.targetUser.Database, null, this.Mailbox, this.Mailbox, out mdbId, out mdbServerSite); base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.Flags = (RequestFlags.CrossOrg | requestFlags); base.RequestName = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.Sync, this.Mailbox, wildcardedSearch); if (this.Imap == true) { this.syncProtocol = SyncProtocol.Imap; } else if (this.Eas == true) { this.syncProtocol = SyncProtocol.Eas; } else if (this.Pop == true) { this.syncProtocol = SyncProtocol.Pop; } else if (this.Olc == true) { this.syncProtocol = SyncProtocol.Olc; } else { base.WriteError(new SyncProtocolNotSpecifiedPermanentException(), ErrorCategory.InvalidArgument, this.syncProtocol); } if (base.IsFieldSet("IncrementalSyncInterval")) { RequestTaskHelper.ValidateIncrementalSyncInterval(this.IncrementalSyncInterval, new Task.TaskErrorLoggingDelegate(base.WriteError)); } DateTime utcNow = DateTime.UtcNow; if (base.IsFieldSet("StartAfter")) { RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), utcNow); } if (base.IsFieldSet("StartAfter") && base.IsFieldSet("CompleteAfter")) { RequestTaskHelper.ValidateStartAfterComesBeforeCompleteAfter(new DateTime?(this.StartAfter.ToUniversalTime()), new DateTime?(this.CompleteAfter.ToUniversalTime()), new Task.TaskErrorLoggingDelegate(base.WriteError)); } base.InternalValidate(); } finally { TaskLogger.LogExit(); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { if (base.ParameterSetName.Equals("Identity")) { TIdentity identity = this.Identity; if (identity.OrganizationId != null) { IDirectorySession dataSession = this.recipSession; TIdentity identity2 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(dataSession, identity2.OrganizationId)) { IDirectorySession session = this.recipSession; TIdentity identity3 = this.Identity; this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(session, identity3.OrganizationId, true); } IDirectorySession dataSession2 = this.currentOrgConfigSession; TIdentity identity4 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(dataSession2, identity4.OrganizationId)) { IDirectorySession session2 = this.currentOrgConfigSession; TIdentity identity5 = this.Identity; this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(session2, identity5.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } ADUser aduser = null; TIdentity identity6 = this.Identity; if (!string.IsNullOrEmpty(identity6.MailboxName)) { IRecipientSession dataSession3 = this.recipSession; IRecipientSession globalCatalogSession = this.gcSession; ADServerSettings serverSettings = base.ServerSettings; TIdentity identity7 = this.Identity; aduser = RequestTaskHelper.ResolveADUser(dataSession3, globalCatalogSession, serverSettings, new MailboxOrMailUserIdParameter(identity7.MailboxName), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); if (aduser != null) { TIdentity identity8 = this.Identity; identity8.MailboxId = aduser.Id; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.recipSession, aduser)) { this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.recipSession, aduser.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.currentOrgConfigSession, aduser)) { this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.currentOrgConfigSession, aduser.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } } TIdentity identity9 = this.Identity; if (!string.IsNullOrEmpty(identity9.OrganizationName)) { IConfigurationSession configurationSession = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId); TIdentity identity10 = this.Identity; IIdentityParameter id = new OrganizationIdParameter(identity10.OrganizationName); IConfigDataProvider session3 = configurationSession; ObjectId rootID = null; TIdentity identity11 = this.Identity; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorOrganizationNotFound(identity11.OrganizationName)); TIdentity identity12 = this.Identity; ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(id, session3, rootID, notFoundError, new LocalizedString?(Strings.ErrorOrganizationNotUnique(identity12.OrganizationName))); if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.recipSession, adorganizationalUnit)) { this.recipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.recipSession, adorganizationalUnit.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.currentOrgConfigSession, adorganizationalUnit)) { this.currentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.currentOrgConfigSession, adorganizationalUnit.OrganizationId, true); this.rjProvider.IndexProvider.ConfigSession = this.currentOrgConfigSession; } } TIdentity identity13 = this.Identity; identity13.SetDefaultIndex(this.DefaultRequestIndexId); IRequestIndexEntry entry = this.GetEntry(); RequestJobObjectId requestJobId = entry.GetRequestJobId(); if (entry.TargetUserId != null) { if (aduser != null && aduser.Id.Equals(entry.TargetUserId)) { requestJobId.TargetUser = aduser; } else { requestJobId.TargetUser = RequestTaskHelper.ResolveADUser(this.recipSession, this.gcSession, base.ServerSettings, new MailboxOrMailUserIdParameter(entry.TargetUserId), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); } } if (entry.SourceUserId != null) { if (aduser != null && aduser.Id.Equals(entry.SourceUserId)) { requestJobId.SourceUser = aduser; } else { requestJobId.SourceUser = RequestTaskHelper.ResolveADUser(this.recipSession, this.gcSession, base.ServerSettings, new MailboxOrMailUserIdParameter(entry.SourceUserId), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); } } this.CheckIndexEntry(entry); TDataObject tdataObject = (TDataObject)((object)this.rjProvider.Read <TDataObject>(requestJobId)); if (tdataObject == null || tdataObject.Status == RequestStatus.None) { TIdentity identity14 = this.Identity; base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorCouldNotFindRequest(identity14.ToString())), ErrorCategory.InvalidArgument, this.Identity); } else if (tdataObject.RequestType != this.RequestType) { base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorNotEnoughInformationToFindRequest), ErrorCategory.InvalidArgument, this.Identity); } else { this.WriteResult(tdataObject); } } else if (base.ParameterSetName.Equals("MigrationRequestQueue")) { if (this.RequestQueue != null) { 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.fromMdb = mailboxDatabase.Id; } this.rjProvider.AllowInvalid = true; base.InternalProcessRecord(); } } finally { TaskLogger.LogExit(); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { if (this.Identity != null) { TIdentity identity = this.Identity; if (identity.OrganizationId != null) { IDirectorySession recipSession = this.RecipSession; TIdentity identity2 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(recipSession, identity2.OrganizationId)) { IDirectorySession recipSession2 = this.RecipSession; TIdentity identity3 = this.Identity; this.RecipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(recipSession2, identity3.OrganizationId, true); } IDirectorySession currentOrgConfigSession = this.CurrentOrgConfigSession; TIdentity identity4 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(currentOrgConfigSession, identity4.OrganizationId)) { IDirectorySession currentOrgConfigSession2 = this.CurrentOrgConfigSession; TIdentity identity5 = this.Identity; this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(currentOrgConfigSession2, identity5.OrganizationId, true); this.indexProvider.ConfigSession = this.CurrentOrgConfigSession; } } TIdentity identity6 = this.Identity; if (!string.IsNullOrEmpty(identity6.MailboxName)) { IRecipientSession recipSession3 = this.RecipSession; IRecipientSession gcsession = this.GCSession; ADServerSettings serverSettings = base.ServerSettings; TIdentity identity7 = this.Identity; ADUser aduser = RequestTaskHelper.ResolveADUser(recipSession3, gcsession, serverSettings, new MailboxOrMailUserIdParameter(identity7.MailboxName), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), false); if (aduser != null) { TIdentity identity8 = this.Identity; identity8.MailboxId = aduser.Id; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.RecipSession, aduser)) { this.RecipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.RecipSession, aduser.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.CurrentOrgConfigSession, aduser)) { this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.CurrentOrgConfigSession, aduser.OrganizationId, true); this.indexProvider.ConfigSession = this.CurrentOrgConfigSession; } } } TIdentity identity9 = this.Identity; if (!string.IsNullOrEmpty(identity9.OrganizationName)) { IConfigurationSession configurationSession = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId); TIdentity identity10 = this.Identity; IIdentityParameter id = new OrganizationIdParameter(identity10.OrganizationName); IConfigDataProvider session = configurationSession; ObjectId rootID = null; TIdentity identity11 = this.Identity; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorOrganizationNotFound(identity11.OrganizationName)); TIdentity identity12 = this.Identity; ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorOrganizationNotUnique(identity12.OrganizationName))); if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.RecipSession, adorganizationalUnit)) { this.RecipSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.RecipSession, adorganizationalUnit.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.CurrentOrgConfigSession, adorganizationalUnit)) { this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.CurrentOrgConfigSession, adorganizationalUnit.OrganizationId, true); this.indexProvider.ConfigSession = this.CurrentOrgConfigSession; } } TIdentity identity13 = this.Identity; identity13.SetDefaultIndex(this.DefaultRequestIndexId); } base.InternalProcessRecord(); } finally { TaskLogger.LogExit(); } }
protected virtual ADUser ResolveADUser(ADObjectId userId) { return(RequestTaskHelper.ResolveADUser(this.WriteableSession, this.GCSession, base.ServerSettings, new MailboxOrMailUserIdParameter(userId), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true)); }
protected override IConfigurable PrepareDataObject() { TIdentity identity = this.Identity; if (identity.OrganizationId != null) { IDirectorySession writeableSession = this.WriteableSession; TIdentity identity2 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(writeableSession, identity2.OrganizationId)) { IDirectorySession writeableSession2 = this.WriteableSession; TIdentity identity3 = this.Identity; this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(writeableSession2, identity3.OrganizationId, true); } IDirectorySession currentOrgConfigSession = this.CurrentOrgConfigSession; TIdentity identity4 = this.Identity; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(currentOrgConfigSession, identity4.OrganizationId)) { IDirectorySession currentOrgConfigSession2 = this.CurrentOrgConfigSession; TIdentity identity5 = this.Identity; this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(currentOrgConfigSession2, identity5.OrganizationId, true); this.RJProvider.IndexProvider.ConfigSession = this.CurrentOrgConfigSession; } } TIdentity identity6 = this.Identity; if (!string.IsNullOrEmpty(identity6.MailboxName)) { IRecipientSession writeableSession3 = this.WriteableSession; IRecipientSession gcsession = this.GCSession; ADServerSettings serverSettings = base.ServerSettings; TIdentity identity7 = this.Identity; ADUser aduser = RequestTaskHelper.ResolveADUser(writeableSession3, gcsession, serverSettings, new UserIdParameter(identity7.MailboxName), base.OptionalIdentityData, this.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); if (aduser != null) { TIdentity identity8 = this.Identity; identity8.MailboxId = aduser.Id; if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.WriteableSession, aduser)) { this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.WriteableSession, aduser.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.CurrentOrgConfigSession, aduser)) { this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.CurrentOrgConfigSession, aduser.OrganizationId, true); this.RJProvider.IndexProvider.ConfigSession = this.CurrentOrgConfigSession; } } } TIdentity identity9 = this.Identity; if (!string.IsNullOrEmpty(identity9.OrganizationName)) { IConfigurationSession configurationSession = RequestTaskHelper.CreateOrganizationFindingSession(base.CurrentOrganizationId, base.ExecutingUserOrganizationId); TIdentity identity10 = this.Identity; IIdentityParameter id = new OrganizationIdParameter(identity10.OrganizationName); IConfigDataProvider session = configurationSession; ObjectId rootID = null; TIdentity identity11 = this.Identity; LocalizedString? notFoundError = new LocalizedString?(Strings.ErrorOrganizationNotFound(identity11.OrganizationName)); TIdentity identity12 = this.Identity; ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorOrganizationNotUnique(identity12.OrganizationName))); if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.WriteableSession, adorganizationalUnit)) { this.WriteableSession = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(this.WriteableSession, adorganizationalUnit.OrganizationId, true); } if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(this.CurrentOrgConfigSession, adorganizationalUnit)) { this.CurrentOrgConfigSession = (ITenantConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(this.CurrentOrgConfigSession, adorganizationalUnit.OrganizationId, true); this.RJProvider.IndexProvider.ConfigSession = this.CurrentOrgConfigSession; } } TIdentity identity13 = this.Identity; identity13.SetDefaultIndex(this.DefaultRequestIndexId); this.IndexEntry = this.GetEntry(); this.CheckIndexEntry(); if (this.IndexEntry == null) { return(null); } RequestJobObjectId requestJobId = this.IndexEntry.GetRequestJobId(); if (this.IndexEntry.TargetUserId != null) { requestJobId.TargetUser = this.ResolveADUser(this.IndexEntry.TargetUserId); } if (this.IndexEntry.SourceUserId != null) { requestJobId.SourceUser = this.ResolveADUser(this.IndexEntry.SourceUserId); } return((TransactionalRequestJob)this.RJProvider.Read <TransactionalRequestJob>(requestJobId)); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { base.ValidateRootFolders(this.SourceRootFolder, this.TargetRootFolder); bool wildcardedSearch = false; if (!string.IsNullOrEmpty(base.Name)) { base.ValidateName(); base.RequestName = base.Name; } else { wildcardedSearch = true; base.RequestName = "MailboxRestore"; } this.targetUser = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.TargetMailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true); this.CheckForInvalidPublicFolderRestoreParameters(); if (this.targetUser.HasLocalArchive && this.targetUser.RecipientType == RecipientType.MailUser && this.targetUser.Database == null && !this.TargetIsArchive) { base.WriteError(new MissingArchiveParameterForRestorePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (this.targetUser.RecipientType != RecipientType.UserMailbox && (!this.TargetIsArchive || this.targetUser.RecipientType != RecipientType.MailUser)) { base.WriteError(new InvalidRecipientTypePermanentException(this.targetUser.ToString(), this.targetUser.RecipientType.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (this.TargetIsArchive && (this.targetUser.ArchiveGuid == Guid.Empty || this.targetUser.ArchiveDatabase == null)) { base.WriteError(new MailboxLacksArchivePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetIsArchive); } if (!this.TargetIsArchive && this.targetUser.Database == null) { base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } if (base.ParameterSetName.Equals("RemoteMailboxRestore")) { if (!Guid.TryParse(this.SourceStoreMailbox.RawIdentity, out this.sourceMailboxGuid)) { base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("SourceStoreMailbox")), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } if (!base.Fields.IsModified("AllowLegacyDNMismatch") || !this.AllowLegacyDNMismatch) { base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("AllowLegacyDNMismatch")), ErrorCategory.InvalidArgument, this.AllowLegacyDNMismatch); } base.Flags = (RequestFlags.CrossOrg | RequestFlags.Pull); switch (this.RemoteRestoreType) { case RemoteRestoreType.RecoveryDatabase: this.restoreFlags |= MailboxRestoreType.Recovery; this.restoreFlags |= MailboxRestoreType.SoftDeleted; break; case RemoteRestoreType.DisconnectedMailbox: this.restoreFlags |= MailboxRestoreType.SoftDeleted; break; case RemoteRestoreType.SoftDeletedRecipient: this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient; break; default: base.WriteError(new RecipientTaskException(Strings.ErrorParameterValueNotAllowed("RemoteRestoreType")), ErrorCategory.InvalidArgument, this.RemoteRestoreType); break; } } else { base.Flags = (RequestFlags.IntraOrg | RequestFlags.Pull); string fqdn; string serverExchangeLegacyDn; ADObjectId adobjectId; int num; MailboxDatabase mailboxDatabase = base.CheckDatabase <MailboxDatabase>(this.SourceDatabase, NewRequest <MailboxRestoreRequest> .DatabaseSide.Source, this.SourceDatabase, out fqdn, out serverExchangeLegacyDn, out adobjectId, out num); if (mailboxDatabase.Recovery) { this.restoreFlags |= MailboxRestoreType.Recovery; } this.sourceDatabase = mailboxDatabase.Id; this.SourceStoreMailbox.Flags |= 1UL; using (MapiSession mapiSession = new MapiAdministrationSession(serverExchangeLegacyDn, Fqdn.Parse(fqdn))) { using (MailboxStatistics mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())))) { MailboxState?disconnectReason = mailboxStatistics.DisconnectReason; if (mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderPrimary || mailboxStatistics.MailboxType == StoreMailboxType.PublicFolderSecondary) { this.restoreFlags |= MailboxRestoreType.PublicFolderMailbox; } bool flag = false; if (disconnectReason == null && !mailboxDatabase.Recovery) { mapiSession.Administration.SyncMailboxWithDS(mailboxDatabase.Guid, mailboxStatistics.MailboxGuid); using (MailboxStatistics mailboxStatistics2 = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.SourceStoreMailbox, mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(mailboxDatabase), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.SourceStoreMailbox.ToString(), this.SourceDatabase.ToString())))) { disconnectReason = mailboxStatistics2.DisconnectReason; if (disconnectReason == null) { if (this.targetUser.OrganizationId != null && this.targetUser.OrganizationId.OrganizationalUnit != null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled) { IRecipientSession recipientSession = CommonUtils.CreateRecipientSession(mailboxStatistics.ExternalDirectoryOrganizationId, null, null); ADRecipient adrecipient = this.TargetIsArchive ? recipientSession.FindByExchangeGuidIncludingArchive(mailboxStatistics.MailboxGuid) : recipientSession.FindByExchangeGuid(mailboxStatistics.MailboxGuid); flag = (adrecipient != null && adrecipient.RecipientSoftDeletedStatus != 0); } if (!this.IsPublicFolderMailboxRestore && !flag) { base.WriteError(new CannotRestoreConnectedMailboxPermanentException(this.SourceStoreMailbox.ToString()), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } } } } if (flag) { this.restoreFlags |= MailboxRestoreType.SoftDeletedRecipient; } else if (disconnectReason != null) { if (disconnectReason != MailboxState.SoftDeleted) { this.restoreFlags |= MailboxRestoreType.Disabled; } else { this.restoreFlags |= MailboxRestoreType.SoftDeleted; } } this.sourceMailboxGuid = mailboxStatistics.MailboxGuid; this.sourceMailboxDN = mailboxStatistics.LegacyDN; } } if ((this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ArchiveGuid && this.sourceDatabase.Equals(this.targetUser.ArchiveDatabase)) || (!this.TargetIsArchive && this.sourceMailboxGuid == this.targetUser.ExchangeGuid && this.sourceDatabase.Equals(this.targetUser.Database))) { base.WriteError(new CannotRestoreIntoSelfPermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.TargetMailbox); } } if (this.restoreFlags.HasFlag(MailboxRestoreType.PublicFolderMailbox)) { if (this.targetUser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPublicToPrivateMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } } else if (this.targetUser.RecipientTypeDetails == RecipientTypeDetails.PublicFolderMailbox) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotRestoreFromPrivateToPublicMailbox), ErrorCategory.InvalidArgument, this.SourceStoreMailbox); } base.RescopeToOrgId(this.targetUser.OrganizationId); if (base.ParameterSetName.Equals("RemoteMailboxRestore")) { base.PerRecordReportEntries.Add(new ReportEntry(MrsStrings.ReportRequestAllowedMismatch(base.ExecutingUserIdentity))); } else { base.ValidateLegacyDNMatch(this.sourceMailboxDN, this.targetUser, this.TargetMailbox); } ADObjectId mdbId = null; ADObjectId mdbServerSite = null; this.LocateAndChooseMdb(null, this.TargetIsArchive ? this.targetUser.ArchiveDatabase : this.targetUser.Database, null, this.TargetMailbox, this.TargetMailbox, out mdbId, out mdbServerSite); base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.RequestName = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.MailboxRestore, this.TargetMailbox, wildcardedSearch); base.InternalValidate(); } finally { TaskLogger.LogExit(); } }