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 an entity
Use the create(DataObject) method to create an entity.
About this task
Use the create method to create any of the entity data object types that are supported by virtual member manager. This particular example shows how to create a PersonAccount entity, Person Admin under the container cn=users,dc=yourco,dc=com. The uniqueName of the parent is defined in the virtual member manager configuration file as the default parent for entity type, PersonAccount. In this case, you do not have to specify the parent property in the input data object.To create a PersonAccount entity, add the following sample code to your 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.set("uid", "Admin"); entity.set("cn", "Administrator"); entity.set("sn", "AdminSn"); 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:PersonAccount"> <wim:uid>Admin </wim:uid> <wim:cn>Administrator </wim:cn> <wim:sn>AdminSn </wim:sn> </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:PersonAccount"> <wim:identifier externalName="uid=Admin,cn=users,dc=yourco,dc=com" repositoryId="LDAP1" uniqueId="38dc5508-bf68-44d8-bcb1-da23f6cd009a" uniqueName="uid=Admin,cn=users,dc=yourco,dc=com"/> </wim:entities> </wim:Root> </sdo:datagraph>Notice that the PersonAccount entity for Person Admin has a virtual member manager identifier consisting of an external name, a repository ID, a unique ID, and a unique name.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 use the search or get methods to retrieve information about Person Admin.
Parent topic: Program tasks
Entity DataObject
Related
create method