public static Collection<String> getAllAttributeValues(Attribute attr) throws NamingException {
        Set<String> values = new HashSet<String>();
        NamingEnumeration ne = null;
        try {
            ne = attr.getAll();
            while (ne.hasMore()) {
                String value = (String) ne.next();
                values.add(value);
            }
        } finally {
            closeEnumeration(ne);
        }

        return values;
    }
Helper method used to retrieve all attribute values from a particular context attribute.

@param attr the LDAP attribute.
@return the values of the attribute.
@throws javax.naming.NamingException if there is an LDAP error while reading the values.
core/src/main/java/org/apache/shiro/realm/ldap/LdapUtils.java