cancel
Showing results for 
Search instead for 
Did you mean: 

Capture the portal user id in Web Dynpro form

Former Member
0 Kudos

Hi All,

I have a Web Dynpro application which queries some data for a User Id. So far, I was able to query the data by entering a user id in the form.

Now, I intend to capture the user id which is logged in the portal (may be through some session) i.e. user id should not be entered manually.

Let me know how to capture the user id of Portal in Web Dynpro form.

Regards

Nikhil Bansal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nikhil,

You can get the current portal userid details with the following two lines of code.

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

String userid = user.getUniqueID();

Note: You need to set the com.sap.security.api.jar file in the libraries of your application.

If you still have any issues in getting the portal user id, reply to me.

Thanks,

Sandeep Bonam

Former Member
0 Kudos

Hi Sandeep,

Thanks for the reply.

The code works but there is bit of a problem.

When I am logging in through the user j2ee_admin then I am getting this user in the form (where I am capturing the current logged in user). However, when I am logging in with some other user id eg test123,sap123 then I am getting j2ee_guest as the logged in user.

Can you figure out what is wrong.

Regards

Nikhil

former_member720137
Active Participant
0 Kudos

Hi Nikhil

Do 1 thing.. Login as test123 in ur portal( in a new IE window) n then deploy ur application.. then u will c test123 not j2ee_guest... or run the application thro portal itself... Everything is fine with ur code...

Reward points if helpful

Thanks

Puneet

Former Member
0 Kudos

Hi

It's working.

Thanks again.

Regards

Nikhil Bansal

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Nikhil,

check WAS users and Portal users are correctly mapped.

Regards

Former Member
0 Kudos

Hi Nikhil,

You can ge the portal userid by using the following code:

IWDClientUser wdUser = WDClientUser.forceLoggedInClientUser();

IUser user = wdUser.getSAPUser();

String Username = user.getUniqueName();

String Email_Id = user.getEmail(); // To get the Email Id

Note: Add the <b>security.api jar</b> file in order ro get the details.

Regards,

Jhansi

Former Member
0 Kudos

Hello Nikhil,

you need to add to your class path: WD_RUNTIME/com.sap.security/lib/com.sap.security.api.jar

This is the code for get the Portal user ID:

IWDClientUser currentUser = WDClientUser.getCurrentUser();

String userId = currentUser.getClientUserID();

IUser sapCurrentUser = currentUser.getSAPUser();

// Get the SAP Current User

if (sapCurrentUser != null) {

portalUserId = sapCurrentUser.getUniqueID();

}

Regards