cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro and EP6, how to get user connected

Former Member
0 Kudos

Hello, I am creating a web dynpro project, that afterwards will be inserted in the EP6, but i need to know how to get the user that is connected in the EP6 from my application at runtime, how could i do this

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You have to include the WEBAS_HOME/bin/ext/com.sap.security.api.sda into the Java Build Path of your Dynpro project.

Also, make sure that when you create your Application in the project to check the "Authentication" check box so you can test your code.

Place the following in your code:

try

{

String logonID;

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

logonID = user.getUniqueName();

}

catch (Exception e)

{

e.printStackTrace();

}

======

Press CTRL-SHFT-O to add the imports.

import com.sap.security.api.IUser;

import com.sap.tc.webdynpro.services.sap.um.api.*;

From the IUser, you can get all the info you need about the logged on user at runtime.

Hope this helps.

Andrew

Answers (2)

Answers (2)

Former Member
0 Kudos

Add the following code in your view Controller:-

IWDClientUser user = WDClientUser.getCurrentUser();

IUser objUser = user.getSAPUser();

wdContext.currentContextElement().setID(objUser.getUniqueName());

wdContext.currentContextElement().setfirstname(objUser.getFirstName());

where ID, firstname are the context names.

getUniqueName : Gives Login id of Portal user.

getFirstName : Gives First Name of the Portal user.

likewise you can get his other information.

Use "Organize imports" and make sure that you have the following two libraries added in the build path of your project. You can do these by right clicking on your project name ==> Properties ==> Java Build Path ==> Libraries ==> Add External jars.

The external jars are :

com.sap.security.api.jar

com.sap.security.api.perm.jar

Finally rebuild your project and deploy.

May be this helps you.

Regards,

Nelly

Former Member
0 Kudos

Hi Sheldon,

when you integrate ur WD app inside portal it will be part of the portal security by default. So from the WD app you have to catch the current portal user. You can do that as following

try{

IWDClientUser user = WDClientUser.getCurrentUser();

if(user.isAnonymousUser()){

//User is anonymous .. do something...

}else{

//user is authenticated..do something

}

}catch(WDUMException e){

//do something...

}

You can check other recent postings on how to handle users from WD App in this forum itself.

Hope it helps!!!

Shubhadip