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
Create a group with an initial member
Use the create(DataObject) method to create a group with an initial person assigned to that group.
About this task
Use the create method to create a group entity. This example shows how to create Group Admins and assign an existing person, Person Admin, to it. The Group Admins is created under “cn=groups,dc=yourco,dc=com”. The unique name of the parent is passed in from the parent property.To create a group and assign an existing person to that group add the following sample code to the application code and replace the variables with the actual values to use for this entity:
DataObject root = service.createRootDataObject(); DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_GROUP); entity.set("cn", "Admins"); entity.createDataObject(DO_MEMBERS).createDataObject(DO_IDENTIFIER). setString(PROP_UNIQUE_NAME, "uid=Admin,cn=users,dc=yourco,dc=com"); root = service.create(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:cn>Admins </wim:cn> <wim:members> <wim:identifier uniqueName="uid=Admin,cn=users,dc=yourco,dc=com"/> </wim:members> </wim:entities> </wim:Root> </sdo:datagraph>The resulting output 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 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: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.
What to do next
To verify that your entry was created, you can perform a search on Group Admins and view its members.
Parent topic: Program tasks
Get group membership
Assign entities to a group
Assign an entity to multiple groups
Related
create method