Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
 private static bool AttrEquals(LdapAttribute attr, ATTRNAME name)
 {
     if (attr.Name.ToUpper().Equals(name.ToString()))
         return true;
     return false;
 }
Ejemplo n.º 4
0
 private static void MakeLdapMod(ATTRNAME attr, string attrVal)
 {
     attribute = new LdapAttribute( attr.ToString(), attrVal);
     modList.Add( new LdapModification(LdapModification.REPLACE, attribute)); //Add to the list of mods
 }