on 08-22-2009 12:47 PM
Hi,
How can i get username currently log in portal?
Thanks.
Hello
Use the following piece of code to get the logged in user name
try
{
IWDClientUser clientUser = WDClientUser.getCurrentUser()
}
catch (WDUMException e)
{
// do exception handling
}
Do try searching the forum before posting questions, this question has been asked and answered way too many times.
Thanks,
GLM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Cemil,
Do refer this link - https://wiki.sdn.sap.com/wiki/display/Snippets/GettingLoggedinPortalUserDetailsinWebDynPro
It has all the needed code to get the current logged in user
Snippet from the said link
Description This code will help one to get the current logged in Portal User through Web DynPro application
These are the imports to be used
import com.sap.security.api.IUser;
import com.sap.security.api.IUserAccount;
import com.sap.security.api.UMException;
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;
String strUserName = null;
try {
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
IUser sapUser = wdClientUser.getSAPUser();
if (sapUser != null) {
IUserAccount[] acct = sapUser.getUserAccounts();
if (acct[0] != null) {
strUserName = acct[0].getDisplayName();
}
}
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks,
GLM
Hi Cemil Bozlagan,
String userName = "";
try
{
IUser user= WDClientUser.getCurrentUser().getSAPUser();
}
catch (WDUMException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), false);
}
userName = user.getUniqueName();
// we have different methods here like getDisplayName(), getUniqueID() etc.
Regards,
Siva
Hi,
Use this code,
IWDClientUser wdUser = WDClientUser.getCurrentUser();
IUser user = wdUser.getSAPUser();
Note: Defining the IUser will show an error. To resolve this, within the properties of
the project, choose Java build path -> Libraries -> Add external jars ->
com.sap.securities -> lib -> com.sap.security.api.
Regards,
Sunaina Reddy T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cemil Bozlagan,
Use the code to get current user logged in
try
{
IUser user= WDClientUser.getCurrentUser().getSAPUser();
String name=user.getUniqueName();
}
catch (WDUMException e)
{
}
U need to add com.sap.security.api.jar file to the project.
Regards,
srikanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try the following code to get vurrently logged in user on portal :
IWDClientUser l_ClntUser = WDClientUser.getCurrentUser();
IUser l_IUser = l_ClntUser.getSAPUser();
IUserAccount[] l_IUA = l_IUser.getUserAccounts();
String uniqName = l_IUA[0].getLogonUid();
If the logged-in user is a URL parameter then try the following :
Eg: to extract the parameter "User" from the URL
String LogginUser = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getParameter("User");
Also check this thread...
Thanks
Avik
Edited by: AVIK SANYAL on Aug 24, 2009 6:49 AM
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 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.