String password = (String) auth.getCredentials();
DistinguishedName dn = new DistinguishedName(nameAttrName + "=" + userName);
String ldapPassword = null;
try {
ldapPassword = (String) ldapTemplate.lookup(dn, new String[] { "userPassword" },
new ContextMapper() {
public Object mapFromContext(Object ctx) {
DirContextAdapter context = (DirContextAdapter) ctx;
return new String((byte[]) context.getObjectAttribute("userPassword"));
}
});