Skip to Content
0
Jun 12, 2006 at 09:18 PM

Java App - Change Password Error

56 Views

Hi,

I've developed a component for simple password change, but I'm getting an UMRuntimeException (Maint method setAttribute cannot be used because the principal is not mutable!) when calling the method "<b>setPassword</b>" of "<b>com.sap.security.api.IUserAccount</b>". The object is really not mutable (i've checked when debugging), but how can I get the mutable account?

There goes the code:

String old_password = //get field value from request...
String new_password = //get field value from request...

try{
  IUserFactory ufact = UMFactory.getUserFactory();
  IUserMaint user = null;
  IUserAccount[] userAccount = null;

  try {
    user = ufact.getMutableUser(request.getUser().getUniqueID());
  } catch (UMException e) {
    //error handling...
  }

  try {
    userAccount = user.getUserAccounts();
  } catch (UMException e) {
    //error handling...
  }

  for (int i = 0; i < userAccount.length; i++) {
    if (userAccount<i>.checkPassword(old_password)) {
      try {
        userAccount<i>.setPassword(old_password, new_password);
        userAccount<i>.commit();
      } catch (InvalidPasswordException e) {
        //error handling...
      }
    } else {
      //error handling...
    }

  }
}catch(UMException umex){
  //error handling...
}catch(Throwable t){
  //error handling (!!!)...
  //here the exception is thrown!
}

Any suggestion is appreciated.

Thanks in advance.

Raphael Barboza