@Override
  public void setUserPassword(String username, String password) {
    for (LdapServer ldapServer : ldapServers) {
      try {
        ldapServer.setPassword(username, password);
        logger.debug(
            "Successfully set password for " + username + " at " + ldapServer.getDescription());
        return;
      } catch (NameNotFoundException ex) {
        logger.debug("Didn't find " + username + " in " + ldapServer.getDescription());
        // ignore... we'll try another server
      } catch (ObjectRetrievalException ex) {
        logger.debug("Multiple results found for " + username);
        // ignore it... try the next server
      }
    }

    logger.debug("Couldn't find server for " + username);
    throw new NameNotFoundException(
        "Couldn't find username " + username + " in any of provided servers.");
  }
  @Override
  public void changeUserPassword(String username, String oldPassword, String newPassword)
      throws UserLockedOutException {

    // throws UserLockedOutException if this isn't allowed
    lockoutService.allowAttempt(username);

    for (LdapServer ldapServer : ldapServers) {
      try {
        if (ldapServer.verifyPassword(username, oldPassword)) {
          ldapServer.setPassword(username, newPassword);
          logger.debug(
              "Successfully changed password for "
                  + username
                  + " at "
                  + ldapServer.getDescription());
          lockoutService.clearIncorrectAttempts(username);
          return;
        }
      } catch (AuthenticationException ex) {
        logger.debug("Didn't find " + username + " in " + ldapServer.getDescription());
        // ignore... we'll try another server
      } catch (NameNotFoundException ex) {
        logger.debug("Didn't find " + username + " in " + ldapServer.getDescription());
        // ignore... we'll try another server
      } catch (ObjectRetrievalException ex) {
        logger.debug("Multiple results found for " + username);
        // ignore it... try the next server
      }
    }

    lockoutService.registerIncorrectAttempt(username);
    logger.debug("Couldn't find server for " + username + " or bad password.");
    throw new NameNotFoundException(
        "Couldn't find username " + username + " in any of provided servers or bad password.");
  }