Example #1
0
        protected override IConfigurable PrepareDataObject()
        {
            IConfigurable configurable = base.PrepareDataObject();

            CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, (ADUser)configurable, false, this.ConfirmationMessage, null);
            return(configurable);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, this.DataObject, false, this.ConfirmationMessage, null);
     try
     {
         using (MailboxSession mailboxSession = ContactLinkingBaseCmdLet.OpenMailboxSessionAsAdmin(this.DataObject, this.UserAgent))
         {
             this.PerformanceTracker = new ContactLinkingPerformanceTracker(mailboxSession);
             if (this.OwnsPerformanceTrackerLifeCycle)
             {
                 this.PerformanceTracker.Start();
             }
             this.ContactLinkingOperation(mailboxSession);
         }
     }
     catch (Exception ex)
     {
         TaskLogger.LogError(ex);
         this.WriteError(ex, ErrorCategory.NotSpecified, this.Identity, true);
     }
     finally
     {
         if (this.OwnsPerformanceTrackerLifeCycle && this.PerformanceTracker != null)
         {
             this.PerformanceTracker.Stop();
         }
         this.WritePerformanceData();
         TaskLogger.LogExit();
     }
 }
Example #3
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, base.DataObject, false, this.ConfirmationMessage, null);
     try
     {
         ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(base.DataObject, null);
         using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(exchangePrincipal, CultureInfo.InvariantCulture, "Client=Management;Action=Remove-UserPhoto"))
         {
             new PhotoRemovalPipeline(RemoveUserPhoto.PhotosConfiguration, mailboxSession, (IRecipientSession)base.DataSession, this.tracer).Upload(this.CreateRemovePhotoRequest(exchangePrincipal), Stream.Null);
         }
     }
     catch (WrongServerException ex)
     {
         this.LogFailedToRemovePhotoEvent(ex);
         this.WriteError(new CannotModifyPhotoBecauseMailboxIsInTransitException(ex), ExchangeErrorCategory.ServerTransient, base.DataObject, true);
     }
     catch (Exception e)
     {
         this.LogFailedToRemovePhotoEvent(e);
         throw;
     }
     finally
     {
         this.tracer.Dump(new PhotoRequestLogWriter(RemoveUserPhoto.RequestLog, RemoveUserPhoto.GenerateRequestId()));
     }
     TaskLogger.LogExit();
 }
 protected override void InternalStateReset()
 {
     base.InternalStateReset();
     if (!TaskHelper.GetLocalServerFqdn(new Task.TaskWarningLoggingDelegate(this.WriteWarning)).StartsWith(this.Server, StringComparison.OrdinalIgnoreCase))
     {
         string remoteServerFqdn = this.Server.ToString();
         int    e15MinVersion    = Microsoft.Exchange.Data.Directory.SystemConfiguration.Server.E15MinVersion;
         CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, remoteServerFqdn, e15MinVersion, false, this.ConfirmationMessage, null);
     }
 }
        protected override IConfigurable PrepareDataObject()
        {
            IConfigurable configurable  = base.PrepareDataObject();
            BackEndServer backEndServer = BackEndLocator.GetBackEndServer((ADUser)configurable);

            if (backEndServer != null && backEndServer.Version < Server.E15MinVersion)
            {
                CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, (ADUser)configurable, false, this.ConfirmationMessage, null);
            }
            return(configurable);
        }
Example #6
0
        protected override IConfigurable PrepareDataObject()
        {
            IConfigurable configurable = base.PrepareDataObject();
            CASMailbox    casmailbox   = (CASMailbox)this.GetDynamicParameters();

            if (casmailbox.ActiveSyncDebugLoggingSpecified || this.ResetAutoBlockedDevices)
            {
                ADUser user = (ADUser)configurable;
                CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, user, false, this.ConfirmationMessage, delegate(PropertyBag parameters)
                {
                    if (parameters.Contains("Confirm"))
                    {
                        parameters.Remove("Confirm");
                    }
                });
            }
            return(configurable);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, this.DataObject, false, this.ConfirmationMessage, null);
     try
     {
         ADUser dataObject = this.DataObject;
         if (dataObject == null)
         {
             base.WriteError(new ObjectNotFoundException(Strings.MailboxAssociationMailboxNotFound), ExchangeErrorCategory.Client, this.DataObject);
         }
         else
         {
             IRecipientSession         adSession = (IRecipientSession)base.DataSession;
             MailboxAssociationContext mailboxAssociationContext = new MailboxAssociationContext(adSession, dataObject, "Set-MailboxAssociation", this.Identity, false);
             mailboxAssociationContext.Execute(new Action <MailboxAssociationFromStore, IAssociationAdaptor, ADUser, IExtensibleLogger>(this.UpdateMailboxAssociation));
         }
     }
     catch (StorageTransientException exception)
     {
         base.WriteError(exception, ErrorCategory.ReadError, this.Identity.MailboxId);
     }
     catch (StoragePermanentException exception2)
     {
         base.WriteError(exception2, ErrorCategory.ReadError, this.Identity.MailboxId);
     }
     catch (AssociationNotFoundException exception3)
     {
         base.WriteError(exception3, ErrorCategory.ReadError, this.Identity.MailboxId);
     }
     catch (MailboxNotFoundException exception4)
     {
         base.WriteError(exception4, ErrorCategory.ReadError, this.Identity.MailboxId);
     }
     catch (RpcException exception5)
     {
         base.WriteError(exception5, ErrorCategory.ConnectionError, this.Identity.MailboxId);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Example #8
0
		protected override IConfigurable PrepareDataObject()
		{
			this.DataObject = (ADUser)base.PrepareDataObject();
			if (this.DataObject.IsChanged(MailboxSchema.WindowsLiveID) && this.DataObject.WindowsLiveID != SmtpAddress.Empty)
			{
				this.DataObject.EmailAddressPolicyEnabled = false;
				SmtpAddress value = (SmtpAddress)this.DataObject.GetOriginalObject()[MailboxSchema.WindowsLiveID];
				if (value == SmtpAddress.Empty || value == this.DataObject.PrimarySmtpAddress)
				{
					this.DataObject.PrimarySmtpAddress = this.DataObject.WindowsLiveID;
				}
			}
			bool flag = false;
			ADUser dataObject = this.DataObject;
			if (this.needChangeMailboxSubtype)
			{
				if (this.originalRecipientTypeDetails == RecipientTypeDetails.UserMailbox || this.targetRecipientTypeDetails == RecipientTypeDetails.UserMailbox)
				{
					flag = true;
				}
			}
			else if (dataObject.IsChanged(ADRecipientSchema.MasterAccountSid))
			{
				flag = true;
			}
			if (!flag && (this.RemoveManagedFolderAndPolicy || base.Fields.IsModified(ADUserSchema.SharingPolicy)))
			{
				flag = true;
			}
			if (flag)
			{
				CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, dataObject, false, this.ConfirmationMessage, new CmdletProxyInfo.ChangeCmdletProxyParametersDelegate(CmdletProxy.AppendForceToProxyCmdlet));
			}
			if ((dataObject.IsChanged(ADUserSchema.LitigationHoldEnabled) && dataObject.LitigationHoldEnabled) || (dataObject.IsChanged(ADRecipientSchema.InPlaceHoldsRaw) && dataObject.IsInLitigationHoldOrInplaceHold))
			{
				RecoverableItemsQuotaHelper.IncreaseRecoverableItemsQuotaIfNeeded(dataObject);
			}
			return this.DataObject;
		}
Example #9
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag = false;

            this.summary = default(UpdateSafeList.SafeListSummary);
            CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, (ADUser)this.DataObject, false, this.ConfirmationMessage, null);
            try
            {
                ADUser aduser = this.DataObject as ADUser;
                if (aduser == null || (aduser.RecipientType != RecipientType.UserMailbox && aduser.RecipientType != RecipientType.MailUser))
                {
                    base.WriteError(new RecipientTypeInvalidException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser);
                }
                ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, aduser);
                using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Update-SafeList"))
                {
                    if (!mailboxSession.Capabilities.CanHaveJunkEmailRule)
                    {
                        base.WriteError(new MailboxNotJunkRuleCapableException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser);
                    }
                    else if (this.EnsureJunkEmailRule)
                    {
                        this.CheckAndCreateJunkEmailRule(mailboxSession);
                    }
                    else
                    {
                        JunkEmailRule filteredJunkEmailRule = mailboxSession.FilteredJunkEmailRule;
                        switch (this.Type)
                        {
                        case UpdateType.SafeSenders:
                        case UpdateType.SafeRecipients:
                        case UpdateType.BlockedSenders:
                            flag = this.CheckAndUpdateHashes(filteredJunkEmailRule, this.Type);
                            break;

                        case UpdateType.Both:
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders))
                            {
                                flag = true;
                            }
                            break;

                        case UpdateType.All:
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders))
                            {
                                flag = true;
                            }
                            if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.BlockedSenders))
                            {
                                flag = true;
                            }
                            break;
                        }
                        if (flag)
                        {
                            base.InternalProcessRecord();
                            if ((this.Type == UpdateType.SafeSenders || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedContacts > 0 || this.summary.SkippedSafeSenderDomains > 0 || this.summary.SkippedSafeSenders > 0))
                            {
                                this.WriteWarning(Strings.SafeSendersNotUpdated(this.summary.SkippedContacts, this.summary.SkippedSafeSenders, this.summary.SkippedSafeSenderDomains, this.Identity.ToString()));
                            }
                            if ((this.Type == UpdateType.SafeRecipients || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedSafeRecipientDomains > 0 || this.summary.SkippedSafeRecipients > 0))
                            {
                                this.WriteWarning(Strings.SafeRecipientsNotUpdated(this.summary.SkippedSafeRecipients, this.summary.SkippedSafeRecipientDomains, this.Identity.ToString()));
                            }
                            if ((this.Type == UpdateType.BlockedSenders || this.Type == UpdateType.All) && (this.summary.SkippedBlockedSenderDomains > 0 || this.summary.SkippedBlockedSenders > 0))
                            {
                                this.WriteWarning(Strings.BlockedSendersNotUpdated(this.summary.SkippedBlockedSenders, this.summary.SkippedBlockedSenderDomains, this.Identity.ToString()));
                            }
                        }
                        if (flag || !filteredJunkEmailRule.AllRestrictionsLoaded)
                        {
                            filteredJunkEmailRule.Save();
                        }
                    }
                }
            }
            catch (JunkEmailValidationException ex)
            {
                TaskLogger.LogError(ex);
                base.WriteError(ex, ErrorCategory.InvalidData, this.DataObject);
            }
            catch (StorageTransientException ex2)
            {
                TaskLogger.LogError(ex2);
                base.WriteError(ex2, ErrorCategory.ReadError, this.DataObject);
            }
            catch (StoragePermanentException ex3)
            {
                TaskLogger.LogError(ex3);
                base.WriteError(ex3, ErrorCategory.InvalidOperation, this.DataObject);
            }
            finally
            {
                TaskLogger.LogExit();
            }
        }