Hi,

The getAllAttributeValues method of LdapUtils throws a ClassCastException
if it encounters binary data.  I created a copy of this method and modified
as follows:


    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()) {
                Object vObj = ne.next();
                try {
                    String value = (String) vObj;
                    values.add(value);
                } catch (ClassCastException e) {
                   log.debug("Ignoring a class cast exception for binary
type");
                }
            }
        } finally {
            closeEnumeration(ne);
        }

        return values;
    }

How have other people solved this problem?  Can you specify a filter on the
search to only return attributes with string values (my current filter is
objectclass=* for a specific DN)?

Cheers,

Stuart

Reply via email to