Пример #1
0
        public LdapAttributeType[] GetAttributesForClass(string objectClassName)
        {
            List <LdapAttributeType> result = new List <LdapAttributeType>();
            string className = objectClassName;

            while (!string.IsNullOrEmpty(className))
            {
                LdapClassType classType = this.GetSchemaTypeByDisplayName(className) as LdapClassType;
                if (classType == null)
                {
                    className = null;
                    break;
                }

                if (classType.MandatoryAttributes != null)
                {
                    foreach (string attr in classType.MandatoryAttributes)
                    {
                        SchemaType attrSchemaType = this.GetSchemaTypeByDisplayName(attr);
                        if (attrSchemaType != null)
                        {
                            attrSchemaType.AttributeType = "Mandatory";
                            LdapAttributeType attrLdapAttributeType = attrSchemaType as LdapAttributeType;
                            result.Add(attrLdapAttributeType);
                        }
                    }
                }

                if (classType.OptionalAttributes != null)
                {
                    foreach (string attr in classType.OptionalAttributes)
                    {
                        SchemaType attrSchemaType = this.GetSchemaTypeByDisplayName(attr);
                        if (attrSchemaType != null)
                        {
                            attrSchemaType.AttributeType = "Optional";
                            LdapAttributeType attrLdapAttributeType = attrSchemaType as LdapAttributeType;
                            result.Add(attrLdapAttributeType);
                        }
                    }
                }

                className = classType.SuperClassName;
            }

            if (result.Count > 0)
            {
                return(result.ToArray());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public void reportSchemaCache(Logger.LogLevel logLevel)
        {
            if (logLevel > Logger.currentLogLevel)
            {
                return;
            }

            foreach (KeyValuePair <string, SchemaType> entry in _attrTypeLookup)
            {
                string            key        = entry.Key as string;
                LdapAttributeType schemaType = entry.Value as LdapAttributeType;
                if (schemaType != null)
                {
                    Logger.Log("Attribute Key = " + key, logLevel);
                    Logger.Log("    SchemaType::CName      = " + schemaType.CName, logLevel);
                    Logger.Log("              ::AttrSyntax = " + schemaType.AttributeSyntax, logLevel);
                    Logger.Log("              ::DataTypa   = " + schemaType.DataType, logLevel);
                    Logger.Log("              ::AttributeDisplayName   = " + schemaType.AttributeDisplayName, logLevel);
                }
            }
            foreach (KeyValuePair <string, SchemaType> entry in _classTypeLookup)
            {
                string        key        = entry.Key as string;
                LdapClassType schemaType = entry.Value as LdapClassType;
                if (schemaType != null)
                {
                    Logger.Log("Class Key = " + key, logLevel);
                    Logger.Log("    SchemaType::CName      = " + schemaType.CName, logLevel);
                    Logger.Log("              ::AttrSyntax = " + schemaType.AttributeSyntax, logLevel);
                    Logger.Log("              ::DataTypa   = " + schemaType.DataType, logLevel);
                    Logger.Log("              ::AttributeDisplayName   = " + schemaType.AttributeDisplayName, logLevel);
                }
            }

            foreach (KeyValuePair <string, SchemaType> entry in _dnTypeLookup)
            {
                string     key        = entry.Key as string;
                SchemaType schemaType = entry.Value as SchemaType;
                if (schemaType != null)
                {
                    Logger.Log("Display Name Key = " + key, logLevel);
                    Logger.Log("    SchemaType::CName      = " + schemaType.CName, logLevel);
                    Logger.Log("              ::AttrSyntax = " + schemaType.AttributeSyntax, logLevel);
                    Logger.Log("              ::DataTypa   = " + schemaType.DataType, logLevel);
                    Logger.Log("              ::AttributeDisplayName   = " + schemaType.AttributeDisplayName, logLevel);
                }
            }
        }
Пример #3
0
        protected bool AddAttributeSchemaType(AttributeMap attribute_map)
        {
            LdapValue[] ldapvalues = getFirstValue(attribute_map, CN_TAG);
            string      cName      = null;

            if (ldapvalues != null && ldapvalues.Length > 0)
            {
                cName = ldapvalues[0].stringData;
            }

            ldapvalues = getFirstValue(attribute_map, ATTR_SYNTAX_TAG);
            string attributeSyntax = null;

            if (ldapvalues != null && ldapvalues.Length > 0)
            {
                attributeSyntax = ldapvalues[0].stringData;
            }

            ldapvalues = getFirstValue(attribute_map, IS_SINGLE_VALUED_TAG);
            string isSingleValued = null;

            if (ldapvalues != null && ldapvalues.Length > 0)
            {
                isSingleValued = ldapvalues[0].stringData;
            }

            ldapvalues = getFirstValue(attribute_map, ATTR_DISPLAYNAME_TAG);
            string attributeDisplayName = null;

            if (ldapvalues != null && ldapvalues.Length > 0)
            {
                attributeDisplayName = ldapvalues[0].stringData;
            }


            if ((attributeSyntax == null) || (isSingleValued == null))
            {
                Logger.Log("Add one entry in schemacache failed", Logger.ldapLogLevel);
                return(false);
            }

            LdapAttributeType schemaType = new LdapAttributeType(cName, attributeSyntax, attributeDisplayName);

            schemaType.Tag = attribute_map;

            if (String.Compare(isSingleValued, "TRUE") == 0)
            {
                schemaType.IsSingleValued = true;
            }
            else
            {
                schemaType.IsSingleValued = false;
            }

            if (!_attrTypeLookup.ContainsKey(cName.ToLower()))
            {
                _attrTypeLookup.Add(cName.ToLower(), schemaType);
            }
            if (!_dnTypeLookup.ContainsKey(attributeDisplayName.ToLower()))
            {
                _dnTypeLookup.Add(attributeDisplayName.ToLower(), schemaType);
            }

            return(true);
        }