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 membership

Use the get(DataObject) method and the GroupMembershipControl to show what groups an entity belongs to.


About this task

In this example, the request is to show the groups that Person SalesManager belongs to.

To request the groups that Person SalesManager belongs to, add this sample code to the application code and replace the variables with the actual values to use for this entity:

DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null,
                         DO_PERSON_ACCOUNT);
entity.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME,
                      "uid=SalesManager,cn=users,dc=yourco,dc=com");
DataObject grpMbrshipCtrl = SDOHelper.createControlDataObject(root, null,
                         DO_GROUP_MEMBERSHIP_CONTROL);
// Retrieve cn attribute for all groups
grpMbrshipCtrl.getList(PROP_PROPERTIES).add("cn");

DataObject outRoot = 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:PersonAccount">
<wim:identifier uniqueName="uid=SalesManager,cn=users,dc=yourco,dc=com"/>
</wim:entities>
<wim:controls xsi:type="wim:GroupMembershipControl">
<wim:properties>cn
</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: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:groups>  
<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:groups>
</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
GroupMembershipControl DataObject


Related


get method

+

Search Tips   |   Advanced Search