Getting group membership
Use the get(DataObject) method and the GroupMembershipControl to show what groups an entity belongs to.
About this task
To request the groups that Person SalesManager
belongs to, add this sample code to your application code and replace
the variables with the actual values that you want 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="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sdo="commonj.sdo"
xmlns:wim="http://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="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sdo="commonj.sdo"
xmlns:wim="http://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.