cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos

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

Answers (0)