on 01-10-2009 5:04 PM
Hi All,
I want to get the current loggedin user in my WD Application.
I tried to use like WDClientUser.getCurrentUser().getSAPUser().getUniqueName()
But here I am not getting getSAPUser() for WDClientUser.getCurrentUser()
How can I get that...
Even I tried by using like WDClientUser.getLoggedInClientUser().getClientUserID().
But in this case, I am getting the number of characters inthat UserID.
Please provide the solution for my issue.
Thanks,
Bhvayasri.M
Hi Bhavya,
Can you try this in onPlugDefault(IWDCustomEvent wdEvent) method of the InterfaceView
try {
IWDClientUser l_ClntUser = WDClientUser.getCurrentUser();
IUser l_IUser = null;
if(l_ClntUser!=null)
l_IUser= l_ClntUser.getSAPUser();
IUserAccount[] l_IUA =null;
if(l_IUser!=null)
l_IUA = l_IUser.getUserAccounts();
String uniqName ="";
if(l_IUA!=null && l_IUA.length >0)
uniqName = l_IUA[0].getLogonUid();
wdThis.wdGet<comp>Controller().wdGetContext().currentContextElement().setCtx_va_loggedInUser(uniqName.toUpperCase());
} catch (WDUMException e) {
}catch (UMException e) {
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for getSAPUser() com.sap.security.api is needed.
If you are using DCs go to DC MetaData - DC Definition - choose add Used Dc from Used DCs context menu
drilldown SAP-JEE and you can find com.sap.security.api.sda[sap.com] drill further and select default under public part
click ok and select dependency type as Built time and Run time.
If you are not using DC, copy the same to \lib directory and include in the java build path
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You will first have to add the com.sap.security.api.sda file to the used DC. This will import the following classes required for user identification :
import com.sap.security.api.IUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;
Then in the wdDoInit() method of the view, you can add the following code to fetch the user ID of the user logged in :
IUser currentUser = null;
try
{
currentUser = WDClientUser.getCurrentUser().getSAPUser();
}
catch (WDUMException e)
{
// TODO Auto-generated catch block
wdComponentAPI.getMessageManager().reportException( "Error occured while processing data:" + e.getMessage() , true);
return null;
}
String userID = currentUser.getUniqueName();
You will get the userID of the current user in 'userID'.
Regards,
Divyata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhavya,
Use the below code in your WD Application
IWDClientUser clientUser = WDClientUser.getCurrentUser();
IUser user = clientUser.getSAPUser();
from the object "user" you can get the current logged in user details.
If you want your application to provide access for authentication, you can achieve this by setting the application property i.e, "authentication = true"
Regards,
Kavitha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this......
import com.sapportals.portal.security.usermanagement.IUser;
import com.sapportals.portal.security.usermanagement.UserManagementException;
import com.sap.tc.webdynpro.services.sal.um.api.IWDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;
import com.sapportals.wcm.util.usermanagement.WPUMFactory;
try {
com.sapportals.portal.security.usermanagement.IUser ep5User = null;
IWDClientUser wdClientUser=WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser=wdClientUser.getSAPUser();
ep5User=WPUMFactory.getUserFactory().getEP5User(sapUser);
String UesrId=ep5User.getId();
}catch (WDUMException e1) {
mgr.reportException("WDUMException::"+e1.toString(),true);
} catch (UserManagementException e2) {
mgr.reportException("UserManagementException::"+e2.toString(),true);
}
Hope this will be useful....
Regards,
Swati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhavya,
Go through the following link:
It contains the method for how to create such an application that will fulfil your requirements. You once go through that and check what you are doing is consistent with the above article or not. When you deploy your application on the browser, if everything is alright then it will show J2EE_USER where you are showing the credentials of the logged in user.
Hope it helps.
Regards.
Rajat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhavya,
First you need to add the corresponding jar file the com.sap.security.api .
Then
import com.sap.security.api.IUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;
After this try with this code to get user ID. This code is working for me.
String userName = "";
IWDClientUser wdUser = null;
try
{
wdUser = WDClientUser.getCurrentUser();
}
catch (WDUMException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), false);
}
IUser usernam = wdUser.getSAPUser();
userName = usernam.getUniqueName();
regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.