Friday, 24 August 2012

OIM Code to get the userlist Assocaiated with a resource

public String associatedUsersResource(String resource,String status){


//Pass the resource name as input
//status will be either provisioedor provisioning or disabled
//If we pass * in the status ,it will return all the users assocaited with the resource with all status

HashMap status1=new HashMap();
status1.put("Objects.Object Status.Status", status);
try {
tcResultSet result=prov.getAssociatedUsers(getObjectKey(resource), status1);
for(int i=0;i<=result.getRowCount()-1;i++){
result.goToRow(i);
System.out.println(result.getStringValue("Users.User ID"));
}
} catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcObjectNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcColumnNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return status;
}

Monday, 13 August 2012

Error while updating user



Normally when we update a user ,we used to call findusers and then call a update

tcResultSet moResultSet = moUserUtility.findUsers(userMap);
hmUser.put("Users.User ID", UID);
hmUser.put("Users.Password", pwd);
moUserUtility.updateUser(moResultSet, hmUser);

now if you call a second update like

hmUser.put("Users.User ID", UID);
 hmUser.put("Users.First Name", FN);
moUserUtility.updateUser(moResultSet, hmUser);

it will throw exception like threw Exception Thor.API.Exceptions.tcStaleDataUpdateException which is caused because for the second update it did not call the find users.It should be like

tcResultSet moResultSet = moUserUtility.findUsers(userMap);
hmUser.put("Users.User ID", UID);
 hmUser.put("Users.First Name", FN);
moUserUtility.updateUser(moResultSet, hmUser);

Now the update works fine.