cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Current Portal user?

Former Member
0 Kudos

Can someone tell me how to get current portal user In Web Dynpro Application.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Robin,

Here is the code which would get the current portal user

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
String userId = request.getUser().getUserId();

Hope this helps.

Cheers

Siva

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Siva

Thanx for prompt reply!

But, How can I get the request in Web Dynpro Application. I can not find any API to get IPortalComponentRequest in Web Dynpro Application, I need your more and detail help and thanks a lot.

Former Member
0 Kudos

Hi Robin,

Try


IUser currentUser = WDClientUser.getCurrentUser().getSAPUser();

You need to have com.sap.security.api.jar

Regards,

SK.

Former Member
0 Kudos

Thanks SK.

I try and get currentUser with the codes you provide in Web Dynpro Application.

But when I deploy the Web Dynpro Application into a portal and running it in a portal, I will get null all the time.

Here is the codes in Component Controller:

public void wdDoInit()

{

//@@begin wdDoInit()

try

{

IWDClientUser user = WDClientUser.getCurrentUser();

String userName = user.getSAPUser().getUniqueName();

}

catch(Exception ex)

{

ex.printStackTrace();

wdComponentAPI.getMessageManager().reportException(ex.toString(), false);

}

//@@end

}

when running in portal , It always raise null Exception.

Former Member
0 Kudos

Hi Robin,

Can you put the same code in the wdDoInit() method of the view controller and try once again???

Regards,

SK.

Former Member
0 Kudos

Hi SK:

I moved the codes into view Controller, and the same result I get.

the same codes in the view controllder:

public void wdDoInit()

{

//@@begin wdDoInit()

try

{

IWDClientUser user = WDClientUser.getCurrentUser();

String userName = user.getSAPUser().getUniqueName();

wdComponentAPI.getMessageManager().reportWarning("userName = " + userName);

}

catch(Exception ex)

{

ex.printStackTrace();

wdComponentAPI.getMessageManager().reportException("in View " + ex.toString(), false);

}

//@@end

}

Saravanan_SD
Advisor
Advisor
0 Kudos

Hi Robin,

Try like this.

IWDClientUser user = WDClientUser.getCurrentUser();

String userName = user.getLastName();

Hope it helps.

Regards,

Saravanan

Former Member
0 Kudos

Hi Saravanan:

Thanks for your answer.

But I wanna get a portal user from the Web Dynpro App, when it running in a portal.

And I try the codes like your answering. I can get "wong" when I run the Web Dynpro App individully, But I run it in the portal , I can get "".

So, I think in portal, with code "IWDClientUser user = WDClientUser.getCurrentUser();" we can get an user containing nothing. Any suggestion?

And thanks again.

Former Member
0 Kudos

Hi Robin,

Basically u need to get the user this way

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser usr = wdUser.getSAPUser();

for further detailed information refer to

Hope that helped,

Best Regards

Uma.

Former Member
0 Kudos

Thans for every anwser a log.