cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain current logon user in JSP application

Former Member
0 Kudos

Hello everyone,

we would like to implement a JSP page which will be embedded inside a Webdynpro IFrame . Inside this JSP we would like to get the current logon user to this application. In webdynpro, I know there are some APIs to get current logon user. Then how to get this information in a JSP file? or How to pass the informaiton from Webdynprot controller to a IFrame ?

Thanks in advance!

Best regards

Deyang

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Accessing the Logon ID

In EP5 you could simply call getUid() to obtain the logon ID. However, you will notice that this method is deprecated in EP6. This is primarily due to the fact that a user can be associated with multiple logon accounts. The Javadocs say to use getUniqueId() as a replacement for getUid(), but this returns a value that must be parsed to get the logon ID. You can access the actual logon ID by iterating through the IUserAccounts array obtained by calling getUserAccounts(). The logon ID is retrieved using the new call getLogonUid(). Often times you can simply pick the first element in the array:

String logonID = user.getUid();

IUserAccount accounts[] = null;

try {

accounts = user.getUserAccounts();

} catch (UMException e) {

response.write(("<br>Error getting accounts: " + e.getLocalizedMessage());

}

if (accounts != null) {

response.write("<br>Number of Login Accounts: " + accounts.length);

for (int i = 0; i < accounts.length; i++) {

response.write(

"<br>** Login ID #" + i

+ ": LogonUID=" + accounts<i>.getLogonUid()

+ ", AssignedUID=" + accounts<i>.getAssignedUserID());

response.write(

"<br>Last Login: "

+ accounts<i>.getLastSuccessfulLogonDate().toString());

response.write(

"<br># Logins: " + accounts<i>.getSuccessfulLogonCounts());

}

}

Regards

Ayyapparaj

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

How are you embedding your JSP in your Webdynpro view?

If possible pass the user parameter once you obtain it through api's to the JSP.

Then in your JSP you can access it via say

request.getParameter(user)