Ah! thanks. I remembered I had two method back then.

/**
 * Updates an existing user
 * @param user the user with the profile attributes
 * @param generatePassword whether to generate password or not
 * @return the generatedPassword
 */
public String updateUser(User user,boolean generatePassword) {
  String generatedPassword=null;
  if(user.getPassword()!=null){
    generatedPassword = new String(user.getPassword());
  }
  String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
  AdminMgr adMgr = createAndGetAdminMgr();
  try {
    if(generatePassword){
      generatedPassword = generateRandomPassword();
      user.setPassword(generatedPassword.toCharArray());
    }
    adMgr.updateUser(user);
  } catch (SecurityException e) {
    logger.error("[" + methodName + "]" + "A system exception was
encountered while updating a user", e);
    throw new RuntimeException("Unable to update the user", e );
  }
  return generatedPassword;

}


On Fri, Dec 16, 2016 at 3:53 PM, Shawn <[email protected]> wrote:

> changePassword is for users to change their own password per pw policies.
> updateUser  (with new password set on password) or resetUser  (to force
> user to change password on next login) are probably what you are looking
> for.
> Shawn
> -------- Original message --------From: Ramandeep Singh Nanda <
> [email protected]> Date: 12/16/16  1:00 PM  (GMT-06:00) To:
> [email protected] Subject: Regarding changing user password
> [rc=modifications require authentication]
> Hi,
>
> As far as I remember admin users could change the password without
> authentication.
>
> AdminMgr mgr = createAndGetAdminMgr();
> User user = new User();
> try {
>   user.setUserId(userId);
>   user.setPassword(oldPassword.toCharArray());
>   mgr.changePassword(user, newPassword.toCharArray());
>
> }
>
> Now, I am getting the following exception.
>
> *Unable to change the password
> org.apache.directory.fortress.core.model.User.changePassword user
> [[email protected] <[email protected]>]  caught LDAPException rc=modifications require
> authentication*
>
> String methodName = Thread.currentThread().getStackTrace()[1].
> getMethodName();
> AdminMgr mgr = null;
> try {
>   mgr = AdminMgrFactory.createInstance(GlobalIds.HOME);
> }
>
>
>
>
> --
> Regards,
> Ramandeep Singh
> [email protected]
>



-- 
Regards,
Ramandeep Singh
http://ramannanda.blogspot.com
+13472849386
[email protected]

Reply via email to