String userDnStr = "";
try {
ctx = getContextSource().getContext(username, password);
// Check for password policy control
PasswordPolicyControl ppolicy = PasswordPolicyControlExtractor
.extractControl(ctx);
logger.debug("Retrieving user object using filter...");
SearchControls searchCtls = new SearchControls();
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
user = SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx,
searchCtls, "", userFilter, new Object[] { username, originalUser });
userDnStr = user.getDn().toString();
if (ppolicy != null) {
user.setAttributeValue(ppolicy.getID(), ppolicy);
}
} catch (NamingException e) {
// This will be thrown if an invalid user name is used and the
// method may