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 ModifyMoveRequest(TransactionalRequestJob moveRequest) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Set-MoveRequest changed values:"); this.mdbGuid = moveRequest.WorkItemQueueMdb.ObjectGuid; if (base.LocalADUser != null) { moveRequest.DomainControllerToUpdate = base.LocalADUser.OriginatingServer; } if (base.IsFieldSet("SuspendWhenReadyToComplete")) { stringBuilder.AppendLine(string.Format("SWRTC: {0} -> {1}", moveRequest.SuspendWhenReadyToComplete, this.SuspendWhenReadyToComplete)); moveRequest.SuspendWhenReadyToComplete = this.SuspendWhenReadyToComplete; } if (base.IsFieldSet("RemoteCredential")) { string remoteCredentialUsername = moveRequest.RemoteCredentialUsername; moveRequest.RemoteCredential = RequestTaskHelper.GetNetworkCredential(this.RemoteCredential, null); stringBuilder.AppendLine(string.Format("RemoteCredential: {0}:<pwd> -> {1}:<pwd>", remoteCredentialUsername, moveRequest.RemoteCredentialUsername)); if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None) { if (moveRequest.Direction == RequestDirection.Pull) { moveRequest.SourceCredential = moveRequest.RemoteCredential; } else { moveRequest.TargetCredential = moveRequest.RemoteCredential; } } } if (base.IsFieldSet("RemoteGlobalCatalog")) { string arg; if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None) { if (moveRequest.Direction == RequestDirection.Pull) { arg = moveRequest.SourceDCName; moveRequest.SourceDCName = this.RemoteGlobalCatalog; } else { arg = moveRequest.TargetDCName; moveRequest.TargetDCName = this.RemoteGlobalCatalog; } } else { arg = moveRequest.RemoteDomainControllerToUpdate; moveRequest.RemoteDomainControllerToUpdate = this.RemoteGlobalCatalog; } stringBuilder.AppendLine(string.Format("RemoteGC: {0} -> {1}", arg, this.RemoteGlobalCatalog)); } if (base.IsFieldSet("RemoteHostName")) { stringBuilder.AppendLine(string.Format("RemoteHostName: {0} -> {1}", moveRequest.RemoteHostName, this.RemoteHostName)); moveRequest.RemoteHostName = this.RemoteHostName; } if (base.IsFieldSet("BadItemLimit")) { stringBuilder.AppendLine(string.Format("BadItemLimit: {0} -> {1}", moveRequest.BadItemLimit, this.BadItemLimit)); moveRequest.BadItemLimit = this.BadItemLimit; } if (base.IsFieldSet("LargeItemLimit")) { stringBuilder.AppendLine(string.Format("LargeItemLimit: {0} -> {1}", moveRequest.LargeItemLimit, this.LargeItemLimit)); moveRequest.LargeItemLimit = this.LargeItemLimit; } if (base.IsFieldSet("Protect")) { stringBuilder.AppendLine(string.Format("Protect: {0} -> {1}", moveRequest.Protect, this.Protect)); moveRequest.Protect = this.Protect; } if (base.IsFieldSet("IgnoreRuleLimitErrors")) { stringBuilder.AppendLine(string.Format("IgnoreRuleLimitErrors: {0} -> {1}", moveRequest.IgnoreRuleLimitErrors, this.IgnoreRuleLimitErrors)); moveRequest.IgnoreRuleLimitErrors = this.IgnoreRuleLimitErrors; } if (base.IsFieldSet("BatchName")) { stringBuilder.AppendLine(string.Format("BatchName: {0} -> {1}", moveRequest.BatchName, this.BatchName)); moveRequest.BatchName = this.BatchName; } if (base.IsFieldSet("Priority")) { stringBuilder.AppendLine(string.Format("Priority: {0} -> {1}", moveRequest.Priority, this.Priority)); moveRequest.Priority = this.Priority; } if (base.IsFieldSet("CompletedRequestAgeLimit")) { stringBuilder.AppendLine(string.Format("CompletedRequestAgeLimit: {0} -> {1}", moveRequest.CompletedRequestAgeLimit, this.CompletedRequestAgeLimit)); moveRequest.CompletedRequestAgeLimit = this.CompletedRequestAgeLimit; } if (base.IsFieldSet("PreventCompletion")) { stringBuilder.AppendLine(string.Format("PreventCompletion: {0} -> {1}", moveRequest.PreventCompletion, this.PreventCompletion)); moveRequest.PreventCompletion = this.PreventCompletion; } if (base.IsFieldSet("StartAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter), this.StartAfter)) { RequestTaskHelper.SetStartAfter(this.StartAfter, moveRequest, stringBuilder); } if (base.IsFieldSet("CompleteAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter), this.CompleteAfter)) { RequestTaskHelper.SetCompleteAfter(this.CompleteAfter, moveRequest, stringBuilder); } if (base.IsFieldSet("IncrementalSyncInterval")) { moveRequest.IncrementalSyncInterval = this.IncrementalSyncInterval; } RequestTaskHelper.ValidateStartAfterCompleteAfterWithSuspendWhenReadyToComplete(moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter), moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter), moveRequest.SuspendWhenReadyToComplete, new Task.TaskErrorLoggingDelegate(base.WriteError)); RequestTaskHelper.ValidateStartAfterComesBeforeCompleteAfter(moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter), moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter), new Task.TaskErrorLoggingDelegate(base.WriteError)); if (base.IsFieldSet("SkipMoving")) { RequestJobInternalFlags requestJobInternalFlags = moveRequest.RequestJobInternalFlags; RequestTaskHelper.SetSkipMoving(this.SkipMoving, moveRequest, new Task.TaskErrorLoggingDelegate(base.WriteError), true); stringBuilder.AppendLine(string.Format("InternalFlags: {0} -> {1}", requestJobInternalFlags, moveRequest.RequestJobInternalFlags)); } if (base.IsFieldSet("InternalFlags")) { RequestJobInternalFlags requestJobInternalFlags2 = moveRequest.RequestJobInternalFlags; RequestTaskHelper.SetInternalFlags(this.InternalFlags, moveRequest, new Task.TaskErrorLoggingDelegate(base.WriteError)); stringBuilder.AppendLine(string.Format("InternalFlags: {0} -> {1}", requestJobInternalFlags2, moveRequest.RequestJobInternalFlags)); } ReportData reportData = new ReportData(moveRequest.ExchangeGuid, moveRequest.ReportVersion); ConnectivityRec connectivityRec = new ConnectivityRec(ServerKind.Cmdlet, VersionInformation.MRS); reportData.Append(MrsStrings.ReportMoveRequestSet(base.ExecutingUserIdentity), connectivityRec); reportData.AppendDebug(stringBuilder.ToString()); if (this.AcceptLargeDataLoss) { reportData.Append(MrsStrings.ReportLargeAmountOfDataLossAccepted2(moveRequest.BadItemLimit.ToString(), moveRequest.LargeItemLimit.ToString(), base.ExecutingUserIdentity)); } if (base.IsFieldSet("TargetDatabase") || base.IsFieldSet("ArchiveTargetDatabase")) { moveRequest.RehomeRequest = true; if (base.IsFieldSet("TargetDatabase")) { moveRequest.TargetDatabase = this.specifiedTargetMDB.Id; } if (base.IsFieldSet("ArchiveTargetDatabase")) { moveRequest.TargetArchiveDatabase = this.specifiedArchiveTargetMDB.Id; } } reportData.Flush(base.MRProvider.SystemMailbox); }