ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 登陆SAP实现IP地址记录和绑定

登陆SAP实现IP地址记录和绑定

原创 Linux操作系统 作者:chouer523 时间:2019-07-19 18:24:02 0 删除 编辑

作用:

.登陆时候记录用户的IP地址等信息

.登陆时候与用户IP地址绑定登陆


登陆SAP实现IP地址记录和绑定


.登陆时候记录用户的IP地址等信息 首先在系统建立数据库表ZLOGONINFO记录用户登陆信息,包括信息(R/3用户名/终端名/IP地址/ 陆日期/登陆时间). 其次在R/3用户登陆增强(SUSR0001)写代码记录用户相关的信息到数据库表ZLOGONINFO,完成用户 登陆信息的记录 增强代码如下:
*----------------------------------------------------------------------
* INCLUDE ZXUSRU01
*----------------------------------------------------------------------
************************************************
* PROGRAM SAPMTZST *
* CREATED BY TXB, 10/18/2000 *
* LAST CHANGE BY TXB, 10/19/2000 *
* PURPOSE: DEMONSTRATION *
************************************************
DATA HOSTADR LIKE UINFO-HOSTADR.
DATA HOSTADDR(8).
DATA TERM LIKE UINFO-TERM.
DATA XHCOUNT TYPE I.
DATA: IPTXT(15),ITIMES TYPE I,ITIMES1 TYPE I,HX(2).
DATA: RESULT TYPE I,RESULTTXT(3).
TABLES ZLOGONINFO.
CALL FUNCTION 'TH_USER_INFO'
IMPORTING HOSTADDR = HOSTADR "like UINFO-HOSTADR (hex)

TERMINAL = TERM. "like UINFO-TERM
SELECT MAX( XH ) INTO XHCOUNT FROM ZLOGONINFO.
XHCOUNT = XHCOUNT + 1.
ZLOGONINFO-XH = XHCOUNT.
ZLOGONINFO-MANDT = SY-MANDT.
ZLOGONINFO-BNAME = SY-UNAME.
HOSTADDR = HOSTADR.
DO 4 TIMES.
HX = HOSTADDR+ITIMES1(2).
ITIMES = 0.
RESULT = 0.
DO 2 TIMES.
CASE HX+ITIMES(1).
WHEN 'A'.
IF ITIMES = 0.
RESULT = RESULT + 10 * 16.
ELSE.
RESULT = RESULT + 10.
ENDIF.
WHEN 'B'.
IF ITIMES = 0.
RESULT = RESULT + 11 * 16.
ELSE.
RESULT = RESULT + 11.
ENDIF.
WHEN 'C'.
IF ITIMES = 0.
RESULT = RESULT + 12 * 16.
ELSE.
RESULT = RESULT + 12.
ENDIF.
WHEN 'D'.
IF ITIMES = 0.
RESULT = RESULT + 13 * 16.
ELSE.
RESULT = RESULT + 13.
ENDIF.
WHEN 'E'.
IF ITIMES = 0.
RESULT = RESULT + 14 * 16.
ELSE.
RESULT = RESULT + 14.
ENDIF.
WHEN 'F'.
IF ITIMES = 0.
RESULT = RESULT + 15 * 16.
ELSE.
RESULT = RESULT + 15.
ENDIF.
WHEN OTHERS.
IF ITIMES = 0.
RESULT = RESULT + HX+ITIMES(1) * 16.
ELSE.
RESULT = RESULT + HX+ITIMES(1).
ENDIF.
ENDCASE.
ITIMES = ITIMES + 1.
ENDDO.
RESULTTXT = RESULT.
IF IPTXT <> ''.
CONCATENATE IPTXT '.' RESULTTXT INTO IPTXT.
ELSE.
IPTXT = RESULTTXT.
ENDIF.
ITIMES1 = ITIMES1 + 2.
ENDDO.
ZLOGONINFO-IP = IPTXT.
ZLOGONINFO-TERMINAL = TERM.
ZLOGONINFO-LOGON_DATE = SY-DATUM.
ZLOGONINFO-LOGON_TIME = SY-UZEIT.
INSERT INTO ZLOGONINFO CLIENT SPECIFIED VALUES ZLOGONINFO.
.登陆时候与用户IP地址绑定登陆 首先在系统里建立R/3用户和IP地址的对应的关系表USERLOGON,包括信息(R/3用户名/IP地址), 后通过批导入的方式将对应关系数据导入系统表里. 其次在R/3用户登陆增强(SUSR0001)写代码验证用户登陆时候的R/3用户名和IP地址在系统对应关 系表里是否有,通过则允许登陆,未通过则不允许登陆. 增强代码如下:
CALL FUNCTION 'TH_USER_INFO'
IMPORTING HOSTADDR = HOSTADR "like UINFO-HOSTADR (hex)
HOSTADDR = HOSTADR.
DO 4 TIMES.
HX = HOSTADDR+ITIMES1(2).
ITIMES = 0.
RESULT = 0.
DO 2 TIMES.
CASE HX+ITIMES(1).
WHEN 'A'.
IF ITIMES = 0.
RESULT = RESULT + 10 * 16.
ELSE.
RESULT = RESULT + 10.
ENDIF.
WHEN 'B'.
IF ITIMES = 0.
RESULT = RESULT + 11 * 16.
ELSE.
RESULT = RESULT + 11.
ENDIF.
WHEN 'C'.
IF ITIMES = 0.
RESULT = RESULT + 12 * 16.
ELSE.
RESULT = RESULT + 12.
ENDIF.
WHEN 'D'.
IF ITIMES = 0.
RESULT = RESULT + 13 * 16.
ELSE.
RESULT = RESULT + 13.
ENDIF.
WHEN 'E'.
IF ITIMES = 0.
RESULT = RESULT + 14 * 16.
ELSE.
RESULT = RESULT + 14.
ENDIF.
WHEN 'F'.
IF ITIMES = 0.
RESULT = RESULT + 15 * 16.
ELSE.
RESULT = RESULT + 15.
ENDIF.
WHEN OTHERS.
IF ITIMES = 0.
RESULT = RESULT + HX+ITIMES(1) * 16.
ELSE.
RESULT = RESULT + HX+ITIMES(1).
ENDIF.
ENDCASE.
ITIMES = ITIMES + 1.
ENDDO.
RESULTTXT = RESULT.
IF IPTXT <> ''.
CONCATENATE IPTXT '.' RESULTTXT INTO IPTXT.
ELSE.
IPTXT = RESULTTXT.
ENDIF.
ITIMES1 = ITIMES1 + 2.
ENDDO.
SELECT COUNT(*) INTO XHCOUNT FROM USERLOGON WHERE BNAME = SY-UNAME
AND IP = IPTXT.
IF XHCOUNT < 0.
MESSAGE I003(ZTXBHB).
CALL 'SYST_LOGOFF'."
退出SAP系统
ELSE.
MESSAGE I002(ZTXBHB).”
登陆
ENDIF.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/332542/viewspace-53552/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-03-28

  • 博文量
    74
  • 访问量
    47957