Пример #1
0
 internal static ADPropertyDefinition ConfigurationXmlProperty <T>(ADPropertyDefinition configXmlRawProperty) where T : XMLSerializableBase
 {
     return(new ADPropertyDefinition("ConfigurationXML", ExchangeObjectVersion.Exchange2003, typeof(T), null, ADPropertyDefinitionFlags.Calculated, null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new ProviderPropertyDefinition[]
     {
         configXmlRawProperty
     }, null, XMLSerializableBase.ConfigurationXMLGetterDelegate <T>(configXmlRawProperty), XMLSerializableBase.ConfigurationXMLSetterDelegate <T>(configXmlRawProperty), null, null));
 }
 public bool this[ADPropertyDefinition owaFeature]
 {
     get
     {
         return((bool)this.owaSegmentationSettings[owaFeature]);
     }
 }
Пример #3
0
        public bool UpdateProperties(IList <PropertyDefinition> properties)
        {
            if (TopologyProvider.CurrentTopologyMode == TopologyMode.Adam || TopologyMode.Ldap == TopologyProvider.CurrentTopologyMode)
            {
                ExTraceGlobals.SchemaInitializationTracer.TraceDebug <TopologyMode>((long)this.GetHashCode(), "Aborting Schema Update. TopologyMode: {0}", TopologyProvider.CurrentTopologyMode);
                return(false);
            }
            bool flag = this.schemaSession.IsReadConnectionAvailable();

            if (!flag)
            {
                ExTraceGlobals.SchemaInitializationTracer.TraceDebug <bool>((long)this.GetHashCode(), "Aborting Schema Update. IsConnectionAvailable: {1}", flag);
                return(false);
            }
            bool result = true;
            List <ADPropertyDefinition> propertiesToRead;
            List <ADPropertyDefinition> list;

            this.GetPropertiesToUpdate(properties, out propertiesToRead, out list);
            this.UpdateConstraintDictionary(propertiesToRead);
            for (int i = 0; i < list.Count; i++)
            {
                ADPropertyDefinition           adpropertyDefinition = list[i];
                PropertyDefinitionConstraint[] autogeneratedConstraints;
                if (this.constraintDictionary.TryGetValue(ADSchemaDataProvider.PropertyKey.GetPropertyKey(adpropertyDefinition), out autogeneratedConstraints))
                {
                    adpropertyDefinition.SetAutogeneratedConstraints(autogeneratedConstraints);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
 private void ThrowIfFeatureTypeNotBoolean(ADPropertyDefinition owaFeature)
 {
     if (owaFeature.Type != typeof(bool))
     {
         throw new ArgumentException("owaFeature: OWA Segmentation features must be of type System.Boolean. Please fix it.", "owaFeature");
     }
 }
 public static GetterDelegate RawStringGetterIgnoringInvalid <TConverted>(ADPropertyDefinition rawPropertyDefinition, ADPropertyDefinition convertedPropertyDefinition)
 {
     if (!rawPropertyDefinition.IsMultivalued)
     {
         throw new NotImplementedException("RawStringGetterIgnoringInvalid is only currently implemented for multi-valued properties.");
     }
     return(delegate(IPropertyBag bag)
     {
         MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)bag[rawPropertyDefinition];
         MultiValuedProperty <TConverted> result = null;
         List <TConverted> list = new List <TConverted>();
         bool flag = false;
         foreach (string originalValue in multiValuedProperty)
         {
             object obj;
             Exception ex;
             if (ADValueConvertor.TryConvertValueFromString(originalValue, typeof(TConverted), rawPropertyDefinition.FormatProvider, out obj, out ex))
             {
                 list.Add((TConverted)((object)obj));
             }
             else
             {
                 flag = true;
             }
         }
         if (!flag && list.Count != 0)
         {
             result = new MultiValuedProperty <TConverted>(rawPropertyDefinition.IsReadOnly, convertedPropertyDefinition, list);
         }
         return result;
     });
 }
Пример #6
0
 private void UpdateConstraintDictionary(List <ADPropertyDefinition> propertiesToRead)
 {
     if (propertiesToRead.Count > 0)
     {
         this.ReadPropertiesFromAD(propertiesToRead, false);
         Dictionary <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]> dictionary = new Dictionary <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]>(propertiesToRead.Count);
         for (int i = 0; i < propertiesToRead.Count; i++)
         {
             ADPropertyDefinition    adpropertyDefinition = propertiesToRead[i];
             ADSchemaAttributeObject schemaObject;
             if (this.schemaAttributeObjectDictionary.TryGetValue(adpropertyDefinition.LdapDisplayName, out schemaObject))
             {
                 PropertyDefinitionConstraint[] value = this.GeneratePropertyConstraints(schemaObject, adpropertyDefinition);
                 dictionary[ADSchemaDataProvider.PropertyKey.GetPropertyKey(adpropertyDefinition)] = value;
             }
             else
             {
                 Globals.LogEvent(DirectoryEventLogConstants.Tuple_DSC_EVENT_CONSTRAINT_READ_FAILED, null, new object[]
                 {
                     adpropertyDefinition.ToString(),
                     adpropertyDefinition.LdapDisplayName
                 });
             }
         }
         lock (this.constraintDictionary)
         {
             Dictionary <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]> dictionary2 = new Dictionary <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]>(this.constraintDictionary);
             foreach (KeyValuePair <ADSchemaDataProvider.PropertyKey, PropertyDefinitionConstraint[]> keyValuePair in dictionary)
             {
                 dictionary2[keyValuePair.Key] = keyValuePair.Value;
             }
             this.constraintDictionary = dictionary2;
         }
     }
 }
        // Token: 0x06000DD9 RID: 3545 RVA: 0x00040694 File Offset: 0x0003E894
        private void ConvertExistsFilter(ExistsFilter existsFilter)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)existsFilter.Property;

            if (adpropertyDefinition.IsSoftLinkAttribute)
            {
                switch (this.softLinkMode)
                {
                case SoftLinkMode.Enabled:
                    this.ConvertExistsFilterInternal(existsFilter, true);
                    return;

                case SoftLinkMode.Disabled:
                    this.ConvertExistsFilterInternal(existsFilter, false);
                    return;
                }
                this.IncrementFilterSize();
                this.ldapFilter.Append("(|");
                this.ConvertExistsFilterInternal(existsFilter, false);
                this.ConvertExistsFilterInternal(existsFilter, true);
                this.ldapFilter.Append(")");
                return;
            }
            this.ConvertExistsFilterInternal(existsFilter, false);
        }
Пример #8
0
 private static GetterDelegate ConfigurationXMLGetterDelegate <T>(ADPropertyDefinition configXmlRawProperty) where T : XMLSerializableBase
 {
     return(delegate(IPropertyBag bag)
     {
         string serializedXML = (string)bag[configXmlRawProperty];
         return XMLSerializableBase.Deserialize <T>(serializedXML, configXmlRawProperty);
     });
 }
Пример #9
0
 public static ADSchemaDataProvider.PropertyKey GetPropertyKey(ADPropertyDefinition propDef)
 {
     if (propDef == null)
     {
         throw new ArgumentNullException("propDef");
     }
     return(new ADSchemaDataProvider.PropertyKey(propDef.LdapDisplayName, propDef.Type));
 }
 // Token: 0x06001039 RID: 4153 RVA: 0x0004EAAC File Offset: 0x0004CCAC
 public static ADPropertyDefinition CreateRangedProperty(ADPropertyDefinition originalProperty, IntRange range)
 {
     if (range == null || range.LowerBound < 0 || range.LowerBound > range.UpperBound)
     {
         throw new ArgumentException("range");
     }
     return(new ADPropertyDefinition(originalProperty.Name, originalProperty.VersionAdded, originalProperty.Type, originalProperty.FormatProvider, originalProperty.LdapDisplayName + RangedPropertyHelper.GetADRangeSuffix(range), originalProperty.Flags | ADPropertyDefinitionFlags.Ranged | ADPropertyDefinitionFlags.ReadOnly, originalProperty.DefaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, null, null));
 }
Пример #11
0
        private void AddSortControl()
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)this.sortBy.ColumnDefinition;
            SortRequestControl   sortRequestControl   = new SortRequestControl(adpropertyDefinition.LdapDisplayName, LcidMapper.OidFromLcid(this.lcid), this.sortBy.SortOrder == SortOrder.Descending);

            sortRequestControl.IsCritical = false;
            ExTraceGlobals.ADFindTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "ADGenericReader::AddSortControl - Sort on {0}, {1} using rule {2})", sortRequestControl.SortKeys[0].AttributeName, sortRequestControl.SortKeys[0].ReverseOrder ? "reverse order (descending)" : "regular  order (ascending)", sortRequestControl.SortKeys[0].MatchingRule);
            this.DirectoryControls.Add(sortRequestControl);
        }
Пример #12
0
 private static void InternalAddSoftLinkAttribute(ADPropertyDefinition propertyDefinition, List <string> results, int id)
 {
     if (ADGlobalConfigSettings.SoftLinkEnabled && propertyDefinition.IsSoftLinkAttribute)
     {
         string ldapDisplayName = propertyDefinition.SoftLinkShadowProperty.LdapDisplayName;
         ExTraceGlobals.ADPropertyRequestTracer.TraceDebug <string>((long)id, "ADObjectSchema::ADPropertyCollectionToLdapAttributes: requesting {0}", ldapDisplayName);
         results.Add(ldapDisplayName);
     }
 }
Пример #13
0
        public override bool Equals(ProviderPropertyDefinition other)
        {
            if (object.ReferenceEquals(other, this))
            {
                return(true);
            }
            ADPropertyDefinition adpropertyDefinition = other as ADPropertyDefinition;

            return(adpropertyDefinition != null && StringComparer.OrdinalIgnoreCase.Equals(adpropertyDefinition.LdapDisplayName, this.LdapDisplayName) && base.Equals(other));
        }
        // Token: 0x06000DD6 RID: 3542 RVA: 0x0003FD34 File Offset: 0x0003DF34
        private void ConvertSinglePropertyFilter(SinglePropertyFilter queryFilter, QueryFilter parentFilter)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)queryFilter.Property;

            if (adpropertyDefinition.LdapDisplayName == null)
            {
                if (adpropertyDefinition.CustomFilterBuilderDelegate == null)
                {
                    throw new ADFilterException(DirectoryStrings.ExceptionPropertyCannotBeSearchedOn(adpropertyDefinition.Name));
                }
                ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter;
                if (comparisonFilter != null && comparisonFilter.ComparisonOperator == ComparisonOperator.NotEqual)
                {
                    QueryFilter filter = adpropertyDefinition.CustomFilterBuilderDelegate(new ComparisonFilter(ComparisonOperator.Equal, comparisonFilter.Property, comparisonFilter.PropertyValue));
                    this.BuildLdapFilter(QueryFilter.NotFilter(filter), parentFilter);
                    return;
                }
                QueryFilter queryFilter2 = adpropertyDefinition.CustomFilterBuilderDelegate(queryFilter);
                this.BuildLdapFilter(queryFilter2, parentFilter);
                return;
            }
            else
            {
                ComparisonFilter comparisonFilter2 = queryFilter as ComparisonFilter;
                if (comparisonFilter2 != null)
                {
                    this.ConvertComparisonFilter(comparisonFilter2, parentFilter);
                    return;
                }
                ExistsFilter existsFilter = queryFilter as ExistsFilter;
                if (existsFilter != null)
                {
                    this.ConvertExistsFilter(existsFilter);
                    return;
                }
                TextFilter textFilter = queryFilter as TextFilter;
                if (textFilter != null)
                {
                    this.ConvertTextFilter(textFilter);
                    return;
                }
                GenericBitMaskFilter genericBitMaskFilter = queryFilter as GenericBitMaskFilter;
                if (genericBitMaskFilter != null)
                {
                    this.ConvertBitMaskFilter(genericBitMaskFilter);
                    return;
                }
                InChainFilter inChainFilter = queryFilter as InChainFilter;
                if (inChainFilter != null)
                {
                    this.ConvertInChainFilter(inChainFilter);
                }
                return;
            }
        }
        // Token: 0x06000DDC RID: 3548 RVA: 0x00040938 File Offset: 0x0003EB38
        private void ConvertInChainFilter(InChainFilter inChainFilter)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)inChainFilter.Property;
            string ldapDisplayName = adpropertyDefinition.LdapDisplayName;

            this.IncrementFilterSize();
            this.ldapFilter.Append("(");
            this.ldapFilter.Append(ldapDisplayName);
            this.ldapFilter.Append(":1.2.840.113556.1.4.1941:=");
            ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, inChainFilter.Value, this.ldapFilter, false, 0);
            this.ldapFilter.Append(")");
        }
Пример #16
0
 private void InitializeFilterOnlyPropertiesDictionary()
 {
     this.allFilterOnlyPropertiesDictionary = new Dictionary <string, ADPropertyDefinition>(StringComparer.OrdinalIgnoreCase);
     foreach (PropertyDefinition propertyDefinition in base.AllFilterOnlyProperties)
     {
         ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
         if (adpropertyDefinition != null && !string.IsNullOrEmpty(adpropertyDefinition.LdapDisplayName))
         {
             this.allFilterOnlyPropertiesDictionary.Add(adpropertyDefinition.LdapDisplayName, adpropertyDefinition);
         }
     }
 }
Пример #17
0
 private void InitializeAllPropertiesDictionary()
 {
     this.allPropertiesDictionary = new Dictionary <string, ADPropertyDefinition>(StringComparer.OrdinalIgnoreCase);
     foreach (PropertyDefinition propertyDefinition in base.AllProperties)
     {
         ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
         if (adpropertyDefinition != null)
         {
             this.AddPropertyToDictionary(this.allPropertiesDictionary, adpropertyDefinition);
         }
     }
 }
Пример #18
0
 private static SetterDelegate ConfigurationXMLSetterDelegate <T>(ADPropertyDefinition configXmlRawProperty) where T : XMLSerializableBase
 {
     return(delegate(object value, IPropertyBag bag)
     {
         XMLSerializableBase xmlserializableBase = value as XMLSerializableBase;
         string value2 = null;
         if (xmlserializableBase != null)
         {
             value2 = xmlserializableBase.Serialize(false);
         }
         bag[configXmlRawProperty] = value2;
     });
 }
        // Token: 0x06000DD7 RID: 3543 RVA: 0x0003FE2C File Offset: 0x0003E02C
        private void ConvertComparisonFilter(ComparisonFilter comparisonFilter, QueryFilter parentFilter)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)comparisonFilter.Property;

            if (adpropertyDefinition != ADObjectSchema.ObjectCategory)
            {
                this.containsUnsafeIdentity |= adpropertyDefinition.IsForestSpecific;
            }
            if (!adpropertyDefinition.IsSoftLinkAttribute)
            {
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                return;
            }
            bool config = ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("SoftLinkFilterVersion2Enabled");

            switch (this.softLinkMode)
            {
            case SoftLinkMode.Enabled:
                if (config)
                {
                    this.IncrementFilterSize(2);
                    this.ldapFilter.Append("(|");
                    this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                    this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 2);
                    this.ldapFilter.Append(")");
                    return;
                }
                this.IncrementFilterSize();
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                return;

            case SoftLinkMode.Disabled:
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                return;
            }
            if (config)
            {
                this.IncrementFilterSize(3);
                this.ldapFilter.Append("(|");
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 2);
                this.ldapFilter.Append(")");
                return;
            }
            this.IncrementFilterSize(2);
            this.ldapFilter.Append("(|");
            this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
            this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
            this.ldapFilter.Append(")");
        }
        // Token: 0x06000DDA RID: 3546 RVA: 0x00040724 File Offset: 0x0003E924
        private void ConvertExistsFilterInternal(ExistsFilter existsFilter, bool isSoftLink)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)existsFilter.Property;
            string ldapDisplayName = adpropertyDefinition.LdapDisplayName;

            if (isSoftLink && adpropertyDefinition.IsSoftLinkAttribute)
            {
                ldapDisplayName = adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName;
            }
            this.IncrementFilterSize();
            this.ldapFilter.Append("(");
            this.ldapFilter.Append(ldapDisplayName);
            this.ldapFilter.Append("=*)");
        }
Пример #21
0
 private static void GetByteConstraints(ADSchemaAttributeObject schemaObject, ADPropertyDefinition propDef, List <PropertyDefinitionConstraint> constraints)
 {
     if (propDef.Type == typeof(byte[]))
     {
         constraints.Add(new ByteArrayLengthConstraint(schemaObject.RangeLower ?? 0, schemaObject.RangeUpper ?? 0));
         return;
     }
     if (propDef.Type == typeof(string))
     {
         ADSchemaDataProvider.GetStringConstraints(schemaObject, propDef, constraints);
         return;
     }
     ExTraceGlobals.SchemaInitializationTracer.TraceDebug <DataSyntax, ADPropertyDefinition>(0L, "Unsupported property type '{1}' for data syntax '{0}'.", schemaObject.DataSyntax, propDef);
 }
Пример #22
0
        private void InitializeADObjectLinkProperties()
        {
            List <ADPropertyDefinition> list = new List <ADPropertyDefinition>();

            foreach (PropertyDefinition propertyDefinition in base.AllProperties)
            {
                ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
                if (adpropertyDefinition.Name != "HomeMTA" && adpropertyDefinition != null && adpropertyDefinition.Type == typeof(ADObjectId))
                {
                    list.Add(adpropertyDefinition);
                }
            }
            this.allADObjectLinkProperties = new ReadOnlyCollection <ADPropertyDefinition>(list.ToArray());
        }
Пример #23
0
 internal void ProvisionalClone(IPropertyBag source)
 {
     foreach (PropertyDefinition propertyDefinition in this.Schema.AllProperties)
     {
         ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
         if (adpropertyDefinition.IncludeInProvisionalClone && !adpropertyDefinition.IsReadOnly && !adpropertyDefinition.IsCalculated && !adpropertyDefinition.IsTaskPopulated)
         {
             object obj = source[adpropertyDefinition];
             if (obj != null && this[adpropertyDefinition] != obj && (!adpropertyDefinition.IsMultivalued || ((MultiValuedPropertyBase)obj).Count != 0))
             {
                 this[adpropertyDefinition] = obj;
             }
         }
     }
 }
Пример #24
0
        private void AddShadowPropertiesToAllPropertiesList()
        {
            HashSet <PropertyDefinition> hashSet = new HashSet <PropertyDefinition>();

            foreach (PropertyDefinition propertyDefinition in base.AllProperties)
            {
                hashSet.TryAdd(propertyDefinition);
                ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
                if (adpropertyDefinition != null && adpropertyDefinition.ShadowProperty != null)
                {
                    hashSet.TryAdd(adpropertyDefinition.ShadowProperty);
                }
            }
            base.AllProperties = new ReadOnlyCollection <PropertyDefinition>(hashSet.ToArray());
            base.InitializePropertyCollections();
        }
Пример #25
0
 private void GetPropertiesToUpdate(IList <PropertyDefinition> properties, out List <ADPropertyDefinition> propertiesToRead, out List <ADPropertyDefinition> propertiesToUpdate)
 {
     propertiesToRead   = new List <ADPropertyDefinition>(properties.Count);
     propertiesToUpdate = new List <ADPropertyDefinition>(properties.Count);
     for (int i = 0; i < properties.Count; i++)
     {
         ADPropertyDefinition adpropertyDefinition = properties[i] as ADPropertyDefinition;
         if (ADPropertyDefinition.CanHaveAutogeneratedConstraints(adpropertyDefinition) && ADSchemaDataProvider.IsKnownType(adpropertyDefinition.Type))
         {
             propertiesToUpdate.Add(adpropertyDefinition);
             if (!this.constraintDictionary.ContainsKey(ADSchemaDataProvider.PropertyKey.GetPropertyKey(adpropertyDefinition)))
             {
                 propertiesToRead.Add(adpropertyDefinition);
             }
         }
     }
 }
        // Token: 0x06000DDB RID: 3547 RVA: 0x00040790 File Offset: 0x0003E990
        private void ConvertTextFilter(TextFilter textFilter)
        {
            if (textFilter.Property.Type.IsEnum)
            {
                throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperatorForProperty(textFilter.Property.Name, "LIKE"));
            }
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)textFilter.Property;
            string ldapDisplayName = adpropertyDefinition.LdapDisplayName;

            this.IncrementFilterSize();
            this.ldapFilter.Append("(");
            this.ldapFilter.Append(ldapDisplayName);
            this.ldapFilter.Append("=");
            switch (textFilter.MatchOptions)
            {
            case MatchOptions.FullString:
                ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0);
                this.ldapFilter.Append(")");
                return;

            case MatchOptions.SubString:
                this.ldapFilter.Append("*");
                ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0);
                this.ldapFilter.Append("*)");
                return;

            case MatchOptions.Prefix:
                ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0);
                this.ldapFilter.Append("*)");
                return;

            case MatchOptions.Suffix:
                this.ldapFilter.Append("*");
                ADValueConvertor.ConvertToAndAppendFilterString(adpropertyDefinition, textFilter.Text, this.ldapFilter, false, 0);
                this.ldapFilter.Append(")");
                return;

            case MatchOptions.WildcardString:
                ADValueConvertor.EscapeAndAppendString(textFilter.Text, this.ldapFilter, true);
                this.ldapFilter.Append(")");
                return;
            }
            throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedTextFilterOption(textFilter.MatchOptions.ToString()));
        }
        // Token: 0x0600103A RID: 4154 RVA: 0x0004EB34 File Offset: 0x0004CD34
        public static DirectoryAttribute GetRangedPropertyValue(ADPropertyDefinition propertyDefinition, SearchResultAttributeCollection attributeCollection, out IntRange returnedRange)
        {
            DirectoryAttribute result = null;

            returnedRange = null;
            string   text;
            IntRange propertyRangeFromLdapName = RangedPropertyHelper.GetPropertyRangeFromLdapName(propertyDefinition.LdapDisplayName, out text);

            if (attributeCollection.Contains(propertyDefinition.LdapDisplayName))
            {
                returnedRange = propertyRangeFromLdapName;
                result        = attributeCollection[propertyDefinition.LdapDisplayName];
            }
            else
            {
                string attributeNameWithRange = ADSession.GetAttributeNameWithRange(text, propertyRangeFromLdapName.LowerBound.ToString(), "*");
                if (attributeCollection.Contains(attributeNameWithRange))
                {
                    returnedRange = new IntRange(propertyRangeFromLdapName.LowerBound, int.MaxValue);
                    result        = attributeCollection[attributeNameWithRange];
                }
                else
                {
                    string value = string.Format(CultureInfo.InvariantCulture, "{0};{1}{2}-", new object[]
                    {
                        text,
                        "range=",
                        propertyRangeFromLdapName.LowerBound
                    });
                    foreach (object obj in attributeCollection.AttributeNames)
                    {
                        string text2 = (string)obj;
                        if (text2.StartsWith(value, StringComparison.OrdinalIgnoreCase))
                        {
                            result        = attributeCollection[text2];
                            returnedRange = RangedPropertyHelper.GetPropertyRangeFromLdapName(text2, out text);
                        }
                    }
                }
            }
            return(result);
        }
Пример #28
0
        internal virtual void StampPersistableDefaultValues()
        {
            object obj = new object();

            foreach (PropertyDefinition propertyDefinition in this.Schema.AllProperties)
            {
                ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
                if (adpropertyDefinition.DefaultValue != null && !adpropertyDefinition.IsReadOnly && adpropertyDefinition.PersistDefaultValue && !this.ExchangeVersion.IsOlderThan(adpropertyDefinition.VersionAdded) && !this.propertyBag.TryGetField(adpropertyDefinition, ref obj))
                {
                    this[adpropertyDefinition] = adpropertyDefinition.DefaultValue;
                }
            }
            ADLegacyVersionableObject adlegacyVersionableObject = this as ADLegacyVersionableObject;

            if (adlegacyVersionableObject != null)
            {
                adlegacyVersionableObject.StampDefaultMinAdminVersion();
            }
            this.SetObjectClass(this.MostDerivedObjectClass);
        }
Пример #29
0
 public static SetterDelegate RawStringSetter <TConverted>(ADPropertyDefinition rawPropertyDefinition)
 {
     if (!rawPropertyDefinition.IsMultivalued)
     {
         throw new NotImplementedException("RawStringSetter is only currently implemented for multi-valued properties.");
     }
     return(delegate(object value, IPropertyBag bag)
     {
         MultiValuedProperty <TConverted> multiValuedProperty = (MultiValuedProperty <TConverted>)value;
         MultiValuedProperty <string> multiValuedProperty2 = null;
         if (multiValuedProperty != null && multiValuedProperty.Count != 0)
         {
             multiValuedProperty2 = new MultiValuedProperty <string>();
             foreach (TConverted tconverted in multiValuedProperty)
             {
                 multiValuedProperty2.Add(ADValueConvertor.ConvertValueToString(tconverted, rawPropertyDefinition.FormatProvider));
             }
         }
         bag[rawPropertyDefinition] = multiValuedProperty2;
     });
 }
Пример #30
0
 private void AddPropertyToDictionary(Dictionary <string, ADPropertyDefinition> allPropertiesDictionary, ADPropertyDefinition adPropertyDefinition)
 {
     if (string.IsNullOrEmpty(adPropertyDefinition.LdapDisplayName) || adPropertyDefinition.IsCalculated)
     {
         if (adPropertyDefinition.IsCalculated && adPropertyDefinition.SupportingProperties != null)
         {
             foreach (ProviderPropertyDefinition providerPropertyDefinition in adPropertyDefinition.SupportingProperties)
             {
                 ADPropertyDefinition adPropertyDefinition2 = (ADPropertyDefinition)providerPropertyDefinition;
                 this.AddPropertyToDictionary(allPropertiesDictionary, adPropertyDefinition2);
             }
         }
         return;
     }
     if (!allPropertiesDictionary.ContainsKey(adPropertyDefinition.LdapDisplayName))
     {
         allPropertiesDictionary.Add(adPropertyDefinition.LdapDisplayName, adPropertyDefinition);
         return;
     }
     ADPropertyDefinition adpropertyDefinition = allPropertiesDictionary[adPropertyDefinition.LdapDisplayName];
 }