Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reset Password with BAPI_USER_CHANGE, but without user being forced to change it

former_member449168
Participant
0 Kudos

Hi

I'm calling BAPI_USER_CHANGE to update a User's password to a self generated password.

Is it possible to 'lock' the user + password, so that the user is not prompted to enter a new password when he logs in for the first time?

I'm populating the params:

USERNAME

PASSWORD

PASSWORDX

1 ACCEPTED SOLUTION

0 Kudos

hi,

You should use the flag field PRODUCTIVE_PWD.

best regards,

Laura

6 REPLIES 6

Former Member
0 Kudos

Hi Andre

It's been a while since I used this but give it a try, I believe this will then not force the password change the next time the user logs in,

" Now change the Password.

  CALL FUNCTION 'SUSR_USER_CHANGE_PASSWORD_RFC'

    EXPORTING

      BNAME                           = lv_user

      PASSWORD                        = iv_old_password

      NEW_PASSWORD                    = iv_new_password

      USE_NEW_EXCEPTION               = 1

   EXCEPTIONS

      CHANGE_NOT_ALLOWED              = 1

      PASSWORD_NOT_ALLOWED            = 2

      INTERNAL_ERROR                  = 3

      CANCELED_BY_USER                = 4

      PASSWORD_ATTEMPTS_LIMITED       = 5

      OTHERS                          = 6.

   " If no Errors - Then Password is correct

   if sy-subrc = 0.

      ev_pwchange_ok = 'X'.

      return.

   else.

      CASE SY-SUBRC.

           WHEN 1.

              ev_return = 'PASSWORD_CHANGE_NOT_PERMITTED'.

           WHEN 2.

              ev_return = 'NEW_PASSWORD_NOT_PERMITTED'.

           WHEN OTHERS.

              ev_return = 'ERROR_WITH_PASSWORD_CHANGE'.

        ENDCASE.

     ENDIF.

Regards

Arden

0 Kudos

hi,

You should use the flag field PRODUCTIVE_PWD.

best regards,

Laura

Former Member
0 Kudos

Hi,

You have to update the last logon time in USR02-LTIME table so that system thinks you have already logged on once.

WE can do that via the same BAPI pass  LOGONDATA-LTIME to a non initial value.

Please note you may have to call the BAPI twice. First for updating the password and then update the LTIME. You can check this in your code.

R

0 Kudos

Thanks - but it seems like BAPI_USER_CHANGE does not have a Export param LOGONDATA-LTIME.

Alternatively I must update USR02 without using this BAPI.

0 Kudos

It does actually. Please see the screenshot. Not sure which version you are in but I recall using it 4.6C and if I am not wrong it was there too as I used for this same reason.

0 Kudos

Hmm, I see.  I was looking at the details from SAP ABAP Function Module BAPI_USER_CHANGE - SAP Datasheet - The Best Run SAP Run SAPDatasheet

My code also gives an error that the param does not exist.  Will play around some more - thanks!!