cancel
Showing results for 
Search instead for 
Did you mean: 

How to get User Name in AbstractPortalComponent

Former Member
0 Kudos

Hello!

Can s.o. tell me how to get the user from doContent()-Area within an AbstractPortalComponent (not JSPDynPage). I saw that there is an Interface IUserContext, in some example i saw another Interface "IUser", but that is not reachable for me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Karpenstein,

Why is IUser not reachable for you?

Usually you would use that exact object to get User information.

IUserFactory userFact = UMFactory.getUserFactory();
userFact.getUser(String uniqueID)

The package that you need to import is com.sap.security.api.*;

Hope that helps.

Cheers,

Hermann

Former Member
0 Kudos

Hello!

Thx for your reply. It seems to me i have to include a library. Do you know which library i need to get IUser or IUserFactory?

Best regarsd

Former Member
0 Kudos

The library you need is: com.sap.security.api.jar

You should be able to find it in the plugins directory of your NWDS installation under com.sap.security_2.0.0\lib

Cheers,

Hermann

Edited by: Hermann Hans on Sep 19, 2008 11:19 AM

Former Member
0 Kudos

Hello thx to all i found the needed libraries.

With best regards

Answers (2)

Answers (2)

Former Member
0 Kudos

...

import com.sap.security.api.IUser;

import com.sap.security.api.IUserFactory;

import com.sap.security.api.UMFactory;

import com.sapportals.portal.prt.component.AbstractPortalComponent;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

...

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

...

IUserFactory userFact = UMFactory.getUserFactory();

IUser me = request.getUser();

...

String accessid = me.getUniqueName();

String uniqueid = me.getUniqueID();

String name = me.getDisplayName();

Former Member
0 Kudos

Hi,

you have some different methods, choose the one which fits more to your requirements:

getUniqueName() --> will display access ID

getUid() or getUniqueID() --> will display unique ID

getDisplayName() --> will display surname and name

as has told Hermann do the import com.sap.security.api.*; where you have included import com.sap.security.api.IUser; which is the package you need.