10-27-2015 10:40 AM
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
10-27-2015 10:48 AM
hi,
You should use the flag field PRODUCTIVE_PWD.
best regards,
Laura
10-27-2015 10:46 AM
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
10-27-2015 10:48 AM
hi,
You should use the flag field PRODUCTIVE_PWD.
best regards,
Laura
10-27-2015 10:49 AM
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
10-27-2015 1:59 PM
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.
10-27-2015 2:05 PM
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.
10-27-2015 2:10 PM
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!!