Represents the definition of a specific matching rule use in the directory schema. The LdapMatchingRuleUseSchema class represents the definition of a matching rule use. It is used to discover or modify which attributes are suitable for use with an extensible matching rule. It contains the name and identifier of a matching rule, and a list of attributes which it applies to.
Наследование: LdapSchemaElement
Пример #1
0
        /// <summary>
        ///     Constructs an LdapSchema object from attributes of an LdapEntry.
        ///     The object is empty if the entry parameter contains no schema
        ///     attributes.  The recognized schema attributes are the following:
        ///     <pre>
        ///         <code>
        /// "attributeTypes", "objectClasses", "ldapSyntaxes",
        /// "nameForms", "dITContentRules", "dITStructureRules",
        /// "matchingRules","matchingRuleUse"
        /// </code>
        ///     </pre>
        /// </summary>
        /// <param name="ent">
        ///     An LdapEntry containing schema information.
        /// </param>
        public LdapSchema(LdapEntry ent) : base(ent.DN, ent.getAttributeSet())
        {
            InitBlock();
            //reset all definitions
            for (var i = 0; i < schemaTypeNames.Length; i++)
            {
                idTable[i]   = new Hashtable();
                nameTable[i] = new Hashtable();
            }
            var itr = getAttributeSet().GetEnumerator();

            while (itr.MoveNext())
            {
                var    attr = (LdapAttribute)itr.Current;
                string value_Renamed, attrName = attr.Name;
                var    enumString = attr.StringValues;

                if (attrName.ToUpper().Equals(schemaTypeNames[OBJECT_CLASS].ToUpper()))
                {
                    LdapObjectClassSchema classSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed = (string)enumString.Current;
                        try
                        {
                            classSchema = new LdapObjectClassSchema(value_Renamed);
                        }
                        catch (Exception e)
                        {
                            Logger.Log.LogWarning("Exception swallowed", e);
                            continue; //Error parsing: do not add this definition
                        }
                        addElement(OBJECT_CLASS, classSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[ATTRIBUTE].ToUpper()))
                {
                    LdapAttributeSchema attrSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed = (string)enumString.Current;
                        try
                        {
                            attrSchema = new LdapAttributeSchema(value_Renamed);
                        }
                        catch (Exception e)
                        {
                            Logger.Log.LogWarning("Exception swallowed", e);
                            continue; //Error parsing: do not add this definition
                        }
                        addElement(ATTRIBUTE, attrSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[SYNTAX].ToUpper()))
                {
                    LdapSyntaxSchema syntaxSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed = (string)enumString.Current;
                        syntaxSchema  = new LdapSyntaxSchema(value_Renamed);
                        addElement(SYNTAX, syntaxSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[MATCHING].ToUpper()))
                {
                    LdapMatchingRuleSchema matchingRuleSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed      = (string)enumString.Current;
                        matchingRuleSchema = new LdapMatchingRuleSchema(value_Renamed, null);
                        addElement(MATCHING, matchingRuleSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[MATCHING_USE].ToUpper()))
                {
                    LdapMatchingRuleUseSchema matchingRuleUseSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed         = (string)enumString.Current;
                        matchingRuleUseSchema = new LdapMatchingRuleUseSchema(value_Renamed);
                        addElement(MATCHING_USE, matchingRuleUseSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[DITCONTENT].ToUpper()))
                {
                    LdapDITContentRuleSchema dITContentRuleSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed        = (string)enumString.Current;
                        dITContentRuleSchema = new LdapDITContentRuleSchema(value_Renamed);
                        addElement(DITCONTENT, dITContentRuleSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[DITSTRUCTURE].ToUpper()))
                {
                    LdapDITStructureRuleSchema dITStructureRuleSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed          = (string)enumString.Current;
                        dITStructureRuleSchema = new LdapDITStructureRuleSchema(value_Renamed);
                        addElement(DITSTRUCTURE, dITStructureRuleSchema);
                    }
                }
                else if (attrName.ToUpper().Equals(schemaTypeNames[NAME_FORM].ToUpper()))
                {
                    LdapNameFormSchema nameFormSchema;
                    while (enumString.MoveNext())
                    {
                        value_Renamed  = (string)enumString.Current;
                        nameFormSchema = new LdapNameFormSchema(value_Renamed);
                        addElement(NAME_FORM, nameFormSchema);
                    }
                }
                //All non schema attributes are ignored.
            }
        }
        /// <summary>
        ///     Constructs an LdapSchema object from attributes of an LdapEntry.
        ///     The object is empty if the entry parameter contains no schema
        ///     attributes.  The recognized schema attributes are the following:.
        ///     <pre>
        ///         <code>
        /// "attributeTypes", "objectClasses", "ldapSyntaxes",
        /// "nameForms", "dITContentRules", "dITStructureRules",
        /// "matchingRules","matchingRuleUse"
        /// </code>
        ///     </pre>
        /// </summary>
        /// <param name="ent">
        ///     An LdapEntry containing schema information.
        /// </param>
        public LdapSchema(LdapEntry ent)
            : base(ent.Dn, ent.GetAttributeSet())
        {
            _nameTable = new Hashtable[8];
            _idTable   = new Hashtable[8];

            // reset all definitions
            for (var i = 0; i < SchemaTypeNames.Length; i++)
            {
                _idTable[i]   = new Hashtable();
                _nameTable[i] = new Hashtable();
            }

            var itr = GetAttributeSet().GetEnumerator();

            while (itr.MoveNext())
            {
                var    attr = (LdapAttribute)itr.Current;
                string valueRenamed, attrName = attr.Name;
                var    enumString = attr.StringValues;

                if (attrName.EqualsOrdinalCI(SchemaTypeNames[ObjectClass]))
                {
                    LdapObjectClassSchema classSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed = (string)enumString.Current;
                        try
                        {
                            classSchema = new LdapObjectClassSchema(valueRenamed);
                        }
                        catch (Exception e)
                        {
                            Logger.Log.LogWarning("Exception swallowed", e);
                            continue; // Error parsing: do not add this definition
                        }

                        AddElement(ObjectClass, classSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[Attribute]))
                {
                    LdapAttributeSchema attrSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed = (string)enumString.Current;
                        try
                        {
                            attrSchema = new LdapAttributeSchema(valueRenamed);
                        }
                        catch (Exception e)
                        {
                            Logger.Log.LogWarning("Exception swallowed", e);
                            continue; // Error parsing: do not add this definition
                        }

                        AddElement(Attribute, attrSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[Syntax]))
                {
                    LdapSyntaxSchema syntaxSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed = (string)enumString.Current;
                        syntaxSchema = new LdapSyntaxSchema(valueRenamed);
                        AddElement(Syntax, syntaxSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[Matching]))
                {
                    LdapMatchingRuleSchema matchingRuleSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed       = (string)enumString.Current;
                        matchingRuleSchema = new LdapMatchingRuleSchema(valueRenamed, null);
                        AddElement(Matching, matchingRuleSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[MatchingUse]))
                {
                    LdapMatchingRuleUseSchema matchingRuleUseSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed          = (string)enumString.Current;
                        matchingRuleUseSchema = new LdapMatchingRuleUseSchema(valueRenamed);
                        AddElement(MatchingUse, matchingRuleUseSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[Ditcontent]))
                {
                    LdapDitContentRuleSchema dItContentRuleSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed         = (string)enumString.Current;
                        dItContentRuleSchema = new LdapDitContentRuleSchema(valueRenamed);
                        AddElement(Ditcontent, dItContentRuleSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[Ditstructure]))
                {
                    LdapDitStructureRuleSchema dItStructureRuleSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed           = (string)enumString.Current;
                        dItStructureRuleSchema = new LdapDitStructureRuleSchema(valueRenamed);
                        AddElement(Ditstructure, dItStructureRuleSchema);
                    }
                }
                else if (attrName.EqualsOrdinalCI(SchemaTypeNames[NameForm]))
                {
                    LdapNameFormSchema nameFormSchema;
                    while (enumString.MoveNext())
                    {
                        valueRenamed   = (string)enumString.Current;
                        nameFormSchema = new LdapNameFormSchema(valueRenamed);
                        AddElement(NameForm, nameFormSchema);
                    }
                }

                // All non schema attributes are ignored.
            }
        }
Пример #3
0
		/// <summary> Constructs an LdapSchema object from attributes of an LdapEntry.
		/// The object is empty if the entry parameter contains no schema
		/// attributes.  The recognized schema attributes are the following: 
		/// <pre><code>
		/// "attributeTypes", "objectClasses", "ldapSyntaxes",
		/// "nameForms", "dITContentRules", "dITStructureRules",
		/// "matchingRules","matchingRuleUse"
		/// </code></pre>
		/// </summary>
		/// <param name="ent">         An LdapEntry containing schema information.
		/// </param>
		public LdapSchema(LdapEntry ent):base(ent.DN, ent.getAttributeSet())
		{
			InitBlock();
			//reset all definitions
			for (int i = 0; i < schemaTypeNames.Length; i++)
			{
				idTable[i] = new System.Collections.Hashtable();
				nameTable[i] = new System.Collections.Hashtable();
			}
			System.Collections.IEnumerator itr = base.getAttributeSet().GetEnumerator();
			while (itr.MoveNext())
			{
				
				LdapAttribute attr = (LdapAttribute) itr.Current;
				System.String value_Renamed, attrName = attr.Name;
				System.Collections.IEnumerator enumString = attr.StringValues;
				
				if (attrName.ToUpper().Equals(schemaTypeNames[OBJECT_CLASS].ToUpper()))
				{
					LdapObjectClassSchema classSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						try
						{
							classSchema = new LdapObjectClassSchema(value_Renamed);
						}
						catch (System.Exception e)
						{
							continue; //Error parsing: do not add this definition
						}
						addElement(OBJECT_CLASS, classSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[ATTRIBUTE].ToUpper()))
				{
					LdapAttributeSchema attrSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						try
						{
							attrSchema = new LdapAttributeSchema(value_Renamed);
						}
						catch (System.Exception e)
						{
							continue; //Error parsing: do not add this definition
						}
						addElement(ATTRIBUTE, attrSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[SYNTAX].ToUpper()))
				{
					LdapSyntaxSchema syntaxSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						syntaxSchema = new LdapSyntaxSchema(value_Renamed);
						addElement(SYNTAX, syntaxSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[MATCHING].ToUpper()))
				{
					LdapMatchingRuleSchema matchingRuleSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						matchingRuleSchema = new LdapMatchingRuleSchema(value_Renamed, null);
						addElement(MATCHING, matchingRuleSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[MATCHING_USE].ToUpper()))
				{
					LdapMatchingRuleUseSchema matchingRuleUseSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						matchingRuleUseSchema = new LdapMatchingRuleUseSchema(value_Renamed);
						addElement(MATCHING_USE, matchingRuleUseSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[DITCONTENT].ToUpper()))
				{
					LdapDITContentRuleSchema dITContentRuleSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						dITContentRuleSchema = new LdapDITContentRuleSchema(value_Renamed);
						addElement(DITCONTENT, dITContentRuleSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[DITSTRUCTURE].ToUpper()))
				{
					LdapDITStructureRuleSchema dITStructureRuleSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						dITStructureRuleSchema = new LdapDITStructureRuleSchema(value_Renamed);
						addElement(DITSTRUCTURE, dITStructureRuleSchema);
					}
				}
				else if (attrName.ToUpper().Equals(schemaTypeNames[NAME_FORM].ToUpper()))
				{
					LdapNameFormSchema nameFormSchema;
					while (enumString.MoveNext())
					{
						value_Renamed = ((System.String) enumString.Current);
						nameFormSchema = new LdapNameFormSchema(value_Renamed);
						addElement(NAME_FORM, nameFormSchema);
					}
				}
				//All non schema attributes are ignored.
				continue;
			}
		}