cancel
Showing results for 
Search instead for 
Did you mean: 

retrieving portal user name

Former Member
0 Kudos

Hi,all

In NW 2004 I retrieved the user name of portal user by following:

HttpServletRequest req =((com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter ()).getHttpServletRequest();

wdContext.currentContextElement().setUserName(req.getRemoteUser());

But in NW 2004S it is not working.I can not to locate IWebContextAdapter.

How can I retrieve the portal user name here?

Regards,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please try following code and let me know.

-


import com.sap.tc.webdynpro.services.sal.um.api.IWDClientUser;

import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;

try

{

//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();

wdContext.currentContextElement().setId(strUserid);

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

}

}

}

catch (Exception e)

{

wdComponentAPI.getMessageManager().reportException("Failed to get current user: " + e.getLocalizedMessage(), true);

}

-


Regards,

Vaibhav

Answers (3)

Answers (3)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Michael

WDClientUser.getCurrentUser().getClientUserID();

Regards

Abhimanyu L

Former Member
0 Kudos

chk it

Former Member
0 Kudos

Hi,

Try this:

WDClientUser.getLoggedInClientUser().getFirstName();

Regards,

Satyajit.