Previous Topic: Set the Search Filter for ODBC Directories

Next Topic: Examples of a Search

Search an Organization

In the DMS API, searches are performed on an organization object.

To search an organization:

  1. Create a search object. This search object holds the search parameters.

    For example, the following SmDmsSearch constructor call creates a search object to search for groups. The root parameter specifies a start point of o=swdev.org.

    SmDmsSearch mySearch = new SmDmsSearch (
               "(&(objectclass=organizationalUnit) (ou=groups))",
                "o=swdev.org");
    

    Note: The root is the top level of the SiteMinder user directory to search. It is not necessarily the top level of the entire directory structure.

    Use the set... methods in the SmDmsSearch class to set any other search parameters—for example:

    mySearch.setScope(2);
    
  2. Optionally, define sorting and paging preferences in the SmDmsCursor object.
  3. Call the search() method in class SmDmsOrganization on the organization you want to search—for example:
    result = targetOrg.search (mySearch, 1);
    

    The second parameter of the search() method indicates the direction to search, as shown in the following table:

Direction

Integer Value

Reset

0

Forward

1

Back

2

Refresh

3

  1. To get the items returned from the search, call getResults() on the search object—for example:
    Vector mySearchResults = search.getResults();
    

    The first element of the results vector contains the search parameters in a SmDmsSearchResultParams object. The remaining elements are SmDmsObject objects. To distinguish object types, the classId attribute of each object is set through the setClassId() method. For example, if the classId is DMSOBJECT_CLASS_USER, the object is a user. If the classId is DMSOBJECT_CLASS_GROUP, the object is a group.