protected override void ValidateRequest(TransactionalRequestJob requestJob)
        {
            DateTime?timestamp = requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter);
            bool     flag      = RequestTaskHelper.CompareUtcTimeWithLocalTime(timestamp, this.StartAfter);
            bool     flag2     = base.IsFieldSet("StartAfter") && !flag;

            if (flag2)
            {
                this.CheckJobStatusInQueuedForStartAfterSet(requestJob);
            }
            DateTime utcNow = DateTime.UtcNow;

            if (flag2 && this.StartAfter != null)
            {
                RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.Value.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), utcNow);
            }
            if (base.IsFieldSet("IncrementalSyncInterval"))
            {
                if (requestJob.IncrementalSyncInterval == TimeSpan.Zero || requestJob.JobType < MRSJobType.RequestJobE15_AutoResume)
                {
                    base.WriteError(new IncrementalSyncIntervalCannotBeSetOnNonIncrementalRequestsException(), ErrorCategory.InvalidArgument, this.Identity);
                }
                RequestTaskHelper.ValidateIncrementalSyncInterval(this.IncrementalSyncInterval, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.IsFieldSet("StartAfter") && flag)
            {
                this.WriteWarning(Strings.WarningScheduledTimeIsUnchanged("StartAfter"));
            }
            base.ValidateRequest(requestJob);
        }
 protected override void ModifyRequestInternal(TransactionalRequestJob requestJob, StringBuilder changedValuesTracker)
 {
     if (base.IsFieldSet("RemoteSourceMailboxServerLegacyDN"))
     {
         changedValuesTracker.AppendLine(string.Format("RemoteMailboxServerLegacyDN: {0} -> {1}", requestJob.RemoteMailboxServerLegacyDN, this.RemoteSourceMailboxServerLegacyDN));
         requestJob.RemoteMailboxServerLegacyDN = this.RemoteSourceMailboxServerLegacyDN;
     }
     if (base.IsFieldSet("OutlookAnywhereHostName"))
     {
         changedValuesTracker.AppendLine(string.Format("OutlookAnywhereHostName: {0} -> {1}", requestJob.OutlookAnywhereHostName, this.OutlookAnywhereHostName));
         requestJob.OutlookAnywhereHostName = this.OutlookAnywhereHostName;
     }
     if (base.IsFieldSet("RemoteCredential"))
     {
         changedValuesTracker.AppendLine("RemoteCredential: <secure> -> <secure>");
         requestJob.RemoteCredential = RequestTaskHelper.GetNetworkCredential(this.RemoteCredential, requestJob.AuthenticationMethod);
     }
     if (base.IsFieldSet("IsAdministrativeCredential"))
     {
         changedValuesTracker.AppendLine(string.Format("IsAdministrativeCredential: {0} -> {1}", requestJob.IsAdministrativeCredential, this.IsAdministrativeCredential));
         requestJob.IsAdministrativeCredential = new bool?(this.IsAdministrativeCredential);
     }
     if (base.IsFieldSet("StartAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter), this.StartAfter))
     {
         RequestTaskHelper.SetStartAfter(this.StartAfter, requestJob, changedValuesTracker);
     }
     if (base.IsFieldSet("IncrementalSyncInterval"))
     {
         changedValuesTracker.AppendLine(string.Format("IncrementalSyncInterval: {0} -> {1}", requestJob.IncrementalSyncInterval, this.IncrementalSyncInterval));
         requestJob.IncrementalSyncInterval = this.IncrementalSyncInterval;
     }
 }
Example #3
0
 protected override void ModifyRequestInternal(TransactionalRequestJob requestJob, StringBuilder changedValuesTracker)
 {
     if (base.IsFieldSet("RemoteServerName"))
     {
         changedValuesTracker.AppendLine(string.Format("RemoteServerName: {0} -> {1}", requestJob.RemoteHostName, this.RemoteServerName));
         requestJob.RemoteHostName = this.RemoteServerName;
     }
     if (base.IsFieldSet("RemoteServerPort"))
     {
         changedValuesTracker.AppendLine(string.Format("RemoteServerPort: {0} -> {1}", requestJob.RemoteHostPort, this.RemoteServerPort));
         requestJob.RemoteHostPort = this.RemoteServerPort;
     }
     if (base.IsFieldSet("SmtpServerName"))
     {
         changedValuesTracker.AppendLine(string.Format("SmtpServerName: {0} -> {1}", requestJob.SmtpServerName, this.SmtpServerName));
         requestJob.SmtpServerName = this.SmtpServerName;
     }
     if (base.IsFieldSet("SmtpServerPort"))
     {
         changedValuesTracker.AppendLine(string.Format("SmtpServerPort: {0} -> {1}", requestJob.SmtpServerPort, this.SmtpServerPort));
         requestJob.SmtpServerPort = this.SmtpServerPort;
     }
     if (base.IsFieldSet("Authentication"))
     {
         changedValuesTracker.AppendLine(string.Format("Authentication: {0} -> {1}", requestJob.AuthenticationMethod, this.Authentication));
         requestJob.AuthenticationMethod = new AuthenticationMethod?(this.Authentication);
     }
     if (base.IsFieldSet("Security"))
     {
         changedValuesTracker.AppendLine(string.Format("Security: {0} -> {1}", requestJob.SecurityMechanism, this.Security));
         requestJob.SecurityMechanism = this.Security;
     }
     if (base.IsFieldSet("Password"))
     {
         changedValuesTracker.AppendLine("Password: <secure> -> <secure>");
         PSCredential psCred = new PSCredential(requestJob.RemoteCredential.UserName, this.Password);
         requestJob.RemoteCredential = RequestTaskHelper.GetNetworkCredential(psCred, requestJob.AuthenticationMethod);
     }
     if (base.IsFieldSet("IncrementalSyncInterval"))
     {
         changedValuesTracker.AppendLine(string.Format("IncrementalSyncInterval: {0} -> {1}", requestJob.IncrementalSyncInterval, this.IncrementalSyncInterval));
         requestJob.IncrementalSyncInterval = this.IncrementalSyncInterval;
     }
     if (base.IsFieldSet("StartAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter), this.StartAfter))
     {
         RequestTaskHelper.SetStartAfter(this.StartAfter, requestJob, changedValuesTracker);
     }
     if (base.IsFieldSet("CompleteAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter), this.CompleteAfter))
     {
         RequestTaskHelper.SetCompleteAfter(this.CompleteAfter, requestJob, changedValuesTracker);
     }
 }
 protected override void ModifyRequestInternal(TransactionalRequestJob requestJob, StringBuilder changedValuesTracker)
 {
     if (base.IsFieldSet("SuspendWhenReadyToComplete"))
     {
         changedValuesTracker.AppendLine(string.Format("SWRTC: {0} -> {1}", requestJob.SuspendWhenReadyToComplete, this.SuspendWhenReadyToComplete));
         requestJob.SuspendWhenReadyToComplete = this.SuspendWhenReadyToComplete;
     }
     if (base.IsFieldSet("CompleteAfter") && !RequestTaskHelper.CompareUtcTimeWithLocalTime(requestJob.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter), this.CompleteAfter))
     {
         RequestTaskHelper.SetCompleteAfter(this.CompleteAfter, requestJob, changedValuesTracker);
     }
     if (base.IsFieldSet("IncrementalSyncInterval"))
     {
         requestJob.IncrementalSyncInterval = this.IncrementalSyncInterval;
     }
 }
Example #5
0
        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);
        }
Example #6
0
        protected override void ValidateMoveRequest(TransactionalRequestJob moveRequest)
        {
            base.ValidateMoveRequestIsActive(moveRequest);
            base.ValidateMoveRequestProtectionStatus(moveRequest);
            base.ValidateMoveRequestIsSettable(moveRequest);
            if (base.IsFieldSet("SuspendWhenReadyToComplete"))
            {
                if (moveRequest.IsOffline)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorNoOfflineSuspendWhenReadyToComplete(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
                if (RequestJobStateNode.RequestStateIs(moveRequest.StatusDetail, RequestState.Completion))
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotAutoSuspendMoveAlreadyCompleting(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
            }
            if (base.IsFieldSet("RemoteCredential") && moveRequest.RequestStyle == RequestStyle.IntraOrg)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorNoRemoteCredentialSettingForLocalMove(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (base.IsFieldSet("RemoteGlobalCatalog") && moveRequest.RequestStyle == RequestStyle.IntraOrg)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorNoRemoteGlobalCatalogSettingForLocalMove(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (base.IsFieldSet("RemoteHostName") && moveRequest.RequestStyle == RequestStyle.IntraOrg)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorNoRemoteHostNameSettingForLocalMove(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (base.IsFieldSet("BadItemLimit") && this.BadItemLimit < new Unlimited <int>(moveRequest.BadItemsEncountered))
            {
                base.WriteError(new BadItemLimitAlreadyExceededPermanentException(moveRequest.Name, moveRequest.BadItemsEncountered, this.BadItemLimit.ToString()), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (base.IsFieldSet("LargeItemLimit") && moveRequest.AllowLargeItems)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorIncompatibleParameters("AllowLargeItems", "LargeItemLimit")), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (base.IsFieldSet("LargeItemLimit") && this.LargeItemLimit < new Unlimited <int>(moveRequest.LargeItemsEncountered))
            {
                base.WriteError(new LargeItemLimitAlreadyExceededPermanentException(moveRequest.Name, moveRequest.LargeItemsEncountered, this.LargeItemLimit.ToString()), ErrorCategory.InvalidArgument, base.Identity);
            }
            if (this.PreventCompletion)
            {
                if (moveRequest.IsOffline)
                {
                    base.WriteError(new CannotPreventCompletionForOfflineMovePermanentException(), ErrorCategory.InvalidArgument, this.PreventCompletion);
                }
                if (RequestJobStateNode.RequestStateIs(moveRequest.StatusDetail, RequestState.Completion))
                {
                    base.WriteError(new CannotPreventCompletionForCompletingMovePermanentException(), ErrorCategory.InvalidArgument, this.PreventCompletion);
                }
                if (moveRequest.JobType >= MRSJobType.RequestJobE15_AutoResume)
                {
                    base.WriteError(new SuspendWRTCPreventCompletionCannotBeSetOnNewRequestsException(), ErrorCategory.InvalidArgument, this.PreventCompletion);
                }
            }
            DateTime?timestamp  = moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.StartAfter);
            bool     flag       = RequestTaskHelper.CompareUtcTimeWithLocalTime(timestamp, this.StartAfter);
            DateTime?timestamp2 = moveRequest.TimeTracker.GetTimestamp(RequestJobTimestamp.CompleteAfter);
            bool     flag2      = RequestTaskHelper.CompareUtcTimeWithLocalTime(timestamp2, this.CompleteAfter);
            bool     flag3      = base.IsFieldSet("StartAfter") && !flag;
            bool     flag4      = base.IsFieldSet("CompleteAfter") && !flag2;

            if (flag3 || flag4 || base.IsFieldSet("IncrementalSyncInterval"))
            {
                this.CheckMoveStatusWithStartAfterAndCompleteAfterIncrementalSyncInterval(moveRequest);
            }
            if (flag3)
            {
                this.CheckMoveStatusInQueuedForStartAfterSet(moveRequest);
            }
            bool flag5 = base.IsFieldSet("SuspendWhenReadyToComplete") ? this.SuspendWhenReadyToComplete : moveRequest.SuspendWhenReadyToComplete;

            if (flag5 && moveRequest.JobType >= MRSJobType.RequestJobE15_AutoResume)
            {
                base.WriteError(new SuspendWRTCPreventCompletionCannotBeSetOnNewRequestsException(), ErrorCategory.InvalidArgument, this.SuspendWhenReadyToComplete);
            }
            DateTime utcNow = DateTime.UtcNow;

            if (flag3 && this.StartAfter != null)
            {
                RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.Value.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), utcNow);
            }
            if (base.IsFieldSet("IncrementalSyncInterval"))
            {
                RequestTaskHelper.ValidateIncrementalSyncInterval(this.IncrementalSyncInterval, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.IsFieldSet("StartAfter") && flag)
            {
                this.WriteWarning(Strings.WarningScheduledTimeIsUnchanged("StartAfter"));
            }
            if (base.IsFieldSet("CompleteAfter") && flag2)
            {
                this.WriteWarning(Strings.WarningScheduledTimeIsUnchanged("CompleteAfter"));
            }
            if (base.IsFieldSet("TargetDatabase") || base.IsFieldSet("ArchiveTargetDatabase"))
            {
                if (!moveRequest.TargetIsLocal)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotRetargetOutboundMoves(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
                if (!RequestJobStateNode.RequestStateIs(moveRequest.StatusDetail, RequestState.Queued))
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCanRetargetOnlyQueuedMoves(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
                if (base.IsFieldSet("TargetDatabase") && moveRequest.ArchiveOnly)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotRetargetPrimaryForArchiveOnlyMoves(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
                if (base.IsFieldSet("ArchiveTargetDatabase") && moveRequest.PrimaryOnly)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorCannotRetargetArchiveForPrimaryOnlyMoves(base.LocalADUser.ToString())), ErrorCategory.InvalidArgument, base.Identity);
                }
            }
        }