示例#1
0
 internal static ADObjectId ResolveDNIfNecessary(ADObjectId obj)
 {
     if (ADSessionSettings.IsRunningOnCmdlet() || ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("IsSoftLinkResolutionEnabledForAllProcesses"))
     {
         return(ADObjectIdResolutionHelper.ResolveDN(obj));
     }
     return(obj);
 }
示例#2
0
        private static ADObjectId ResolveADObject(ADObjectId obj)
        {
            bool config = ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("IsSoftLinkResolutionCacheEnabled");

            if (config)
            {
                return(ADObjectIdResolutionCache.Default.GetEntry(obj));
            }
            return(ADObjectIdResolutionHelper.ResolveADObjectIdWithoutCache(obj));
        }
示例#3
0
        internal static ADObjectId ResolveADObjectIdWithoutCache(ADObjectId obj)
        {
            IDirectorySession sessionForPartition = ADObjectIdResolutionHelper.GetSessionForPartition(obj.PartitionFQDN);
            ADRawEntry        adrawEntry          = sessionForPartition.ReadADRawEntry(obj, ADObjectIdResolutionHelper.propertiesToRetrieve);

            if (adrawEntry != null)
            {
                return(adrawEntry.Id);
            }
            return(obj);
        }
示例#4
0
 internal static ADObjectId ResolveSoftLink(ADObjectId obj)
 {
     if (!ADGlobalConfigSettings.SoftLinkEnabled)
     {
         return(obj);
     }
     if (obj == null || string.IsNullOrEmpty(obj.DistinguishedName) || (obj.PartitionGuid != Guid.Empty && obj.ObjectGuid != Guid.Empty))
     {
         return(obj);
     }
     return(ADObjectIdResolutionHelper.ResolveADObjectIdWithoutCache(obj));
 }
示例#5
0
 internal static ADObjectId ResolveDN(ADObjectId obj)
 {
     if (!ADGlobalConfigSettings.SoftLinkEnabled)
     {
         return(obj);
     }
     if (obj == null || !string.IsNullOrEmpty(obj.DistinguishedName) || obj.ObjectGuid == Guid.Empty)
     {
         return(obj);
     }
     return(ADObjectIdResolutionHelper.ResolveADObject(obj));
 }
        // Token: 0x06000DD8 RID: 3544 RVA: 0x0003FF84 File Offset: 0x0003E184
        private void ConvertComparisonFilterInternal(ComparisonFilter comparisonFilter, QueryFilter parentFilter, bool isSoftLink, byte softLinkPrefix = 0)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)comparisonFilter.Property;
            object obj             = comparisonFilter.PropertyValue;
            string ldapDisplayName = adpropertyDefinition.LdapDisplayName;

            if (isSoftLink && adpropertyDefinition.IsSoftLinkAttribute)
            {
                ldapDisplayName = adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName;
                if (obj != null)
                {
                    obj = ADObjectIdResolutionHelper.ResolveSoftLink((ADObjectId)obj);
                }
            }
            bool flag = adpropertyDefinition.Type.IsGenericType && adpropertyDefinition.Type.GetGenericTypeDefinition() == typeof(Unlimited <>);

            if (flag)
            {
                bool flag2 = adpropertyDefinition.DefaultValue.Equals(obj);
                switch (comparisonFilter.ComparisonOperator)
                {
                case ComparisonOperator.Equal:
                    if (flag2)
                    {
                        this.IncrementFilterSize(2);
                        this.ldapFilter.Append("(!(");
                        this.ldapFilter.Append(ldapDisplayName);
                        this.ldapFilter.Append("=*))");
                        return;
                    }
                    break;

                case ComparisonOperator.NotEqual:
                case ComparisonOperator.LessThan:
                    if (flag2)
                    {
                        this.IncrementFilterSize();
                        this.ldapFilter.Append('(');
                        this.ldapFilter.Append(ldapDisplayName);
                        this.ldapFilter.Append("=*)");
                        return;
                    }
                    break;

                case ComparisonOperator.LessThanOrEqual:
                    if (flag2)
                    {
                        this.IncrementFilterSize();
                        this.ldapFilter.Append("(objectclass=*)");
                        return;
                    }
                    break;

                case ComparisonOperator.GreaterThan:
                    if (flag2)
                    {
                        this.IncrementFilterSize();
                        this.ldapFilter.Append("(!(objectclass=*))");
                        return;
                    }
                    break;

                case ComparisonOperator.GreaterThanOrEqual:
                    if (flag2)
                    {
                        this.IncrementFilterSize(2);
                        this.ldapFilter.Append("(!(");
                        this.ldapFilter.Append(ldapDisplayName);
                        this.ldapFilter.Append("=*))");
                        return;
                    }
                    this.IncrementFilterSize(4);
                    this.ldapFilter.Append("(|(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append(">=");
                    ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix);
                    this.ldapFilter.Append(")(!(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append("=*)))");
                    return;
                }
            }
            switch (comparisonFilter.ComparisonOperator)
            {
            case ComparisonOperator.LessThan:
                this.ConvertCompositeFilter(new AndFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.LessThanOrEqual, comparisonFilter.Property, obj),
                    new ComparisonFilter(ComparisonOperator.NotEqual, comparisonFilter.Property, obj)
                }), parentFilter);
                return;

            case ComparisonOperator.GreaterThan:
                this.ConvertCompositeFilter(new AndFilter(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, comparisonFilter.Property, obj),
                    new ComparisonFilter(ComparisonOperator.NotEqual, comparisonFilter.Property, obj)
                }), parentFilter);
                return;
            }
            if (!adpropertyDefinition.PersistDefaultValue && !flag && adpropertyDefinition.DefaultValue != null && adpropertyDefinition.DefaultValue.Equals(comparisonFilter.PropertyValue))
            {
                switch (comparisonFilter.ComparisonOperator)
                {
                case ComparisonOperator.Equal:
                    this.IncrementFilterSize(4);
                    this.ldapFilter.Append("(|(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append("=");
                    ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, adpropertyDefinition.DefaultValue, this.ldapFilter, isSoftLink, softLinkPrefix);
                    this.ldapFilter.Append(")(!(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append("=*)))");
                    return;

                case ComparisonOperator.NotEqual:
                    this.IncrementFilterSize(4);
                    this.ldapFilter.Append("(&(!(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append("=");
                    ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, adpropertyDefinition.DefaultValue, this.ldapFilter, isSoftLink, softLinkPrefix);
                    this.ldapFilter.Append("))(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append("=*))");
                    return;

                default:
                    throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedDefaultValueFilter(adpropertyDefinition.Name, comparisonFilter.ComparisonOperator.ToString(), (comparisonFilter.PropertyValue == null) ? string.Empty : obj.ToString()));
                }
            }
            else
            {
                string value = string.Empty;
                switch (comparisonFilter.ComparisonOperator)
                {
                case ComparisonOperator.Equal:
                    value = "=";
                    goto IL_49B;

                case ComparisonOperator.NotEqual:
                    value = "=";
                    goto IL_49B;

                case ComparisonOperator.LessThanOrEqual:
                    value = "<=";
                    goto IL_49B;

                case ComparisonOperator.GreaterThanOrEqual:
                    value = ">=";
                    goto IL_49B;
                }
                throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperator(comparisonFilter.ComparisonOperator.ToString(), typeof(ComparisonFilter).ToString()));
IL_49B:
                if (comparisonFilter.ComparisonOperator == ComparisonOperator.NotEqual)
                {
                    this.IncrementFilterSize(2);
                    this.ldapFilter.Append("(!(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append(value);
                    ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix);
                    this.ldapFilter.Append("))");
                    return;
                }
                if (adpropertyDefinition == ADObjectSchema.Id && Guid.Empty != ((ADObjectId)obj).ObjectGuid && this.tenantScoped && comparisonFilter.ComparisonOperator == ComparisonOperator.Equal)
                {
                    this.IncrementFilterSize(3);
                    this.ldapFilter.Append("(|(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append(value);
                    ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, false, softLinkPrefix);
                    this.ldapFilter.Append(")(");
                    this.ldapFilter.Append(ADObjectSchema.CorrelationIdRaw.LdapDisplayName);
                    this.ldapFilter.Append(value);
                    this.ldapFilter.Append(ADValueConvertor.EscapeBinaryValue(((ADObjectId)obj).ObjectGuid.ToByteArray()));
                    this.ldapFilter.Append("))");
                    return;
                }
                if (adpropertyDefinition == ADObjectSchema.Guid && this.tenantScoped && comparisonFilter.ComparisonOperator == ComparisonOperator.Equal)
                {
                    string value2 = ADValueConvertor.EscapeBinaryValue(((Guid)obj).ToByteArray());
                    this.IncrementFilterSize(3);
                    this.ldapFilter.Append("(|(");
                    this.ldapFilter.Append(ldapDisplayName);
                    this.ldapFilter.Append(value);
                    this.ldapFilter.Append(value2);
                    this.ldapFilter.Append(")(");
                    this.ldapFilter.Append(ADObjectSchema.CorrelationIdRaw.LdapDisplayName);
                    this.ldapFilter.Append(value);
                    this.ldapFilter.Append(value2);
                    this.ldapFilter.Append("))");
                    return;
                }
                this.IncrementFilterSize();
                this.ldapFilter.Append("(");
                this.ldapFilter.Append(ldapDisplayName);
                this.ldapFilter.Append(value);
                ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, obj, this.ldapFilter, isSoftLink, softLinkPrefix);
                this.ldapFilter.Append(")");
                return;
            }
        }