on 03-17-2005 5:14 AM
Hi all,
I have a webdynpro application and have integrate it into a Portal's iView. Now in my application, I want to get the Logon Portal urer's information(like username .. etc.) So how to achieve this?
Thanks and Best regards
Deyang
Hi,
The only way I could figure out how to get it was to import the com.sap.security.api.
1. From Window>Preferences>Java-->Classpath Variables, set up a variable called WEBAS_HOME pointing to:
<drive>/usr/sap/<SID>/jc00/j2ee/cluster/server0/
2. Right click on properties of your Dynpro Project->Properties->Java Build Path->Libraries and click "Add Variable."
3. Select WEBAS_HOME and click "Extend"
4. Select /bin/ext/com.sap.api.sda/com.sap.security.api.jar and click OK.
If you don't have access to a portal directory, you will have to get this jar file and copy it to your workspace to add to your build path instead of the above steps.
Then in your code:
import com.sap.security.api.IUser;
import com.sap.security.api.IUserAccount;
public void GetLogonID( )
{
String LogonID;
try {
/* create an user object from the current user */
IWDClientUser wdUser = WDClientUser.getCurrentUser();
IUser user = wdUser.getSAPUser();
if (user != null) {
IUserAccount acct = user.getUserAccounts()[0];
if (acct != null) {
LogonID = acct.getLogonUid();
} else
LogonID = "acct null";
} else {
LogonID = "user null";
}
wdContext.currentContextElement().setDisplayName(user.getFirstName() + " " + user.getLastName());
wdContext.currentContextElement().setLogonID(LogonID.toUpperCase());
} catch (Exception e) {
e.printStackTrace();
}
}
Hope this helps... I had to search several places before I found all the necessary stuff. Maybe I can get my first points!
Thanks,
Andrew
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thankx
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shubhadip and Andrew,
Thanks for your answers! I think my problem was resolved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deyang,
u can use WDClientUser utility for this. Try the following code
try{
IWDClientUser user = WDClientUser.getCurrentUser();
String fName = user.getFirstName();
String lName = user.getLastName();
}catch(Exception e){
}
Hope it helps!!!
Shubhadip
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could also try the following for the LoginID. If all you need is the first and last name and not the users LoginID, you don't need the com.sap.security.api.jar file.
Also, make sure you check the "Authenticate" checkbox when creating your Dynpro application.
public void GetLogonID( )
{
/*@@begin GetLogonID()*/
String LogonID;
try {
/* create an user object from the current user */
IWDClientUser wdUser = WDClientUser.getCurrentUser();
IUser user = wdUser.getSAPUser();
LogonID = user.getUniqueName();
wdContext.currentContextElement().setDisplayName(user.getFirstName() + " " + user.getLastName());
wdContext.currentContextElement().setLogonID(LogonID.toUpperCase());
} catch (Exception e) {
e.printStackTrace();
}
/*@@end*/
}
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.