on 12-09-2005 12:08 PM
Hi all,
I have a problem with function "UserSearch" in my WebDynpro application. With following code I cannon have data user who registered with the portal.
try {
IUserFactory ufact = UMFactory.getUserFactory();
IUserSearchFilter isf = ufact.getUserSearchFilter();
// data from input field
String mySearchStr = wdContext.currentContextElement).getUserDataSelect();
//Provide the search attributes
isf.setDisplayName("" + mySearchStr + "",ISearchAttribute.LIKE_OPERATOR,false);
//Start search
ISearchResult sr = ufact.searchUsers(isf);
String strtest = sr.toString().toUpperCase();
IUser user = UMFactory.getUserFactory().getUser(strtest);
//put <b>user.getUniqueName</b>() -> in context Node
} catch (UMException e) {
e.printStackTrace();
}
Can some one give me pointers or some sample code of web dynpro which we can search specific user in the portal (Search parameters: ID, Last/First Name)
Thanks,
Natalia
hi natalia
use the portal user management api by importing the portal ume api jar files
to check for the portal user.then you can use the portal api to search the user.
regards
saravana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi saravana,
thank for your help. In help portal and sdn I found enough information about UME but not realy good info for searching for user. For example I tempted this solution but without success.
http://help.sap.com/saphelp_nw04/helpdata/en/0f/807300c5754ed79107dcd9c2ae4ef4/frameset.htm
Do you have any more information or coding about searching user?
best regards,
Natalia
Hi,
Assuming u get more than one user.. in the search result.. and u r converting it to string.. it will give worng results right..!!
1.Try printing the search result..
2. Try getting a user object by directly giving the username..
3.Restrict the search so that it will give u only one result..
Try all these options.. and use this..
ISearchResult sr = ufact.searchUsers(isf);
String str = sr.next(); and not toString()...
It should work...:)
Regards
Bharathwaj
Message was edited by: Bharathwaj R
Message was edited by: Bharathwaj R
Hello Bharathwaj,
I had to try your recomendation but without result. It is not works. Although I search user by directly giving the username (user display name as search paremeter) and printing the serch result in the table.
try {
IUserFactory iuf = UMFactory.getUserFactory();
IUserSearchFilter usf = iuf.getUserSearchFilter();
// Input field for search parameter
String search = wdContext.currentContextElement().getUserDataSelect();
//Provide the search attributes
usf.setDisplayName(
search,
ISearchAttribute.EQUALS_OPERATOR,
false);
//Start search
ISearchResult sr = iuf.searchUsers(usf);
while(sr.hasNext())
{
IUser user = UMFactory.getUserFactory().getUser(sr.next().toString());
// put to the table in context
wdContext.currentUserSearchElement().setUserId(user.getUniqueName());
wdContext.currentUserSearchElement().setUserName(user.getDisplayName());
}
} catch (UMException e) {
e.printStackTrace();
}
If you have more ideas please give me your feedback.
Thanks,
Natalia
Hi Natalie,
This is supposed to work..:(
There might be some exception.. e.printStackTrace() wont print the output in the console..
use message manager and use the Exception class.. and not a specific child like UMException.
We might have a chance here..
usf.setDisplayName(
search,
ISearchAttribute.EQUALS_OPERATOR,
false);
//Start search
ISearchResult sr = iuf.searchUsers(usf);
while(sr.hasNext())
{
IUser user = UMFactory.getUserFactory().getUser(sr.next().toString());
// put to the table in context
wdContext.currentUserSearchElement().setUserId(user.getUniqueName());
wdContext.currentUserSearchElement().setUserName(user.getDisplayName());
}
} catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e.toString((),true);
}
Regards
Bharathwaj
Hi,
winter !
Are u trying to put it in a node..
wdContext.currentUserSearchElement().setUserId(user.getUniqueName());
Have u created this user search element in the node..?
When u try to access an element without creating any , you will get null pointer exception
That must be the reason.. (My best guess!)
Regards
Bharathwaj
hi,
Try using the following codes
IUserFactory iuf = UMFactory.getUserFactory();
IUserSearchFilter usf = iuf.getUserSearchFilter();
String search = wdContext.currentSearchElement().getSearchKey();
search = "" + search + "";
usf.setSearchMethod(usf.SEARCHMETHOD_OR);
you need to include com.sap.security.api.jar file to implement.
Also see this thread for more information
/thread/35152 [original link is broken]
hope it helps...
regards,
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Arun,
Sorry , I am new to web dynpro and for me is not clearly how can I access to selected user date if I use the methode usf.setSearchMethod(usf.SEARCHMETHOD_OR);
Can you sent me more details?
What about search input parameters:is it possible to search for lastname, firstname or user id ?
P:S: I have included com.sap.security.api.jar file in my project.
Thanks for your help
Natalia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.