SAP Jobsuche bei DV-Treff


Suchen
Max_SAP
  • Max_SAP
  • SAP Forum - User Thema Starter
vor ein Jahr
Hallo,

bitte gebt mir einen Tipp, wie ich in meinem Report den Kennwortstatus eines Users auslesen kann.

In der Transaktion RSUSR200 wird der Kennwortstatus mit "Produktivkennwort", "Initialkennwort" oder "Kennwort deaktiviert" sehr schön ausgelesen.

Welchen Funktionsbaustein oder BAPI kann ich verwenden, dass ich das in meinem Report auch verwenden kann?

Vielen Dank

LG Max

Shortcut IT GmbH
vor ein Jahr
Hallo,

die Info kannst du über Klasse CL_IDENTITY / Interface IF_IDENTITY_PASSWORD kriegen. Hier ein dahingeschmiertes Programm (leider bietet das Forum anscheinend keine Code-Formatierungs-Option - oder sehe ich die bloß nicht?)

===================

report z_pw_state.

data: f4Bname like usr02-bname.

select-options: sBname for f4Bname.

data: tBname type SUID_TT_BNAME.

select bname from usr02 into table @tBname

where bname in @sBname.

CALL METHOD cl_identity=>retrieve

EXPORTING

it_bname = tBname

IMPORTING

et_node_root = data(userNodes).

loop at userNodes reference into data(userNode).

userNode->idref->if_identity_password~get_password_state(

importing ev_password_state = data(pwState) ) .

write:/ userNode->bname.

case pwState.

when if_identity=>CO_PASSWORD_INACTIVE.

write at 15 'Password inactive'.

when if_identity=>CO_PASSWORD_INITIAL.

write at 15 'Password initial'.

when if_identity=>CO_PASSWORD_PRODUCTIVE.

write at 15 'Password productive'.

when if_identity=>CO_PASSWORD_ACTIVE.

write at 15 'Password active'.

when if_identity=>CO_PASSWORD_DEACTIVATED.

write at 15 'Password deactivated'.

endcase.

endloop.

===================

Viele Grüße

Shortcut IT

Max_SAP
  • Max_SAP
  • SAP Forum - User Thema Starter
vor ein Jahr
Vielen Dank für den tollen Tipp. Das muss ich sehr bald testen.

LG Max

Max_SAP
  • Max_SAP
  • SAP Forum - User Thema Starter
vor ein Jahr
Hallo Shortcut IT,

kann man diese Methode auch als RFC-Zugriff auf andere Systeme ausführen.

Ich müsste diese auf unserer zentralen Benutzerverwaltung verwenden.

Danke.

LG Max

Shortcut IT GmbH
vor ein Jahr
Hallo,

dafür müsstest du einen RFC-fähigen Funktionsbaustein entwickeln, der die Ermittlung des / der Passwort-Status enthält.

Wenn man sich die Ermittlung des Passwort-Status z.B. in RSUSR200 mal ansieht... das sieht schon alles irgendwie unschön und umständlich aus. Eine andere Möglichkeit wäre noch, das nicht nachzubauen sondern dem RSUSR200 im Zielsystem zu überlassen. Den Status des Passwortes würde man dann anhand des Icons der RSUSR200-Liste ermitteln. Auch nicht schön... Na ja, einen Tod muss man sterben, ich kenne keine wirklich schöne Möglichkeit für die Ermittlung des Passwort-Status.

So könnte der Funktionsbaustein aussehen (müsste dann natürlich in die Zielsysteme verteilt werden):

FUNCTION Z_RSUSR200_RFC

TABLES

ALVLIST TYPE SUSR_T_RSUSR200_ALV

EXCEPTIONS

ERROR_RETRIEVING_ALVLIST.

field-symbols type sim_t_rsusr200_alv.

data: rsusr200AlvList type ref to data,

alvLine type API_RSUSR200_ALV,

pwState type char30,

locked type c.

" Notify ALV to get data only, without displaying it.

cl_salv_bs_runtime_info=>set(

exporting display = abap_false

metadata = abap_false

data = abap_true ).

submit RSUSR200 and return.

try.

cl_salv_bs_runtime_info=>get_data_ref(

importing r_data = rsusr200AlvList ).

assign rsusr200AlvList->* TO .

catch cx_salv_bs_sc_runtime_info.

raise ERROR_RETRIEVING_ALVLIST.

endtry.

loop at reference into data(rsusr200AlvLine).

alvLine = corresponding #( rsusr200AlvLine->* ).

insert alvLine into table alvList.

endloop.

endfunction.

Und das wäre ein Testprogramm mit dem RFC-Aufruf und der Auswertung des Icons für den Passwort-Status.

REPORT z_rsusr200_rfc_test.

include .

data: rsusr200AlvList type SUSR_T_RSUSR200_ALV.

data: alvList type ref to data,

pwState type char30,

locked type c,

rfcDest type rfcdest value 'SAPQX1100'.

call function 'Z_RSUSR200_RFC' destination rfcDest

tables

alvList = rsusr200AlvList

EXCEPTIONS

ERROR_RETRIEVING_ALVLIST = 1 " Error retrieving list from RSUSR200

OTHERS = 2.

IF SY-SUBRC 0.

message 'Error retrieving result.' type 'E'.

ENDIF.

loop at rsusr200AlvList reference into data(alvLine).

clear locked.

case alvLine->icon_state.

when icon_deactivate. pwState = 'Password deactivated'.

when icon_alert. pwState = 'Initial password expired'.

when icon_cancel. pwState = 'Initial password'.

when icon_message_error_small. pwState = 'Productive password expired'.

when icon_okay. pwState = 'Production password'.

endcase.

if not alvLine->icon_locked is initial.

locked = 'Locked'.

endif.

write:/ alvLine->bname, alvLine->gltgv, alvLine->gltgb, pwState, locked, alvLine->lock_reason.

endloop.

Warum hat dieses Forum eigentlich keine Möglichkeiten zur Formatierung und zum Anhängen von Dateien?

Viele Grüße

Shortcut IT

Max_SAP
  • Max_SAP
  • SAP Forum - User Thema Starter
vor ein Jahr
Hallo,

vielen Dank für deinen Aufwand.

ja, dass die RSUSR200 das ebenfalls umständlich macht habe ich auch schon gesehen. :-)

Wir haben jedoch etwa 60 Systeme angehängt und daher bevorzuge ich Abstand zu nehmen von eigenen FuBa's, die ich auf die gesamten Systeme verteilen muss. Ich habe den Standard-FuBa gefunden, der zum Glück auf allen Systemen vorhanden ist und das Coding sieht wie folgt aus.

Vielleicht kannst du da einmal draufschaun, ob dir ein Fehler auffällt!? (Ich bin kein Programmierer mit jahrelanger Erfahrung).

**********************************************************************

* Kennwortstatus einlesen

**********************************************************************

CALL FUNCTION 'SUSR_USER_PASSWORD_STATUS_GET' DESTINATION ls_systems-zsystem

EXPORTING

username = ls_userlist-username

password_logon = p_p_log

* USE_BAPI_RETURN = ' '

IMPORTING

pwdstate = lv_pwdstate

* PWD_CHANGE_SSO =

* ALLOW_PWD_DELETION =

* ONLY_OLDSTYLE_PASSWORDS =

* RETURN_MESSAGE =

EXCEPTIONS

username_not_exists = 1

internal_error = 2

password_logon_disabled = 3

user_has_no_password = 4

not_authorized_for_other_user = 5

OTHERS = 6.

IF sy-subrc = 0.

**********************************************************************

* Werte der User-Kennwort-Status in Texte umwandeln

**********************************************************************

IF lv_pwdstate = '2-'.

ls_data-pwdstate = 'Kennwortänderung nicht möglich'.

ELSEIF lv_pwdstate = '1-'.

ls_data-pwdstate = 'Änderbar nach Wartezeit'.

ELSEIF lv_pwdstate = '0'.

ls_data-pwdstate = 'Produktivkennwort'.

ELSEIF lv_pwdstate = '1'.

ls_data-pwdstate = 'Initialkennwort'.

ELSEIF lv_pwdstate = '2'.

ls_data-pwdstate = 'Kennwort abgelaufen'.

ELSEIF lv_pwdstate = '3'.

ls_data-pwdstate = 'Muss geändert werden - Neue Kennwortregeln'.

ENDIF.

ELSEIF sy-subrc = 3.

ls_data-pwdstate = 'Anmeldung nicht möglich'.

ELSEIF sy-subrc = 4.

ls_data-pwdstate = 'Kennwort deaktiviert'.

ENDIF.

Vielen Dank

LG Max

Shortcut IT GmbH
vor ein Jahr
Hallo,

den Funktionsbaustein hatte ich noch nicht auf dem Schirm. Die Info ist etwas anders als die aus RSUSR200.

Ich bin nicht so der Freund von vielen IF..ELSE-Konstrukten, daher hätte ich hier folgendes Testprogramm als Vorschlag. Meiner Ansicht nach etwas "more clean", insbesondere bzgl. der Übersichtlichkeit der einzelnen Rückgabewerte bzw. SY-SUBRC's aus dem Funktionsbaustein.

report z_pw_state.

data: f4Bname like usr02-bname.

parameters: pClient type mandt default '100'.

select-options: sBname for f4Bname.

types: begin of ValueAndText,

value type int4,

text type char80,

end of ValueAndText,

ValuesAndTexts type standard table of ValueAndText with key value.

types: begin of UserResult,

bname type xubname,

value type int4,

text type char80,

end of UserResult,

UserResults type standard table of UserResult with empty key.

" An RFC destination for testing

data: rfcDest type rfcdest value 'SAPQX1100',

" Importing parameter from SUSR_USER...

pwdstate type int4,

" Result from FM SUSR... and the explaining text

result type ValueAndText,

" Result for a single user and a table for all results.

userResult type UserResult,

userResults type UserResults.

" A table for all possible password status and their meanings

" from FM SUSR_USER_PASSWORD_STATUS_GET, taken from the documentation

data(pwStatusInfos) = value ValuesAndTexts(

( value = -2 text = 'Password cannot (generally) be changed' )

( value = -1 text = 'Password cannot be changed until the end of the wait period' )

( value = 0 text = 'Password can be changed, but does not have to be changed' )

( value = 1 text = 'Password is initial and must be changed' )

( value = 2 text = 'Password has expired and must be changed' )

( value = 3 text = 'Password must be changed because it no longer meets the new rules' ) ).

" A table for all possible SUBRC's and their meanings from FM SUSR_USER...

data(subrcs) = value ValuesAndTexts(

( value = 1 text = 'User does not exist' )

( value = 2 text = 'Internal error' )

( value = 3 text = 'Password logon disabled' )

( value = 4 text = 'User has no password' )

( value = 5 text = 'Not authorized for other user' )

( value = 6 text = 'Unknown error when calling SUSR_USER_PASSWORD_STATUS_GET' ) ).

data: resultTable type ref to ValuesAndTexts,

resultValue type int4.

" Get all users in the specified client of this system.

select bname from usr02 client specified into table @data(users)

where mandt = @pClient and bname in @sBname.

" Get the password status for each user.

loop at users reference into data(user).

call function 'SUSR_USER_PASSWORD_STATUS_GET' destination rfcDest

exporting

USERNAME = user->*

PASSWORD_LOGON = 'X '

importing

pwdstate = pwdstate

exceptions

username_not_exists = 1

internal_error = 2

password_logon_disabled = 3

user_has_no_password = 4

not_authorized_for_other_user = 5

others = 6.

if ( sy-subrc = 0 ).

resultValue = pwdstate.

resultTable = ref #( pwStatusInfos ).

else.

resultValue = sy-subrc.

resultTable = ref #( subrcs ).

endif.

try.

result = resultTable->*[ value = resultValue ].

catch CX_SY_ITAB_LINE_NOT_FOUND.

result-value = resultValue.

result-text = '*** Unknown ***'.

endtry.

userResult = corresponding #( result ).

userResult-bname = user->*.

insert UserResult into table userResults.

endloop.

cl_demo_output=>display_data( userResults ).

Viele Grüße

Shortcut IT

Max_SAP
  • Max_SAP
  • SAP Forum - User Thema Starter
vor ein Jahr
Hallo,

herzlichen Dank.

LG Max