on 01-04-2007 3:12 PM
Hi all,
We developed the development component under the track and deployed in standalone J2EE server. From the development J2EE server we transport the component to solution manager J2EE server. In EP we created system, for the same solution manager server and with this system as a reference we created the webdynpro iView in portal to access the component stored in solution manager server.
Now we want to get the EP Login User of the portal server. Please can anybody help us to get the EP user with respect to our senario.
The code with which we tried was as follows,
//To get EPUser
IUser epuser = null;
IUserObjectBasedNavigation obnService = (IUserObjectBasedNavigation) WDPortalUtils.getServiceReference(IUserObjectBasedNavigation.KEY);
String portalUser="";
try
{
IWDClientUser user1 = WDClientUser.getLoggedInClientUser();
epuser=user1.getSAPUser();
portalUser=epuser.getUniqueName();
wdComponentAPI.getMessageManager().reportSuccess(portalUser);
}
catch (Exception e)
{
wdComponentAPI.getMessageManager().reportException("Failed to get current user: " + e.getLocalizedMessage(),true);
}
Please experts advice needed.
Thanks
Hi Krish,
try the following one..
Try out this code in webdynpro.
{
// get the currently logged in user
IWDClientUser wdUser = WDClientUser.getCurrentUser();
//get the com.sap.security.api.Iuser; It is null in case wdUser represents an anonymous user
IUser user = wdUser.getSAPUser();
//check whether the user is anonymous
if (user != null)
{
//access logon ID by iterating through the IUserAccount array
IUserAccount[] acct = user.getUserAccounts();
if(acct[0] != null)
{
String strUserid = acct[0].getLogonUid();
//pass the value obtained from the portal to value attribute
wdContext.currentNode().setAttribute(new String(strUserid));
}
}
}
Note: Defining the IUser will show an error. To resolve this:
1. Right-click the project in Eclipse or SAP NetWeaver Developer Studio.
2. Select Properties.
3. Choose Java build path -> Libraries -> Add Variable -> Select variable WD_RUNTIME -> Extend -> com.sap.security -> lib -> com.sap.security.api.jar.
Thanks
Dheerendra Shukla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Shukla,
if you want to get the uniquename of the logged in portal user use this code.
String Username = "";
IWDClientUser wdUser = null;
try {
wdUser = WDClientUser.getCurrentUser();
} catch (WDUMException e) {
e.printStackTrace();
}
IUser user = wdUser.getSAPUser();
();
Username =user.getUniqueName();
// for unique ID use user.getUniqueId().
for this you need to add the security.api jar file.
Right click on the project properties->addexternal jars and add this .jar file
Regards,
Gopi
Hi,
Make sure you have set the "sap.authentication = true" in the application properties of your application.
Then use the following code -
WDClientUser.getCurrentUser().getSAPUser().getUniqueName()
Remember, if the "sap.authentication: application property is not set, the above method will throw a Null Pointer.
Regards,
Navneet.
Hi,
Check this blog:
/people/preksha.malhotra/blog/2006/12/12/accessing-a-web-dynpro-application-through-portal-using-portal-user-id
Regards,
Bhavana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.