Show TOC

Searching for Users with Standard SearchLocate this document in the navigation structure

Use

Use this procedure to create you custom search application, when you want to search user attributes not searched by the simple search, such as, custom user attributes or department.

More information: Standard Search and Simple Search .

Prerequisites

You have imported the required interfaces and gotten the required factories.

More information: User Management Functions for Users .

Procedure
  1. Get the search string filter.

  2. Use the setSearchAttribute() method to set the parameters of the search filter.

    The parameters include:

    • Attribute to search

    • Namespace of the attribute

    • Attribute value to search for

    • Search type

      Choose a search type from the table below.

      Search Type

      Description

      EQUALS_OPERATOR

      This search returns only an exact match of the value searched for. The search function interprets all characters literally.

      LIKE_OPERATOR

      This search interprets wildcards in the search value. The asterisk ( * ) is always interpreted as a wildcard. The question mark ( ? ) is not supported for all data sources. Searches of the database of SAP NetWeaver Application Server (AS) Java supports the use of the question mark. Searches of AS ABAP user management and LDAP data sources do not support the use of question mark as a wildcard.

      GREATER_THAN_OPERATOR

      This search returns all objects that are greater than and not equal to the search value. Value of a string depends ultimately on the Unicode value.

      LESS_THAN_OPERATOR

      This search returns all objects that are less than and not equal to the search value. Value of a string depends ultimately on the Unicode value.

    • Case sensitivity

      Enter the parameter true to make the search case sensitive.

  3. Use the searchUsers() method to get the search results and store them in an object.

  4. Read the unique ID of the user from the search result object.

  5. Use the getUser() method to get the user object with the unique ID.

Example

The following example searches for users with the attribute myAttributeName in the com.example namespace with the value myValue. The search is case insensitive and otherwise searches for an exact match. The results are stored in an object. The method iterates through the results and gets the unique ID. Next the method gets the user based on the unique ID.

            public static void userStandardSearch(String nameSpace, String attributeName, String attributeValue) {

                try {
                        

                        // Get the search filter. 
                        
                        


                        /*
                         * Set the search filter. This search searches the custom attribute "myAttributeNmae"
                         * in the namespace "com.example" for the value "myValue", is case insensitive,
                         *  and uses no wildcards.
                         */

                        


                        // Store the search results in the object "sr".
                        
                        


                        //Check if the results are valid.
                        
                        if (
) {

                                // Loop through the search results in the object "searchResult".
                                
                                while (searchResult.hasNext()) {
                                        

                                        


                                        /*
                                         * TODO: Process the object "user" returned by the search.
                                         * For example, get the display name of the user and display it on the screen.
                                         * Or use it in the next example: showUser(user, "com.example", "myAttributeName");
                                         */
                                }
                        } else {
                                // TODO: Handle incomplete or undefined results.
                        }
                } catch (UMException umex) {
                        // TODO: Handle UMException.
                } catch (UMRuntimeException umrex) {
                        // TODO: Handle UMRuntimeException.
                }

        }

}