*/
protected User recoverUserPassword(DirContext dirContext,
String username,
String emailAddress)
throws NamingException {
User userFound = null;
UsernamePasswordCredentials credentials = null;
username = Val.chkStr(username);
emailAddress = Val.chkStr(emailAddress);
if ((username.length() > 0) && (emailAddress.length() > 0)) {
LdapQueryFunctions queryFunctions = new LdapQueryFunctions(getConfiguration());
LdapUserProperties userProps = getConfiguration().getUserProperties();
boolean bMultipleFound = false;
String sBaseDN = userProps.getUserSearchDIT();
String sFilter = userProps.returnUserLoginSearchFilter(username);
StringSet ssDNs = queryFunctions.searchDNs(dirContext,sBaseDN,sFilter);
// loop through each DN found, check for an email address match
for (String sDN: ssDNs) {
User userTmp = new User();
userTmp.setDistinguishedName(sDN);
queryFunctions.readUserProfile(dirContext,userTmp);
if (userTmp.getProfile().getEmailAddress().equals(emailAddress)) {
if (userFound == null) {
credentials = new UsernamePasswordCredentials();
credentials.setUsername(username);
credentials.generatePassword();
userFound = userTmp;