Search for a user account on the messaging server
You can use any attribute in the
MailStoreUserSearchCriteriaType
class
to search for user accounts on the messaging server . The
findMailStoreUsers() method can return multiple results if the search criteria is not unique. The
findMailStoreUsers() method
adds wildcard characters to the beginning and end of all search terms. For example, if you search using an email address for the string
james.lambier, the result could contain the user accounts for
james.lambier@blackberry.com,
james.lambier2@blackberry.com, and
5james.lambier@example.com. The following code sample searches for a user account using a complete, unique email address in the search criteria.
Before you begin:
Retrieve the emailAddress
string for the user you want to find.
- Create the search criteria. To search using more than one of the criteria in the MailStoreUserSearchCriteriaType
class, specify the additional criteria after the email address.
MailStoreUserSearchCriteria criteria=new MailStoreUserSearchCriteria();
criteria.setEmailAddress(emailAddress);
- Specify the order that the BlackBerry® Administration API returns the results in. The following code sample assumes that the search criteria is unique and only one result is returned, but you should always specify the order.
MailStoreUserSearchResultSortByEnum sortByEnum=new MailStoreUserSearchResultSortByEnum();
sortByEnum.setEnum(MailStoreUserSearchResultSortByEnumType.DISPLAY_NAME);
- Specify the page size and the locale.
int pageSize=1;
String locale="en_US";
- Invoke findMailStoreUsers(). You use the pageCriteria parameter when multiple pages of results are returned. To change the number of results per page, use the pageSize parameter. If there are multiple pages of results, set the pageCriteria parameter to null to obtain the first page of the results.
To retrieve the next page of results, invoke the findMailStoreUsers()
method again and specify the last value in the results from the previous search as the pageCriteria parameter.
FindMailStoreUsersResult result=emailDominoWebService.findMailStoreUsers(criteria, sortByEnum, true, locale, null, pageSize);
- Check the result for errors and handle any errors.
if ((result.getFindMailStoreUsersReturnStatus().getCode() == FindMailStoreUsersReturnStatusEnumType.SUCCESS) && (result.getMailStoreUserSearchResult().size() == 1))
{
return result.getMailStoreUserSearchResult();
}
else
{
// handle any errors
}
Was this information helpful? Send us your comments.