I have an attribute in my LDAP server that contains special characters like letters with accents.
This is my code to recover that attribute:
public class LdapUser implements AttributesMapper {
@Override public Object mapFromAttributes(Attributes attributes) throws NamingException{
if(attributes == null)
return null;
Presenter presenter = new Presenter();
if(attributes.get("cn") != null)
presenter.setFullName(attributes.get("cn").get().toString());
if(attributes.get("uid") != null)
presenter.setId(attributes.get("uid") .get().toString());
return presenter;
}
}
The problem is that in Java the value of the cn attribute is:
With values:
There is some way to set the character encoding to recover ldap attributes?
Thanks in advance!
env.put('java.naming.ldap.version', '3');
and set spring charset toUTF-8
it should work. - EricLavault