Express (Distributed operating systems), v8.0 > Secure applications and their environment > Authenticate users > Select a registry or repository > Manage realms in a federated repository > Virtual member manager > Develop with virtual member manager > Integrate virtual member manager into the application > Program tasks


Performing a search

Use the search(DataObject) method to return a set of entities that match the search expression.


About this task

The virtual member manager search function returns a set of entities that match the search expression. The controls that related to search are SearchControl, PageControl, SortControl, PageResponseControl, and SortResponseControl. Use the SearchControl DataObject to pass the search expression and return property list into the virtual member manager service. This example code shows how to get the uid and sn properties of all the person entities. In this example, the paged and sorted search function are not used.

In this example, the paged and sorted search functions are not used.

To get the uid and sn properties of all the person entities, add the following sample code to the application code and replace the variables with the actual values to use for this search:

DataObject root = SDOHelper.createRootDataObject();
 DataObject searchCtrl = SDOHelper.createControlDataObject(root, null, DO_SEARCH_CONTROL);
 searchCtrl.getList(PROP_PROPERTIES).add("uid");
searchCtrl.getList(PROP_PROPERTIES).add("sn");
 searchCtrl.getList(PROP_SEARCH_BASES).add("o=Sales,cn=users,dc=yourco,dc=com");
 searchCtrl.setString(PROP_SEARCH_EXPRESSION, "@xsi:type='PersonAccount' and uid='*'");

 root = service.search(root);

  1. If a property is applicable only to a particular repository and to include that property in a search expression, specify the searchbase in the search control to perform the search only in that repository. For example propInDB is only applicable to a database repository. If you wanted to search on propInDB='abc', specify the searchbase for that database repository.

  2. If the actual search value contains a character such as an asterisk ( * ) that can also be used as a wild card, for example "hobby=abc*de", the character must be escaped using a backslash ( \ ), "hobby=abc\*de".


Sample input and output data graphs

For this particular example the input data graph is:

<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
               xmlns:sdo="commonj.sdo"
               xmlns:wim="//www.ibm.com/websphere/wim">
<wim:Root>
<wim:controls xsi:type="wim:SearchControl"
         expression="@xsi:type='PersonAccount' and uid='*'">
<wim:properties>uid
</wim:properties>
<wim:properties>sn
</wim:properties>
<wim:searchBases>o=Sales,cn=users,dc=yourco,dc=com
</wim:searchBases>
</wim:controls>
</wim:Root>
</sdo:datagraph> 

A sample output data graph for this example is:

<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
               xmlns:sdo="commonj.sdo"
               xmlns:wim="//www.ibm.com/websphere/wim">
<wim:Root>
<wim:entities xsi:type="wim:PersonAccount">
<wim:identifier externalName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1"
                      uniqueId="13ae346f-1e4c-40cd-8896-1c7f0b2b3079"
                      uniqueName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson3
</wim:uid>
<wim:sn>SalesPerson3Sn
</wim:sn>
</wim:entities>
<wim:entities xsi:type="wim:PersonAccount">
<wim:identifier externalName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1"
                      uniqueId="a2d1be42-212e-44f0-8396-0bfc2d7d346d"
                      uniqueName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson4
</wim:uid>
<wim:sn>SalesPerson4Sn
</wim:sn>
</wim:entities>
<wim:entities xsi:type="wim:PersonAccount">
<wim:identifier externalName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1"
                      uniqueId="a3f9e8a1-117a-4252-840f-6d0cb079a7fb"
                      uniqueName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson2
</wim:uid>
<wim:sn>SalesPerson2Sn
</wim:sn>
</wim:entities>
<wim:entities xsi:type="wim:PersonAccount">
<wim:identifier externalName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1"
                      uniqueId="e7db8c0e-d2b3-43fe-be14-1475125606f4"
                      uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:uid>SalesPerson1
</wim:uid>
<wim:sn>SalesPerson1Sn
</wim:sn>
</wim:entities>
</wim:Root>
</sdo:datagraph> 

Also see the topics, Sample code for performing a paged search with sorted results and Sample code for searching using search bases.

Parent topic: Program tasks
PageControl DataObject
PageResponseControl DataObject
SearchControl DataObject


Related


search method

+

Search Tips   |   Advanced Search