on 05-20-2013 2:25 PM
Hi, I'm making a method which I get the portal user data, but it is not recognizing data types.
My question is, which libraries should I import?
My method is as follows:
try {
IUserFactory ufactory=UMFactory.getUserFactory();
ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();
IUserFactory usf = UMFactory.getUserFactory();
IUser iuser = null;
//IUserListElement userElement = null;
int i = 0;
IPrivateKmnewsView.IUserNodeNode usernode=wdContext.nodeUserNode();
IPrivateKmnewsView.IUserNodeElement usernodeelement = null;
while (rst.hasNext()) {
iuser =
UMFactory.getUserFactory().getUser(rst.next().toString());
//wdComponentAPI.getMessageManager().reportSuccess("rst.next().toString() : "+rst.next().toString());
usernodeelement = usernode.createUserNodeElement();
String UID=iuser.getUid().toString();
//wdComponentAPI.getMessageManager().reportSuccess("UID:"+UID);
usernodeelement.setUserId(UID);
//wdContext.currentUserNodeElement().setUserId(UID);
String UniqueID=iuser.getUniqueID().toString();
//wdComponentAPI.getMessageManager().reportSuccess("UniqueID:"+UniqueID);
String email = iuser.getEmail();
String fname = iuser.getFirstName();
String lname = iuser.getLastName();
String Name =fname+lname;
//if(!(fname.equalsIgnoreCase("") ^ fname.equalsIgnoreCase("")))
//{
//if(currentUsers.equals()
usernodeelement.setUserName(Name);
usernodeelement.setUserEmailID(email);
usernode.addElement(usernodeelement);
//wdComponentAPI.getMessageManager().reportSuccess("Name : "+fname+""+lname);
//wdComponentAPI.getMessageManager().reportSuccess("Email : "+email);
//}
}
} catch (UMException e) {
// TODO Auto-generated catch block
wdComponentAPI.getMessageManager().reportSuccess("Exception "+e);
}
Thanks.
Cristian ottero
To all: It is generally considered bad practice to add Jar files directly to the build path of Web Dynpro applications -- and when using NWDI for development instead of LocalDevelopment, adding Jar files directly is downright impossible!
Instead, you should add component tc/je/usermanagement/api as a 'Used DC' (NW 7.0) / 'Required DC' (NW7.11 and up)
At the bottom of the Java API pages, there is a chapter named 'This class can be accessed from' which displays the required DC's to be included in your Web Dynpro DC project (see http://help.sap.com/javadocs/NW73/SPS05/CE/se/com.sap.se/com/sap/security/api/UMFactory.html )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Robin van het Hof
I served a lot of your answer. and it is true that we must apply the best practices
Regards
Cristian
Hi Cristian,
Please import com.sap.security.api.jar. You will find that in plugins folder.
Rgds,
Pankaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
1. Take jar file from below Path:
C:\Program Files\SAP\JDT\eclipse\plugins\com.sap.security\lib\com.sap.security.api.jar" file has to be added to classpath.
2. How to add Jar File to Project:
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.
3. Code:
Please use the below code to get the logged in User
try
{
IWDClientUser CurrentUser = WDClientUser.getCurrentUser();
String UserId = WDClientUser.getCurrentUser().getSAPUser().getUniqueName();
String UserName = WDClientUser.getCurrentUser().getSAPUser().getName();
}
catch(Exception e)
{
e.printStackTrace();
}
Regards
Vijay Kumar Kalluri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now why didn't you use the SCN search to locate examples? Find attached a link to one. You neglected to mention your AS JAVA version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.