Skip to Content
avatar image
Former Member

Function module for VALIDATING USERNAME AND PASSWORD?

Hello,

I have a requirement wherein for the first screen I have to design two input fields for USERNAME & PASSWORD.

Once the user has entered these two fields, I need to validate both.* Is there any function module which has this

fuctionality to validate both the username and password?*

And is it possible to call this FM in webdynpro?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 21, 2011 at 04:22 AM

    Hi,

    You can write your own validation username and password codes:

    DATA lr_current_controller TYPE REF TO if_wd_controller.

    DATA lr_message_manager TYPE REF TO if_wd_message_manager.

    DATA lo_nd_name TYPE REF TO if_wd_context_node.

    DATA lo_el_name TYPE REF TO if_wd_context_element.

    DATA ls_name TYPE wd_this->Element_name.

    DATA lv_message TYPE string.

    • navigate from <CONTEXT> to <node_NAME> via lead selection

    lo_nd_name = wd_context->get_child_node( name = wd_this->wdctx_node_name ).

    • get element via lead selection

    lo_el_name = lo_nd_name->get_element( ).

    • get all declared attributes

    lo_el_name->get_static_attributes(

    IMPORTING

    static_attributes = ls_node_name ).

    IF ls_node_name-password <> 'YOUR_PASSWORD_NAME'.

    lv_message = 'Wrong password'.

    lr_current_controller ?= wd_this->wd_get_api( ).

    lr_message_manager = lr_current_controller->get_message_manager( ).

    lr_message_manager->report_error_message(

    EXPORTING

    message_text = lv_message

    show_as_popup = abap_false ).

    clear lv_message.

    ENDIF.

    IF ls_node_name-username <> 'YOUR_USERNAME'.

    lv_message = 'Wrong username'.

    lr_current_controller ?= wd_this->wd_get_api( ).

    lr_message_manager = lr_current_controller->get_message_manager( ).

    lr_message_manager->report_error_message(

    EXPORTING

    message_text = lv_message

    show_as_popup = abap_false ).

    clear lv_message.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 20, 2011 at 04:48 PM

    Hi Payal,

    Try by using, SUSR_CHECK_LOGON_DATA.

    You need to provide auth_method (P for password check), userid and password.

    Be careful when you execute the function in test mode because it converts the input into upper case hence if you have lower case characters in your password it will return with invalid password. If you pass the lower case into the function in a program everything is fine.

    Cheers,

    Kris.

    Add comment
    10|10000 characters needed characters exceeded