cancel
Showing results for 
Search instead for 
Did you mean: 

Search Portal users

Former Member
0 Kudos

Hai,

I try to search the protal users with first name or last name. i try with this below code but i am not getting the user details.

public String [] searchUsers(String firstName,String lastName){
		try {
			IUserSearchFilter filter=userFactory.getUserSearchFilter();
			if(firstName!=null && (firstName.trim().length()>0))
			filter.setFirstName("%"+firstName+"%",ISearchAttribute.LIKE_OPERATOR,false);
			if(lastName!=null && (lastName.trim().length()>0))
			filter.setLastName("%"+lastName+"%",ISearchAttribute.LIKE_OPERATOR,false);
			ISearchResult result=userFactory.searchUsers(filter);
			String[] ids=new String[result.size()];
			int j=0;
			for(Iterator i=new PrincipalIterator(result);i.hasNext();){
				IUser userO=(IUser)i.next();
				ids[j]=userO.getUniqueID();
				j++;
			}
			return ids;
		} catch (UMException e) {
			return null;
		}

Where is the problem in the code .

Help me to solve this problem.

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

gothtrhu this link it might helps u

Thanks,

Lohi.

Former Member
0 Kudos

Hai Lohita,

I want to search users , not the roles.

My problem is i am not getting any result with using above code.

Regards,

Answers (5)

Answers (5)

Former Member
0 Kudos

Dear Nagaraj,

is the code working fine?

please give points if i have solved your problem.

Former Member
0 Kudos

now code is working fine .

I didnt change any thing in code. I dnt know why its not workde before

Former Member
0 Kudos

Dear naga Raju,

Sorry for delayed reply.

please write the piece if code in view's init method and execute it.

You will get the user's list

ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();

IUserFactory usf = UMFactory.getUserFactory();

IUser iuser = null;

IUserListElement userElement = null;

int i = 0;

while (rst.hasNext()) {

iuser =

UMFactory.getUserFactory().getUser(rst.next().toString());

String email = iuser.getEmail();

String fname = iuser.getFirstName();

String lname = iuser.getLastName();

//diplay the email, first name and lastname

}

former_member188556
Active Contributor
0 Kudos

Hi


while (searchResult.hasNext() && i < 50) {
	searchResultElement = wdContext.createSearchResultElement();
	String uniqueid = (String) searchResult.next();
	IUser user = userFactory.getUser(uniqueid);

        searchResultElement.setFirstName(user.getFirstName());

This is working fine for me

Regards

BP

Award points if found usefull

Former Member
0 Kudos

Hai BP,

I am getting the result size is 0.

regards,

Former Member
0 Kudos

Dear Naga Raju,

please let me know what database you are using for the Potal, is it LDAP or UME?

Anil Dichpally

Former Member
0 Kudos

Hi Anil ,

its UME.

Regards,