cancel
Showing results for 
Search instead for 
Did you mean: 

Not getting the User ID properly

former_member214651
Active Contributor
0 Kudos

Hi All,

I am facing a problem while getting the user id of the logged user in my application. I have written the following code to get the id of the logged user:

IWDClientUser wdClientUSer = WDClientUser.getCurrentUser();
StringTokenizer stkUserName = new StringTokenizer(wdClientUSer.getClientUserID(),":");
while (stkUserName.hasMoreElements()) 
{
	String strUserID = stkUserName.nextToken();			
}

this returns the output as USER.PRIVATE_DATASOURCE.un:<user_id>. Using the string tokenizer, i am able to get the <user_id> and displaying it on the screen.

This works fine on the Dev and Quality server, but when the same code is deployed on the production server, the user id is retrieved as USER.CORP_LDAP.<user_id>.

Please let me know how can this be corrected to get the <user_id> alone?

Regards,

Poojith MV

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member214651
Active Contributor
0 Kudos

Solved. Added the com.sap.security.sda to the dependency of the DC

former_member214651
Active Contributor
0 Kudos

Sorry. Accidentally clicked on Answered

Former Member
0 Kudos

Hi Poojith,

You can directly get the user id of the logged user by below code.

Sting userId = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();

Regards

Ravindra

former_member214651
Active Contributor
0 Kudos

Hi Ravindra,

Thanks for the reply. But I found one thing which i don't know if that is how it works. I tried using the statement:

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

but the IUser was throwing an error that there was no such API. I Tried doing Organize Imports, but did not work. I checked in the installation directory of my NWDS to see if there was an API for com.sap.security. It was present but the import was not happening.

Later i right-clicked the project and in the Java Build Path>Libraries>Add External Jars, I added the 2 Jars present in the folder of my NWDS installation and then it started working.

Is this how it should be done or is there a better way to do it.

Regards,

Poojith MV

Former Member
0 Kudos

Sorry I missed that part.

Instead of adding the jars from java build path just add these jars by right click on Used Dcs, go to Local Developement ->

SAP-JEE and add com.sap.security.api.sda

Regards

Ravindra

former_member214651
Active Contributor
0 Kudos

Hi,

I don't see the section "UsedDCs" under my WD project. I am using CE 7.1 NWDS. Is there any other place where i can add this jar file which can be used any DC's?

Regards,

Poojith MV