Exemple #1
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            OrganizationId organizationId = this.DataObject.OrganizationId;
            OrganizationalUnitIdParameter organizationalUnitIdParameter = null;

            if (base.Fields.IsModified("RecipientContainer"))
            {
                if (this.RecipientContainer == null)
                {
                    this.DataObject.RecipientContainer = null;
                }
                else
                {
                    organizationalUnitIdParameter = this.RecipientContainer;
                }
            }
            else if (this.DataObject.IsModified(AddressBookBaseSchema.RecipientContainer) && this.DataObject.RecipientContainer != null)
            {
                organizationalUnitIdParameter = new OrganizationalUnitIdParameter(this.DataObject.RecipientContainer);
            }
            if (organizationalUnitIdParameter != null)
            {
                if (base.GlobalConfigSession.IsInPreE14InteropMode())
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorCannotSetRecipientContainer), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                }
                this.DataObject.RecipientContainer = NewAddressBookBase.GetRecipientContainer(organizationalUnitIdParameter, (IConfigurationSession)base.DataSession, organizationId, new NewAddressBookBase.GetUniqueObject(base.GetDataObject <ExchangeOrganizationalUnit>), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            }
            if (this.IsObjectStateChanged() && this.DataObject.HasMailboxManagerSetting)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorCanNotUpgradePolicyWithMailboxSetting(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Id);
            }
            if (this.IsObjectStateChanged() && this.DataObject.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2007))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorObjectNotManagableFromCurrentConsole(this.Identity.ToString(), this.DataObject.ExchangeVersion.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (!base.HasErrors)
            {
                if (this.DataObject.IsChanged(EmailAddressPolicySchema.Priority) && this.DataObject.Priority != 0)
                {
                    UpdateEmailAddressPolicy.PreparePriorityOfEapObjects(organizationId, this.DataObject, base.DataSession, new TaskExtendedErrorLoggingDelegate(this.WriteError), out this.affectedPolicies, out this.affectedPoliciesOriginalPriority);
                }
                if (!base.HasErrors && (this.DataObject.IsChanged(EmailAddressPolicySchema.RecipientFilter) || this.DataObject.IsChanged(EmailAddressPolicySchema.Priority) || this.DataObject.IsChanged(EmailAddressPolicySchema.RawEnabledEmailAddressTemplates) || this.DataObject.IsChanged(EmailAddressPolicySchema.DisabledEmailAddressTemplates) || this.DataObject.IsChanged(EmailAddressPolicySchema.NonAuthoritativeDomains) || this.DataObject.IsChanged(EmailAddressPolicySchema.RecipientContainer)))
                {
                    this.DataObject[EmailAddressPolicySchema.RecipientFilterApplied] = false;
                }
            }
            if (this.domainValidator == null || !this.domainValidator.OrganizationId.Equals(organizationId))
            {
                this.domainValidator = new UpdateEmailAddressPolicy.WritableDomainValidator(organizationId, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            this.domainValidator.Validate(this.DataObject);
            TaskLogger.LogExit();
        }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession;

            this.containerId = base.CurrentOrgContainerId.GetDescendantId(EmailAddressPolicy.RdnEapContainerToOrganization);
            this.DataObject  = (EmailAddressPolicy)base.PrepareDataObject();
            if (!base.HasErrors)
            {
                this.DataObject.SetId(this.containerId.GetChildId(base.Name));
                if (!this.DataObject.IsModified(EmailAddressPolicySchema.Priority))
                {
                    this.DataObject.Priority = EmailAddressPolicyPriority.Lowest;
                }
                if (!base.HasErrors && (this.DataObject.Priority != 0 || !this.DataObject.IsModified(EmailAddressPolicySchema.Priority)))
                {
                    UpdateEmailAddressPolicy.PreparePriorityOfEapObjects(base.OrganizationId ?? OrganizationId.ForestWideOrgId, this.DataObject, base.DataSession, new TaskExtendedErrorLoggingDelegate(this.WriteError), out this.affectedPolicies, out this.affectedPoliciesOriginalPriority);
                }
                OrganizationalUnitIdParameter organizationalUnitIdParameter = null;
                if (base.Fields.IsModified("RecipientContainer"))
                {
                    if (this.RecipientContainer == null)
                    {
                        this.DataObject.RecipientContainer = null;
                    }
                    else
                    {
                        organizationalUnitIdParameter = this.RecipientContainer;
                    }
                }
                else if (this.DataObject.RecipientContainer != null)
                {
                    organizationalUnitIdParameter = new OrganizationalUnitIdParameter(this.DataObject.RecipientContainer);
                }
                if (organizationalUnitIdParameter != null)
                {
                    if (base.GlobalConfigSession.IsInPreE14InteropMode())
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorCannotSetRecipientContainer), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                    }
                    this.DataObject.RecipientContainer = NewAddressBookBase.GetRecipientContainer(organizationalUnitIdParameter, (IConfigurationSession)base.DataSession, base.OrganizationId ?? OrganizationId.ForestWideOrgId, new NewAddressBookBase.GetUniqueObject(base.GetDataObject <ExchangeOrganizationalUnit>), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                }
            }
            TaskLogger.LogExit();
            return(this.DataObject);
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (!base.HasErrors)
     {
         if (base.DataObject.Priority == EmailAddressPolicyPriority.Lowest)
         {
             this.WriteError(new InvalidOperationException(Strings.ErrorInvalidOperationOnLowestEap(this.Identity.ToString())), ErrorCategory.InvalidOperation, base.DataObject.Identity, false);
         }
         this.affectedPolicies = null;
         if (EmailAddressPolicySchema.Priority.ValidateValue(base.DataObject.Priority, false) == null)
         {
             base.DataObject.Priority = EmailAddressPolicyPriority.Lowest;
             UpdateEmailAddressPolicy.PreparePriorityOfEapObjects(base.DataObject.OrganizationId, base.DataObject, base.DataSession, new TaskExtendedErrorLoggingDelegate(this.WriteError), out this.affectedPolicies, out this.affectedPoliciesOriginalPriority);
         }
     }
     TaskLogger.LogExit();
 }