Which IIQ version are you inquiring about?
Version 8.1
Share all details related to your problem, including any error messages you may have received.
Hello,
I wrote this code to remove negative=true from all the identities that have Active iiqStatus and Active orgstatus. But got a comment that this will work only for one identity.
Can anyone help me to clear me this confusion?
List bundleNames = new ArrayList();
List idenNames = new ArrayList();
QueryOptions qo = new QueryOptions();
//qo.setCloneResults(true); // this will stop iterator being closed on a commitTransaction()
qo.addFilter(Filter.and(Filter.eq("iiqStatus", "Active"),Filter.eq("orgStatus", "Hired")));
List userList = new ArrayList();
Iterator it = context.search(Identity.class, qo);
while (it.hasNext()) {
Identity identityObj = it.next();
userList.add(identityObj);
//return identityObj;
List negroleAssignments = identityObj.getRoleAssignments();
//return negroleAssignments;
if (identityObj !=null)
{
List roleAssignments = identityObj.getRoleAssignments(); // getRoleAssignment methods returns the list of role assignment under the user
//return roleAssignments;
if (roleAssignments!= null) // check if roleAssignments exists in Identity
{ //return "not null";
for(RoleAssignment ra : roleAssignments)
{ //return ra;
if(ra !=null && ra.isNegative())
{
bundleNames.add(ra.getRoleName());
}
}
}
for (String b:bundleNames)
{
negroleAssignments = identityObj.getRoleAssignments(b);
Bundle bundl = context.getObjectByName(Bundle.class,b);
identityObj.removeAssignedRole(bundl);
if(negroleAssignments != null)
{
for(RoleAssignment negrole : negroleAssignments)
{
identityObj.removeRoleAssignment(negrole);
//context.log("Negative Role Assignment has been removed");
}
idenNames.add(identityObj.getName());
}
}
context.saveObject(identityObj);
context.commitTransaction();
}
}
if(idenNames != null && !idenNames.isEmpty())
return"Negative role assignment has been removed:"+ idenNames;
return bundleNames;