class LdapAuthenticateService {

    public void resetUserPassword(String token, String password) throws AcmUserActionFailedException
    {
        AcmUser user = userDao.findByPasswordResetToken(token);
        if (user == null)
        {
            throw new AcmUserActionFailedException("reset password", "USER", null, "User not found!", null);
        }
        LdapTemplate ldapTemplate = ldapDao.buildLdapTemplate(ldapAuthenticateConfig);
        try
        {
            log.debug("Changing password for user: [{}]", user.getUserId());

            ldapUserDao.changeUserPasswordWithAdministrator(user.getDistinguishedName(), password, ldapTemplate, ldapAuthenticateConfig);
        }
        catch (AcmLdapActionFailedException e)
        {
            throw new AcmUserActionFailedException("reset password", "USER", null, "Change password action failed!", e);
        }
        try
        {
            savePasswordExpirationDate(user, ldapTemplate);
            invalidateToken(user);
        }
        catch (AuthenticationException e)
        {
            log.warn("Password expiration date was not set for user [{}]", user.getUserId(), e);
        }
    }

}