on 04-21-2009 12:11 PM
Hi experts,
I have developed and integrated a Web Dynpro application into SAP Neteaver portal. When user logged in to portal and run the web dynpro application, the web dynpro application will get the current user info such as logon Id. I discovered the logon id was not always retrieved (is null) and it not happen all the time.
Following are my code to retrieve logon id of the current user:
String logonId = null;
IWDClientUser wdUser = WDClientUser.getLoggedInClientUser();
IUser user = wdUser.getSAPUser();
try {
if (user!=null) {
IUserAccount[] userAccs = user.getUserAccounts();
if (userAccs!=null && userAccs.length > 0) {
IUserAccount userAcc = userAccs[0];
logonId = userAcc.getLogonUid();
}
}
}catch (UMException ex){
}
Btw anyway know what is the different between WDClientUser.getCurrentUser() and WDClientUser.getLoggedInClientUser()?
Hi ,
You can try the following for getting the current logged in user :
IWDClientUser user=WDClientUser.getCurrentUser();
//set user
String userLogged = user.toString().substring(user.toString().lastIndexOf(".")+1,user.toString().length()-1);
Hope this helps to solve you problem.
Thanks
Ritushree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use the below code.
//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();
//CHANGE strUserid TO uppercase USING toUppercase() and bind it to ur arrtibute
wdContext.currentContextElement().setUserName(strUserid.toUpperCase());
}
}
***************************************************
Now Organise the import.If u get an error for IWDClientUser, then plz add an external jar file - "com.sap.security_2.0_0" to your project.
Hope it helps.
Regards
Shruti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if your working with normal webdynpro development it will work i think,,
can you discribe your scenario. if your working with ESS&MSS that will be a different scenario,
Cheers,
Apparao
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 code to get the logged in user's login ID.
import com.sap.security.api.IUser;
IWDClientUser user=WDClientUser.getCurrentUser();
IUser myuser=null;
myuser=user.getSAPUser();
wdContext.currentContextElement().setVa_EmpId(myuser.getUniqueName());
Regards,
Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Try this
String logonID = "";
try
{
IWDClientUser wdUser = null;
try
{
wdUser = WDClientUser.getCurrentUser();
}
catch (WDUMException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
IUser user = wdUser.getSAPUser();
logonID = user.getUniqueName();
}
catch (Exception e)
{
}
Best Regards
Satish Kumar
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.