cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the current user logon to portal?

Former Member
0 Kudos

Hi Gurus,

How to get the current user who logged into portal.

I have a webdynpro requirement where in which I have to get the current user id who loggedinto portal which will be the input parameter of the BAPI(adaptive RFC model) which will return me employee number of the particular user.

Can anyone send me the code to retrive the user id through webdynpro application..........

Pts will be rewarded for useful inputs......

Thanks in Advance,

Dharani

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

IWDClientUser user = WDClientUser.getLoggedInClientUser();

Regards,

Murtuza

Former Member
0 Kudos

Hi Murtuza,

I have to pass this user id to bapi which will return me employee number associated to this user.

How to do that?

I guess I have to put your code(IWDClientUser user = WDClientUser.getLoggedInClientUser();)

before I call the bapi(whic will return the employee number).

and please tell me how to set this value as a input parameter to the bapi.

Thanks in Advance,

Dharani

Former Member
0 Kudos

Hi Dharani,

Write this code before executing your BAPI.

IWDClientUser user = WDClientUser.getLoggedInClientUser();

IUser iuser = user.getSAPUser();

String userid = iuser.getDisplayName();

Pass userid to your BAPI.

Regards,

Murtuza

Former Member
0 Kudos

Hi Murtuza,

Thanks for the input.

When I addded your code in my webdynpro application.

It throwing an error message saying that IUSER cannot be resolved and its not a type?

What is that?

whether i need to create the class file or what?

Thanks in Advance,

Dharani

Former Member
0 Kudos

Hi Dharani,

For that, you need to add a JAR file.

To do this:

1) Right click on your project

2) Choose properties

3) Choose Java Build Path

4) Click on 'Add variable'

5) ECLIPSE_HOME

6) Click on 'extend'

7) Open plugins

😎 Choose com.sap.security_2.0.0 > lib > com.sap.security.api.jar

9) Click OK

10) Now right-click in your code and do "organize imports"

This should solve your issue about "IUser cannot be resolved or is not a type"

Kind regards

Allan

Former Member
0 Kudos

Hi Allan,

Thanks for the input.

Can you please send me the code to get the current user loggedinto portal.

Looking forward to hear from you soon.

Thanks in Advance,

Dharani

Former Member
0 Kudos

Another remark;

The webdynpro application user will be 'J2EE_GUEST' by default, so to avoid this, you need to setup the login.

How to proceed:

1) Double click on the application

2) Go to tab 'application properties'

3) Choose 'New'

4) Select 'pre-defined'

5) Click 'Browse' and select 'authentication'

6) Set value to 'true'

Reward points when helpful

[The smiley saved your two points ;-]

Kind regards

Allan

Edited by: Armin Reichert on Apr 26, 2008 7:12 PM

Former Member
0 Kudos

Hi Dharani,

No problem

I did this by coding this:

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

Kind regards

Allan

Former Member
0 Kudos

Hi Allan,

Thank you once again...

Which parameter I should pass to the bapi so that it will return me employee number which is associated with the portal userid.

Thanks in Advance,

Dharani

Former Member
0 Kudos

Hi Dharani,

Do you mean which parameter you need to use for the username?

Well, the string userName has the value of the logged-in user. So you'll need to use that one.

I hope I helped you solve your problem.

Regards

Allan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Dharani,

Using UMEfactory u can do that...

1. create one input field,

2. create one attribute called Uid

3. assign Uid attribute to the input field

4. type the following code in Doinit() method

String uid = wdContext.currentContextElement().getUid();

try {

IUser user = UMFactory.getUserFactory().

getUserByLogonID(uid);

String userName = user.getDisplayName();

} catch (UMException ex) {

e.toString();

}*/

5. after that go to Portal create one iview assign to particular user. then u get into the user details...

thats it

Regards,

P.Manivannan

Former Member
0 Kudos

Hi Manivannan,

I shouldn't create UI element in the view since its a standard business workpackge.

I have just get the current user logged into portal and pass that information as a input to the BAPI(which I imported using adaptive RFC model).

so that I will get the employee number as a output from the bapi.......

Hope you understood my requirement.......

Kindly help if you got a clue........

Thanks in Advance,

Dharani

Former Member
0 Kudos

Hi ,

Use this code,

IUser user = UMFactory.getUserFactory().

String userName = user.getDisplayName();

String email = user.getEmail();

String Description = user.getJobTitle();

String name = user.getName();

String UniqueID = user.getUniqueID();

String UniqueName = user.getUniqueName();

Regards,

P.Manivannan