예제 #1
0
        public static List <string> GetStringListAttribute(this LdapEntry entry, LdapAttr attr)
        {
            List <string> list = entry.getAttribute(attr.LdapName)?.StringValueArray.ToList();

            if ((list == null || list.Count == 0) && !attr.Optional)
            {
                throw new LdapMandatoryAttributeMissingException(attr.LdapName, entry.DN);
            }

            return(list ?? new List <string>());
        }
예제 #2
0
        public static DateTime?GetDateTimeAttribute(this LdapEntry entry, LdapAttr attr)
        {
            var val = entry.GetAttribute(attr);

            if (val == null && attr.Optional)
            {
                return(null);
            }

            return(DateTime.ParseExact(entry.GetAttribute(attr), LdapConstants.DateFormat,
                                       CultureInfo.InvariantCulture));
        }
예제 #3
0
        public static LdapAttributeSet Add(this LdapAttributeSet set, LdapAttr attr, object value)
        {
            var ldapAttribute = attr.CreateLdapAttribute(value);

            if (value == null)
            {
                return(set);
            }

            if (ldapAttribute != null)
            {
                set.Add(ldapAttribute);
            }
            return(set);
        }
예제 #4
0
        public static int?GetIntAttribute(this LdapEntry entry, LdapAttr attr)
        {
            var strVal = entry.GetAttribute(attr);

            return(strVal == null ? null : (int?)int.Parse(strVal));
        }
예제 #5
0
        public static bool?GetBoolAttribute(this LdapEntry entry, LdapAttr attr)
        {
            var strVal = entry.GetAttribute(attr);

            return(strVal == null ? null : (bool?)(strVal == "TRUE"));
        }
예제 #6
0
 public static string GetAttribute(this LdapEntry entry, LdapAttr attr)
 {
     return(entry.GetAttribute(attr.LdapName, attr.Optional));
 }