getAttribute() public method

Returns the attribute matching the specified attrName. For example:
  • getAttribute("cn") returns only the "cn" attribute
  • getAttribute("cn;lang-en") returns only the "cn;lang-en" attribute.
In both cases, null is returned if there is no exact match to the specified attrName. Note: Novell eDirectory does not currently support language subtypes. It does support the "binary" subtype.
public getAttribute ( System attrName ) : LdapAttribute
attrName System The name of an attribute to retrieve, with or without /// subtype specifications. For example, "cn", "cn;phonetic", and /// "cn;binary" are valid attribute names. /// ///
return LdapAttribute
示例#1
0
        /// <summary>
        /// Returns the attribute value specified in the second string parameter
        /// 
        /// TODO: Need more error handling 
        /// </summary>
        /// <param name="entry">
        /// A <see cref="LdapEntry"/>
        /// </param>
        /// <param name="attr">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public static string getAttr(LdapAttributeSet attrSet, ATTRNAME attr)
        {
            string sAttr = attr.ToString();
            Logger.Debug("Requesting Attribute value of {0}", attrSet.getAttribute(sAttr));

            if (attrSet.getAttribute(sAttr) == null)
                return null;
            else {
                Logger.Debug(" Attribute {0} -> {1}", sAttr, attrSet.getAttribute(sAttr).StringValue);
                return attrSet.getAttribute(sAttr).StringValue;
            }
        }
示例#2
0
 /// <summary> Returns the attributes matching the specified attrName.
 ///
 /// </summary>
 /// <param name="attrName">The name of the attribute or attributes to return.
 ///
 /// </param>
 /// <returns> An array of LdapAttribute objects.
 /// </returns>
 public virtual LdapAttribute getAttribute(System.String attrName)
 {
     return(attrs.getAttribute(attrName));
 }
示例#3
0
        /// <summary>
        /// Returns null of no attributes match the attr parameter value
        /// Returns a list of strings that contain the attribute values that were specified in the attr param
        /// </summary>
        /// <param name="attrSet">
        /// A <see cref="LdapAttributeSet"/>
        /// </param>
        /// <param name="attr">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="List<System.String>"/>
        /// </returns>
        public static List<string> getListofAttr(LdapAttributeSet attrSet, ATTRNAME attr)
        {
            string sAttr = attr.ToString();
            if (attrSet.getAttribute(sAttr) == null)
                return null;

            List<string> values = null;
            System.Collections.IEnumerator ienum =  attrSet.GetEnumerator();

            while(ienum.MoveNext())
            {
                LdapAttribute attribute=(LdapAttribute)ienum.Current;
                if (AttrEquals(attribute, attr)) {
                    values = new List<string>(attrSet.getAttribute(sAttr).StringValueArray.Length);
                    values.AddRange(attrSet.getAttribute(sAttr).StringValueArray); // take the values from the array

                    if (Logger.LogLevel == Level.DEBUG) {
                        foreach (string x in values) //debug purposes
                        Logger.Debug("Values in {0} list {1}", attr, x);
                    }
                }
            }
            return values;
        }