Use the login(DataObject) method and LoginControl to authenticate a user.
This example shows how to authenticate using a PersonAccount object with a principalName and password.
try { DataObject root = SDOHelper.createRootDataObject(); DataObject paccount = SDOHelper.createEntityDataObject(root, null, DO_PERSON_ACCOUNT); paccount.set(PROP_PRINCIPAL_NAME, "bob"); paccount.set(Service.PROP_PASSWORD, com.ibm.websphere.wim.util.PasswordUtil.getByteArrayPassword("mypassword")); DataObject loginCtrl = SDOHelper.createControlDataObject(root, null, DO_LOGIN_CONTROL); loginCtrl.getList(PROP_SEARCH_BASES).add("cn=users,dc=yourco,dc=com"); loginCtrl.getList(PROP_PROPERTIES).add("uid"); loginCtrl.getList(PROP_PROPERTIES).add("cn"); root = service.login(root); } catch (WIMException e) { e.printStackTrace(); }
<?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:principalName>bob</wim:principalName> <wim:password>KioqKg==</wim:password> </wim:entities> <wim:controls xsi:type="wim:LoginControl"> <wim:searchBases>cn=users,dc=yourco,dc=com</wim:searchBases> <wim:properties>cn</wim:properties> <wim:properties>uid</wim:properties> </wim:controls> </wim:Root> </sdo:datagraph>
<?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"> <changeSummary/> <Root> <entities xsi:type="PersonAccount"> <identifier uniqueId="f0cf975b-eca8-4331-8a70-6b90556f4f65" uniqueName="accountName=bob,cn=users,dc=yourco,dc=com"> <cn>bob W</cn> <uid>bob</uid> </entities> </Root> </sdo:datagraph>