Exemple #1
0
		protected override void InternalValidate()
		{
			TaskLogger.LogEnter();
			base.InternalValidate();
			if (base.Fields.IsModified(ADRecipientSchema.RoleAssignmentPolicy) && (MailboxPolicyIdParameter)base.Fields[ADRecipientSchema.RoleAssignmentPolicy] == null && !OrganizationId.ForestWideOrgId.Equals(this.DataObject.OrganizationId))
			{
				base.WriteError(new TaskInvalidOperationException(Strings.ResettingPolicyIsNotSupported("RoleAssignmentPolicy")), ExchangeErrorCategory.Client, this.Identity);
			}
			SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(base.CurrentOrganizationId);
			if (sharedConfiguration != null)
			{
				this.DataObject.SharedConfiguration = sharedConfiguration.SharedConfigId.ConfigurationUnit;
			}
			if (this.DataObject.IsResource)
			{
				this.CheckResourceProperties();
			}
			else if (this.DataObject.RecipientTypeDetails == RecipientTypeDetails.DiscoveryMailbox)
			{
				if (base.Fields.IsModified(ADRecipientSchema.AcceptMessagesOnlyFrom) || base.Fields.IsModified(ADRecipientSchema.AcceptMessagesOnlyFromSendersOrMembers))
				{
					base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeAcceptMessagesFrom), ExchangeErrorCategory.Client, this.DataObject);
				}
				MailboxTaskHelper.ValidateMaximumDiscoveryMailboxQuota(this.DataObject, this.ConfigurationSession, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.WriteError));
			}
			else if (this.PublicFolder && base.UserSpecifiedParameters.Contains(MailEnabledRecipientSchema.HiddenFromAddressListsEnabled.Name))
			{
				base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeHiddenFromAddressListsEnabled), ExchangeErrorCategory.Client, this.DataObject);
			}
			if (this.RetentionPolicy != null && this.DataObject.RecipientTypeDetails == RecipientTypeDetails.TeamMailbox)
			{
				base.WriteError(new RecipientTaskException(Strings.ErrorNoRetentionPolicyForTeamMailbox(this.DataObject.Name)), ExchangeErrorCategory.Client, this.DataObject);
			}
			if (this.AuditLog)
			{
				Mailbox mailbox = (Mailbox)this.GetDynamicParameters();
				foreach (object obj in SetMailboxBase<MailboxIdParameter, Mailbox>.InvalidAuditLogParameters)
				{
					ProviderPropertyDefinition providerPropertyDefinition = obj as ProviderPropertyDefinition;
					if (base.Fields.IsModified(obj) || (providerPropertyDefinition != null && mailbox.IsModified(providerPropertyDefinition)))
					{
						base.WriteError(new TaskArgumentException(Strings.ErrorInvalidParameterForAuditLog((providerPropertyDefinition == null) ? obj.ToString() : providerPropertyDefinition.Name, "AuditLog")), ExchangeErrorCategory.Client, this.Identity);
					}
				}
			}
			else if (this.DataObject.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox)
			{
				base.WriteError(new RecipientTaskException(Strings.RecipientNotFoundException(this.DataObject.Name)), ExchangeErrorCategory.Client, this.DataObject);
			}
			base.VerifyIsWithinScopes((IRecipientSession)base.DataSession, this.DataObject, true, new DataAccessTask<ADUser>.ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
			TaskLogger.LogExit();
		}
Exemple #2
0
		protected override void InternalBeginProcessing()
		{
			TaskLogger.LogEnter();
			if (this.RemoveManagedFolderAndPolicy)
			{
				this.RetentionPolicy = null;
			}
			base.InternalBeginProcessing();
			base.CheckExclusiveParameters(new object[]
			{
				ADRecipientSchema.MailboxPlan,
				"SKUCapability"
			});
			Mailbox mailbox = (Mailbox)this.GetDynamicParameters();
			this.needChangeMailboxSubtype = base.Fields.IsModified("Type");
			if (this.needChangeMailboxSubtype)
			{
				if (ConvertibleMailboxSubType.Equipment != this.Type && ConvertibleMailboxSubType.Room != this.Type && (mailbox.ResourceCustom.Changed || mailbox.ResourceCapacity != null))
				{
					base.ThrowTerminatingError(new TaskArgumentException(Strings.ErrorCannotChangeResourceProperties, null), ExchangeErrorCategory.Client, null);
				}
				if (base.Fields.IsModified("LinkedCredential") || base.Fields.IsModified("LinkedDomainController") || base.Fields.IsModified(MailboxSchema.LinkedMasterAccount))
				{
					base.ThrowTerminatingError(new TaskArgumentException(Strings.ErrorCannotChangeLinkedProperty, null), ExchangeErrorCategory.Client, null);
				}
			}
			if (mailbox.IsModified(MailboxSchema.UseDatabaseRetentionDefaults) && mailbox.IsModified(MailboxSchema.RetainDeletedItemsUntilBackup) && mailbox.UseDatabaseRetentionDefaults && mailbox.RetainDeletedItemsUntilBackup)
			{
				base.ThrowTerminatingError(new RecipientTaskException(Strings.ErrorOnlyOneParameterMayBeUsed), ExchangeErrorCategory.Client, this);
			}
			if (mailbox.IsModified(MailboxSchema.AuditOwner))
			{
				MultiValuedProperty<MailboxAuditOperations> auditOwner = mailbox.AuditOwner;
				foreach (MailboxAuditOperations mailboxAuditOperations in auditOwner)
				{
					if ((mailboxAuditOperations & SetMailboxBase<TIdentity, TPublicObject>.UnsupportedOwnerOperations) != MailboxAuditOperations.None)
					{
						base.ThrowTerminatingError(new RecipientTaskException(Strings.ErrorInvalidAuditOwnerOperationType), ExchangeErrorCategory.Client, this);
					}
				}
			}
			if (mailbox.IsModified(MailboxSchema.AuditDelegate))
			{
				MultiValuedProperty<MailboxAuditOperations> auditDelegate = mailbox.AuditDelegate;
				foreach (MailboxAuditOperations mailboxAuditOperations2 in auditDelegate)
				{
					if ((mailboxAuditOperations2 & SetMailboxBase<TIdentity, TPublicObject>.UnsupportedDelegateOperations) != MailboxAuditOperations.None)
					{
						base.ThrowTerminatingError(new RecipientTaskException(Strings.ErrorInvalidAuditDelegateOperationType), ExchangeErrorCategory.Client, this);
					}
				}
			}
			if (mailbox.IsModified(MailboxSchema.AuditAdmin))
			{
				MultiValuedProperty<MailboxAuditOperations> auditAdmin = mailbox.AuditAdmin;
				foreach (MailboxAuditOperations mailboxAuditOperations3 in auditAdmin)
				{
					if ((mailboxAuditOperations3 & SetMailboxBase<TIdentity, TPublicObject>.UnsupportedAdminOperations) != MailboxAuditOperations.None)
					{
						base.ThrowTerminatingError(new RecipientTaskException(Strings.ErrorInvalidAuditAdminOperationType), ExchangeErrorCategory.Client, this);
					}
				}
			}
			if (this.LinkedMasterAccount != null)
			{
				if (string.IsNullOrEmpty(this.LinkedDomainController))
				{
					base.ThrowTerminatingError(new TaskArgumentException(Strings.ErrorMissLinkedDomainController), ExchangeErrorCategory.Client, this);
				}
				try
				{
					NetworkCredential userForestCredential = (this.LinkedCredential == null) ? null : this.LinkedCredential.GetNetworkCredential();
					mailbox[ADRecipientSchema.MasterAccountSid] = MailboxTaskHelper.GetAccountSidFromAnotherForest(this.LinkedMasterAccount, this.LinkedDomainController, userForestCredential, base.GlobalConfigSession, new MailboxTaskHelper.GetUniqueObject(base.GetDataObject<ADUser>), new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
				}
				catch (PSArgumentException exception)
				{
					base.ThrowNonLocalizedTerminatingError(exception, ExchangeErrorCategory.Client, this.LinkedCredential);
				}
			}
			TaskLogger.LogExit();
		}