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


Get group members

Use the get(DataObject) method and the GroupMemberControl to show what entities belong to a group.


About this task

In this example, the request is to show the members of a group, Employee.

To request the members that belong to Employee, add this sample code to the application code and replace the variables with the actual values to use:

DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_GROUP);
entity.createDataObject(DO_IDENTIFIER).set(PROP_UNIQUE_NAME,
                  "cn=Employee,cn=groups,dc=yourco,dc=com");
DataObject propCtrl = SDOHelper.createControlDataObject(root, null, DO_PROPERTY_CONTROL);
propCtrl.getList(PROP_PROPERTIES).add("cn");
DataObject grpMbrCtrl = SDOHelper.createControlDataObject(root, null,
               DO_GROUP_MEMBER_CONTROL);
// Retrieve cn and uid attributes for all members
grpMbrCtrl.getList(PROP_PROPERTIES).add("cn");
grpMbrCtrl.getList(PROP_PROPERTIES).add("uid");
// retrieve nested members
grpMbrCtrl.setInt(PROP_LEVEL, 0);

root = service.get(root);


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:entities xsi:type="wim:Group">
<wim:identifier uniqueName="cn=Employee,cn=groups,dc=yourco,dc=com"/>
</wim:entities>
<wim:controls xsi:type="wim:PropertyControl">
<wim:properties>cn
</wim:properties>
</wim:controls>
<wim:controls xsi:type="wim:GroupMemberControl" level="0">
<wim:properties>cn
</wim:properties>
<wim:properties>uid
</wim:properties>
</wim:controls>
</wim:Root>
</sdo:datagraph> 

The resulting 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:Group">
<wim:identifier externalName="cn=Employee,cn=groups,dc=yourco,dc=com"
                      repositoryId="LDAP1"
                      uniqueId="46f31f7d-dddd-4930-83dd-126de9bb667d"
                      uniqueName="cn=Employee,cn=groups,dc=yourco,dc=com"/>
<wim:cn>Employee
</wim:cn>
<wim:members xsi:type="wim:Group">  
<wim:identifier externalName="cn=Managers,cn=groups,dc=yourco,dc=com"
                        repositoryId="LDAP1"
                        uniqueId="6e45af37-bc3f-4260-af27-666e1ebdbda2"
                        uniqueName="cn=Managers,cn=groups,dc=yourco,dc=com"/>  
<wim:cn>Managers
</wim:cn>
</wim:members>
<wim:members xsi:type="wim:Group">  
<wim:identifier externalName="cn=Admins,cn=groups,dc=yourco,dc=com"
                        repositoryId="LDAP1"
                        uniqueId="73dc5d64-be44-4db0-9697-9a69056eb699"
                        uniqueName="cn=Admins,cn=groups,dc=yourco,dc=com"/>  
<wim:cn>Admins
</wim:cn>
</wim:members>
<wim:members 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:cn>Sales Person1
</wim:cn>
</wim:members>
<wim:members 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:cn>Sales Person2
</wim:cn>
</wim:members>
<wim:members 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:cn>Sales Person3
</wim:cn>
</wim:members>
<wim:members 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:cn>Sales Person4
</wim:cn>
</wim:members>
<wim:members xsi:type="wim:PersonAccount">  
<wim:identifier externalName="uid=SalesManager,cn=users,dc=yourco,dc=com"
                        repositoryId="LDAP1"
                        uniqueId="5e846c20-a1b4-4bfc-bce2-1f841d762f9a"
                        uniqueName="uid=SalesManager,cn=users,dc=yourco,dc=com"/>  
<wim:uid>SalesManager
</wim:uid>  
<wim:cn>Sales Manager </wim:cn>
</wim:members>
<wim:members xsi:type="wim:PersonAccount">  
<wim:identifier externalName="uid=Admin,cn=users,dc=yourco,dc=com"
                        repositoryId="LDAP1"
                        uniqueId="38dc5508-bf68-44d8-bcb1-da23f6cd009a"
                        uniqueName="uid=Admin,cn=users,dc=yourco,dc=com"/>  
<wim:uid>Admin
</wim:uid>  
<wim:cn>Administrator
</wim:cn>
</wim:members>
</wim:entities>
</wim:Root>
</sdo:datagraph> 

For end-to-end sample code, see the topic, Sample code for working with users, groups, group members, and group memberships.

Parent topic: Program tasks
GroupMemberControl DataObject


Related


get method

+

Search Tips   |   Advanced Search