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


Unassigning entities from groups using GroupMembershipControl

Use the update(DataObject) method and GroupMembershipControl to remove one or more entities from one or more groups.


About this task

This example shows how to unassign or remove SalesPerson1 from the groups Admins and Managers.

To remove SalesPerson1 from the groups Admins and Managers, add this sample code to you application code and replace the variables with the actual values that to use for this request:

DataObject toot = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_ENTITY);
entity.createDataObject(DO_IDENTIFIER).set(PROP_UNIQUE_NAME,
            "uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com");

DataObject grp1 = SDOHelper.createDataObject(WIM_NS_URI, DO_GROUP);
grp1.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME,
            "cn=Admins,cn=groups,dc=yourco,dc=com");

DataObject grp2 = SDOHelper.createDataObject(WIM_NS_URI, DO_GROUP);
grp2.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME,
            "cn=Managers,cn=groups,dc=yourco,dc=com");

entity.getList(DO_GROUPS).add(grp1);
entity.getList(DO_GROUPS).add(grp2);

DataObject grpMbrCtrl = SDOHelper.createControlDataObject(root, null, DO_GROUP_MEMBERSHIP_CONTROL);
// Unassign mode grpMbrCtrl.setInt(PROP_MODIFY_MODE, VALUE_MODIFY_MODE_UNASSIGN);

root = service.update(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>
<wim:identifier uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
<wim:groups>  
<wim:identifier uniqueId="73dc5d64-be44-4db0-9697-9a69056eb699"/>
</wim:groups>
<wim:groups>  
<wim:identifier uniqueName="cn=Managers,cn=groups,dc=yourco,dc=com"/>
</wim:groups>
</wim:entities>
<wim:controls xsi:type="wim:GroupMembershipControl" modifyMode="3"/>
</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 externalId="e7db8c0e-d2b3-43fe-be14-1475125606f4"
                      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:entities>
</wim:Root>
</sdo:datagraph> 

Also see the topic, Sample code for removing users from a group.

Parent topic: Program tasks
GroupMembershipControl DataObject
PropertyControl DataObject
Update the properties of an entity


Related


update method

+

Search Tips   |   Advanced Search