SAP LOGON DATA CHECK

时间:2022-05-06 06:41:38

之前有朋友做过RFC登录验证,后来群里又有很多人问SAP的登录验证函数。

后来自己找找了,看看了,然后改写了一个LOGON DATA CHECK。。。

FUNCTION ZUSER_CHECK_LOGON_DATA.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(BNAME) LIKE RSYST-BNAME DEFAULT SY-UNAME
*" VALUE(PASSWORD) LIKE RSYST-BCODE OPTIONAL
*" EXPORTING
*" VALUE(MESSAGE) TYPE STRING
*"----------------------------------------------------------------------
DATA: PWDSTATE TYPE XUPWDSTATE.
CALL 'INTERNET_USER_LOGON' ID 'AUTHTYPE' FIELD 'P' "password
ID 'TESTMODE' FIELD SPACE
ID 'UNAME' FIELD BNAME
ID 'PASSW' FIELD PASSWORD
ID 'PASSFLAG' FIELD PWDSTATE. CASE SY-SUBRC.
WHEN OR .
MESSAGE = 'Correct!'.
WHEN .
MESSAGE = 'user / password incorrect!'.
WHEN .
MESSAGE = 'user locked!'.
WHEN .
MESSAGE = 'STOP_SESSION!'.
WHEN .
MESSAGE = 'CUA master record!'.
WHEN .
MESSAGE = 'bad_user_type (not DIALOG type)!'.
WHEN .
MESSAGE = 'outside validity!'.
WHEN .
MESSAGE = 'SNC required!'.
WHEN .
MESSAGE = 'password disabled'.
WHEN .
MESSAGE = 'initial pwd expired'.
WHEN .
MESSAGE = 'user has no password!'.
WHEN .
MESSAGE = 'password will not be evaluated since there have been too many failed password logon attempts!'.
WHEN OTHERS.
ENDCASE. ENDFUNCTION.