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 the ancestors of an entity
Use the get(DataObject) method and the AncestorControl to show the ancestors of an entity.
About this task
This is the hierarchical structure for SalesPerson1:
- cn=users,dc=yourco,dc=com
- o=Sales
- ou=CA
- uid=SalesPerson1
- ou=US
- ou=Europe
In this example, the request is to show all levels of ancestors for SalesPerson1.
To request all levels of ancestors for SalesPerson1, add this sample code to the application code and replace the variables with the actual values that you want to use for this request:
DataObject root = SDOHelper.createRootDataObject(); DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_PERSON_ACCOUNT); entity.createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME, "uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"); DataObject ancesCtrl = SDOHelper.createControlDataObject(root, null, DO_ANCESTOR_CONTROL); // 0 means all ancestors ancesCtrl.setInt(PROP_LEVEL, 0); ancesCtrl.getList(PROP_PROPERTIES).add("uid"); ancesCtrl.getList(PROP_PROPERTIES).add("cn"); ancesCtrl.getList(PROP_PROPERTIES).add("o"); ancesCtrl.getList(PROP_PROPERTIES).add("ou"); 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:PersonAccount"> <wim:identifier uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/> </wim:entities> <wim:controls xsi:type="wim:AncestorControl" level="0"> <wim:properties>uid </wim:properties> <wim:properties>cn </wim:properties> <wim:properties>o </wim:properties> <wim:properties>ou </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=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:parent xsi:type="wim:OrgContainer"> <wim:identifier externalId="0dfcccf7-9fb9-4b25-a0f4-ff4b6b33068e" externalName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com" repositoryId="LDAP1" uniqueName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/> <wim:parent xsi:type="wim:OrgContainer"> <wim:identifier externalId="eab85abb-9d29-40f1-b502-36c051d3ee96" externalName="o=Sales,cn=users,dc=yourco,dc=com" repositoryId="LDAP1" uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/> <wim:parent xsi:type="wim:OrgContainer"> <wim:identifier externalId="93fde597-b628-4952-90cc-d6b178a05235" externalName="cn=users,dc=yourco,dc=com" repositoryId="LDAP1" uniqueName="cn=users,dc=yourco,dc=com"/> <wim:cn>users </wim:cn> </wim:parent> <wim:o>Sales </wim:o> </wim:parent> <wim:ou>CA </wim:ou> </wim:parent> </wim:entities> </wim:Root> </sdo:datagraph>CA, Sales, users, and dc=yourco.dc=com are returned as the ancestors of SalesPerson1.Also see the topic, Sample code for creating an entity in a hierarchy and getting descendants and ancestors.
Parent topic: Program tasks
AncestorControl DataObject
Related
get method