Skip to Content
avatar image
Former Member

How to find login id of the portal user from Webdynpro application

Hi,

We need to find out the login id of the logged in portal user in our webdynpro application.

Please explain the steps needed to do this.

Regards

Ajay

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Nov 06, 2006 at 08:56 AM

    Hi Ajay,

    Try out this code in webdynpro.

    {

    // get the currently logged in user

    IWDClientUser wdUser = WDClientUser.getCurrentUser();

    //get the com.sap.security.api.Iuser; It is null in case wdUser represents an anonymous user

    IUser user = wdUser.getSAPUser();

    //check whether the user is anonymous

    if (user != null)

    {

    //access logon ID by iterating through the IUserAccount array

    IUserAccount[] acct = user.getUserAccounts();

    if(acct[0] != null)

    {

    String strUserid = acct[0].getLogonUid();

    //pass the value obtained from the portal to value attribute

    wdContext.currentNode().setAttribute(new String(strUserid));

    }

    }

    }

    Note: Defining the IUser will show an error. To resolve this:

    1. Right-click the project in Eclipse or SAP NetWeaver Developer Studio.

    2. Select Properties.

    3. Choose Java build path -> Libraries -> Add Variable -> Select variable WD_RUNTIME -> Extend -> com.sap.security -> lib -> com.sap.security.api.jar.

    Regards, Suresh KB

    Add comment
    10|10000 characters needed characters exceeded