cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving Web Dynpro User Info

Former Member
0 Kudos

Hi,

I would like to know how in a webdynpro application, one can obtain the user id of the EP6 user who is logged in.

Here's one of the examples from the documentation:

// get the com.sap.security.api.IUser;

//it is null in case user represents an anonymous user

IWDClientUser user = WDClientUser.getCurrentUser();

IUser iUser = user.getSAPUser();

But the above example doesn't seem to explain, how to get the "com.sap.security.api.IUser" package.

Can somebody explain? or is there any other method of retrieving the user info?

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hello,

I am also looking for same information and i am new to this environment. My task is to design a Login page from java webapplication i.e a jsp. My problem is that how do i retrieve user iinfo so that i can verify userid & password and authenticate him/her.

Former Member
0 Kudos

Sorry Karin for the late reply!

The issue is now solved by converting the proj into a dev component.

Thanks

-Shakeel

Former Member
0 Kudos

Dear Shakeel & Karin,

I have the same issue when I develop web DynPro.

Could you tell me more detail about your deal with.

Thank you!!

Best Regard,

Jessie

Former Member
0 Kudos

Hi Jessie,

Try converting your project into a development component and make sure you add com.sap.security.api.sda into your used DCs. If you are running WAS 630 SP2 or a higher version, then you will not face this problem.

To retrieve the current user id, use the following code:

IWDClientUser user = WDClientUser.getCurrentUser();

IUserAccount[] accounts = user.getSAPUser().getUserAccounts();

String userId = (String) accounts[0].getLogonUid();

The String object userId will have the value that you are looking for.

Regards

Shakeel

Former Member
0 Kudos

I can not found method getSAPUser in interface IWDClientUser in WAS 6.3 SP5 any more. Is it deleted from that version?

Former Member
0 Kudos

Hi Shakeel,

Did you organize the imports? Within source code (implementation tab) right mouse click, organize imports.

All necessary API should be imported then.

HTH,

Karin

Former Member
0 Kudos

Hi Karin,

Sorry for the late reply!

I did organize the imports and even tried including the JAR file containing the IUser class into the EAR file of the Web Dynpro project. But I still get the runtime exception.

Is there any other way to get the EP6 user id in a webdynpro app?

Thanks

Shakeel

Former Member
0 Kudos

Hello Shakeel,

Sorry for the delay again, I had some days off

I am not quite sure, why you get this exception again and again. I would like to send you some more background information. Could you please send me an email to karin.schattka@sap.com, I will send you some stuff then. Please expect some days of delay, since I will be back in the office beginning of next week.

Best regards,

Karin

Former Member
0 Kudos

The way I usually find the path to packages is I run search in Windows in the J2EE system directory. In this case i'd search for "com.sap.security.api".

Former Member
0 Kudos

Hi Shakeel ur Rahman,

I did not really get your question, but I hope the example I found for you will help:

// Example:

// get the currently logged in user

IWDClientUser user = WDClientUser.getCurrentUser();

// check whether the current user is authenticated or anonymous

if ( user.isAnonymous() ) {

// anonymous user

} else {

// authenticated user

}

// read some user profile information

String name = user.getLastName();

String title = user.getTitle();

// get the com.sap.security.api.IUser; it is null in case user

// represents an anonymous user

IUser iUser = user.getSAPUser();

To enable authentication for a Web Dynpro application, the application property “sap.authentication” has to be set to “true”.

Hope that helps. If it does not answer your question, please let me know!!

Best regards, Karin

Former Member
0 Kudos

Hi,

Is enabling authentication on web dynpro mandatory for getting the logged in user?/

Ashok