Posted: Mon Feb 25, 2008 1:29 pm Post subject: Lock User that did not log in for a specified period of time
Code:
report zexp_lock_user no standard page heading.title
***********************************************************
* Batch User Locking Tool
*
* This is freeware. Please read the terms of use.
* Written by Urs Rohner, Rohner IT Consulting & Engineering
*
* Contact Author: Urs Rohner
*
*
*history
* Vers Date Own Remark
* ---- ------------------ --- ----------------------------------
* 1.00 19th January 2001 rnr Initial version
* 1.05 15th February 2001 rnr Run Tagger over it
* 1.10 23rd May 2001 rnr changed docu
* 1.20 9th August 2001 rnr correct bug in function call interf.
*
***********************************************************
tables:
usr02.
data:
t_ type i.
* Selection Screen
select-options:
bname for usr02-bname.
parameters:
* mandt like usr02-mandt,
time type i default 60,
test as checkbox default 'X'.
form m_user_locked using
_u like usr02-bname " user name
_l type c. " lock state
data:
s_ like uslock.
call function 'SUSR_USER_LOCKSTATE_GET'
exporting user_name = _u
importing lockstate = s_
exceptions
user_name_not_exist = 1
others = 2.
if sy-subrc is initial.
case s_.
when 'UUU'. _l = 'U'. " unlocked
when 'LUU'. _l = 'L'. " locked by failed login
when 'ULU'. _l = 'A'. " locked by admin
when 'UUL'. _l = 'G'. " locked by global admin
when others. _l = '*'. " ?
endcase.
else.
_l = '?'.
endif.
endform.
form m_user_lock using
_u like usr02-bname.
data:
l_.
perform m_user_locked using _u l_.
case l_.
when 'U' or '*'.
call function 'SUSR_USER_LOCK'
exporting user_name = _u
exceptions
user_name_not_exist = 1
others = 2.
if sy-subrc is initial.
call function 'SUSR_USER_BUFFERS_TO_DB'
exceptions
no_logondata_for_new_user = 1
no_init_password = 2
db_insert_usr02_failed = 3
db_update_usr02_failed = 4
db_insert_usr01_failed = 5
db_update_usr01_failed = 6
db_insert_usr05_failed = 7
db_update_usr05_failed = 8
db_insert_usr21_failed = 9
db_update_usr21_failed = 10
internal_error = 11
others = 12.
endif.
endcase.
endform.
start-of-selection.
authority-check object 'S_ADMI_FCD' id 'S_ADMI_FCD' field '*'.
if not sy-subrc is initial.
message e208(00) with 'Permission denied'.
endif.
select * from usr02
where ustyp eq 'A' and uflag eq 0
and bname in bname.
if not usr02-trdat is initial.
if usr02-ustyp eq 'A'.
if usr02-uflag eq 0.
check usr02-bname ne: 'SAP*', 'DDIC', 'SAPCPIC'.
t_ = sy-datum - usr02-trdat.
if t_ ge time.
write: / usr02-bname, t_.
if test is initial.
perform m_user_lock using usr02-bname.
endif.
endif.
endif.
endif.
endif.
endselect.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.