예제 #1
0
        protected bool IsOverridingAllowCapabilityFound(ADRawEntry adObject)
        {
            CapabilityIdentifierEvaluator capabilityIdentifierEvaluator = this.OverridingAllowCapabilityEvaluators.FirstOrDefault((CapabilityIdentifierEvaluator x) => x.Evaluate(adObject) == CapabilityEvaluationResult.Yes);

            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ValidationRule.IsOverridingAllowCapabilityFound({0}). OverridingAllowCapability: {1}.", adObject.GetDistinguishedNameOrName(), (capabilityIdentifierEvaluator != null) ? capabilityIdentifierEvaluator.Capability.ToString() : "<NULL>");
            return(capabilityIdentifierEvaluator != null);
        }
        internal static MultiValuedProperty <Capability> GetCapabilities(ADRawEntry adObject)
        {
            MultiValuedProperty <Capability> multiValuedProperty = new MultiValuedProperty <Capability>();

            foreach (object obj in Enum.GetValues(typeof(Capability)))
            {
                Capability capability = (Capability)obj;
                if (capability != Capability.None)
                {
                    CapabilityIdentifierEvaluator capabilityIdentifierEvaluator = CapabilityIdentifierEvaluatorFactory.Create(capability);
                    CapabilityEvaluationResult    capabilityEvaluationResult    = capabilityIdentifierEvaluator.Evaluate(adObject);
                    if (capabilityEvaluationResult == CapabilityEvaluationResult.Yes)
                    {
                        multiValuedProperty.Add(capability);
                    }
                }
            }
            return(multiValuedProperty);
        }
        protected override bool InternalTryValidate(ADRawEntry adObject, out RuleValidationException validationException)
        {
            validationException = null;
            CapabilityIdentifierEvaluator capabilityIdentifierEvaluator = base.RestrictedCapabilityEvaluators.FirstOrDefault((CapabilityIdentifierEvaluator x) => CapabilityEvaluationResult.Yes == x.Evaluate(adObject));

            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ExpressionFilterValidationRule.InternalTryValidate({0}). CurlpritCapability {1}.", adObject.GetDistinguishedNameOrName(), (capabilityIdentifierEvaluator != null) ? capabilityIdentifierEvaluator.Capability.ToString() : "<NULL>");
            if (capabilityIdentifierEvaluator == null)
            {
                return(true);
            }
            foreach (ValidationRuleExpression validationRuleExpression in base.RuleDefinition.Expressions)
            {
                if (validationRuleExpression.ApplicableObjects != null && validationRuleExpression.ApplicableObjects.Count > 0)
                {
                    Type right = validationRuleExpression.ApplicableObjects.FirstOrDefault((Type x) => x.IsAssignableFrom(adObject.GetType()));
                    if (null == right)
                    {
                        ExTraceGlobals.AccessCheckTracer.TraceDebug <string, Type, string>((long)this.GetHashCode(), "ExpressionFilterValidationRule.InternalTryValidate({0}). Object type '{1}' is not on the list of applicable types for expression {2}.", adObject.GetDistinguishedNameOrName(), adObject.GetType(), validationRuleExpression.QueryString);
                        continue;
                    }
                }
                bool flag = true;
                foreach (PropertyDefinition propertyDefinition in validationRuleExpression.QueryFilter.FilterProperties())
                {
                    if (!adObject.propertyBag.Contains((ProviderPropertyDefinition)propertyDefinition))
                    {
                        ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ExpressionFilterValidationRule.InternalTryValidate({0}). Missing Property {1}.", adObject.GetDistinguishedNameOrName(), propertyDefinition.Name);
                        flag = false;
                        break;
                    }
                }
                if (flag && !OpathFilterEvaluator.FilterMatches(validationRuleExpression.QueryFilter, adObject) && !base.IsOverridingAllowCapabilityFound(adObject))
                {
                    validationException = new RuleValidationException(base.GetValidationRuleErrorMessage(adObject, capabilityIdentifierEvaluator.Capability));
                    return(false);
                }
            }
            return(true);
        }