Show TOC Start of Content Area

Background documentation Searching for Users, Roles and Groups  Locate the document in its SAP Library structure

The UME provides several methods to search for users, groups and roles with different attributes. The search is performed with search filters.

Search for Users

Example to get a user search filter and start search:

    IUserFactory ufact = UMFactory.getUserFactory();
    IUserSearchFilter isf = ufact.getUserSearchFilter();

//  Provide the search attributes
    
isf.setDisplayName (…);
//  Start search
    
ISearchResult sr = fact.searchUsers(isf);

 

Search for Roles

To search for roles is similar to search for users.

Example:

    IRoleFactory rfact = UMFactory.getRoleFactory();
    IRoleSearchFilter isf = rfact.getRoleSearchFilter();

//  Provide the search attributes
    
isf.setDisplayName (…);
//  Start search
    
ISearchResult sr = fact.searchUsers(isf);

 

Defining a Search Attribute

The search attribute can be set with setDisplayName() method. This method allows exact searches or wildcard searches.

Example:

//  Provide the search attributes, with wildcards before and after
//  the search string.
    
isf.setDisplayName ("*" mySearchStr + "*",
                        ISearchAttribute.LIKE_OPERATOR, 
false);

//  Provide the search attributes for an exact search
    
isf.setDisplayName (mySearchStr,
                        ISearchAttribute.EQUALS_OPERATOR, 
false);

 

Search Result

Depending on the search attribute, the search method returns one or several users or roles. The returned value is a ISearchResult object that can be iterated.

 

To which Role or Group does a User Belong

With the methods isMemberOfRole() or isMemberOfGroup() it can be determined if a user is a member of a particular role or group. The methods require the unique ID of the role or group.

Example:

    IRole superRole= null;
    
try {
        superRole= getSingleRole(
"super_admin"false);
    } 
catch (UMException e) {
        response.write(
            
"Error getting role: " + e.getLocalizedMessage());
    }
    
if (user.isMemberOfRole(superRole.getUniqueID(), true))
        response.write(
" IS a super admin");
    
else
        
response.write(" IS NOT a super admin");

 

End of Content Area