internal Claim GetClaimFromLdapAttributes(LdapEntry user, string claim, LdapAttributes ldapAttribute) { string value = string.Empty; try { value = user.getAttribute(ldapAttribute.ToDescriptionString()).StringValue; return(new Claim(claim, value)); } catch (Exception) { // Should do something... But basically the attribute is not found // We swallow for now, since we might not care. } return(new Claim(claim, value)); }
public static string ToDescriptionString(this LdapAttributes val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }