cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve employee ID from sap.authentication?

Former Member
0 Kudos

Hi there,

Anyone knows what code do I write to retrieve the ID of the employee who is currently logged in?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use the below code.

String strUserName = null;

try {

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

IUser sapUser = wdClientUser.getSAPUser();

if (sapUser != null) {

IUserAccount[] acct = sapUser.getUserAccounts();

if (acct[0] != null) {

strUserName = acct[0].getDisplayName();

}

}

} catch (WDUMException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (UMException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

The string strUserName gives you the logged in user. and add the required jar files.

Thanks,

Prasanthi.

Former Member
0 Kudos

Hey there!

So sorry,

The code by prasanthi reddy above works! Thanks a bunch!

Answers (5)

Answers (5)

Former Member
0 Kudos

are you still facing problem in retrieving USER ID of logged in user?

Thanks,

Prasanthi.

Former Member
0 Kudos

Hi there,

I can get the ID but it appears to be encrpyted? It is not the same ID that I use to log in to the authorised system.

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

Its the same Id by whichyou have logegd in. Its just that it comes with some prefix and suffix in that. Please refer to my first reply where I have mentioned that you can write a simple java loic to extract the userid from the string which you got.

Can you please let us know that :-

1) What is the user name with which you have logged on?

2) What is the encrypted string which you are getting?

Then accordingly i can send you the code for getting the exact ID. You can try to get the ID yourself however in case you want some help just let me know.

I hope this helps!

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Hi,

I logged in with 40001 (userid) and when i requested for the id, it gives me

"ff0f16f0095611de871d00145ec79d88" instead.

How can I decrypt it?

Former Member
0 Kudos

Thank you so much!! I will try and let you guys know!

Former Member
0 Kudos

To add the jar files,

In addition to code mentioned you will need to add external jars in the build path of your project. You can do this by right clicking on your Project Name ==> Properties ==> Java Build path ==> Libraries ==> Add external jars.

the jars you need to add for this are,

com.sap.security.api.jar

com.sap.security.api.perm.jar.

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

Use this:


String loggedOnUserID = WDClientUser.getCurrentUser().getClientUserID();

If you use this code then you need not have to add any external Jars!! Also you can check the format of the ClientUserID, if it needs some manipulation to get the way you want to have the UserID then you can easily do that using JAVA API's.

I hope this helps!! Please revert back in case you have any issues!!

Thanks and Regards

Pravesh

Former Member
0 Kudos

hi,

Give it in a try and catch block..

try {

String loggedOnUserID = WDClientUser.getCurrentUser().getClientUserID();

}

catch (WDUMException e){

e.printStackTrace();

}

Jithin

Former Member
0 Kudos

Hi there,

I used your code but it still requires me to add the external jar files

BTW is it normal that the UserID is in some encrpyted form? like 8ae9eg1qope3?

Former Member
0 Kudos

Plz see the below thread for help