Get Identity Roles

Which IIQ version are you inquiring about?

8.2

Hi Community,
I am trying to get list of assigned roles and modify the plan via WebServiceBeforeOperationRule but identityName is not getting resolved and throwing undefined argument identityName error.

If i hardcode the name it works fine and gives me list of roles

Identity iden = context.getObjectByName(Identity.class, "identityName123");
 List<Bundle> detectedRole =iden.getDetectedRoles();
 log.error("List of detedted roles  " +identityDetectedRoles.size());

  List<Bundle> assignedRole =iden.getDetectedRoles();
  log.error("List of assigned roles  " +identityAssignedRoles.size());

Below is code snippet using throws undefined argument identityName

  import org.json.JSONArray;
  import org.json.JSONObject;
  import sailpoint.tools.Util;
  import sailpoint.object.*;
  import sailpoint.connector.webservices.EndPoint;
  import sailpoint.connectorDependencies.EndPoint;
  import sailpoint.object.Identity;
  import sailpoint.object.ProvisioningPlan.*;
  import sailpoint.object.ProvisioningPlan;
  import sailpoint.object.ProvisioningPlan.AccountRequest;
  import sailpoint.object.ProvisioningPlan.AttributeRequest;
  import java.util.Map;

 AccountRequest accReq = provisioningPlan.getAccountRequest("UMS GBP");
  if (accReq != null) {
    String nativeIdentity = accReq.getNativeIdentity();
    log.error("nativeIdentity====== "+nativeIdentity);
    Identity identity = context.getObjectByName(Identity.class,identityName);
    //String identityName = identity.getName();
    log.error("identityValue========= "+identity);
    if (identity != null) {
      List<Bundle> roles = identity.getAssignedRoles();
      log.error("list of roles >>>>>>>> "+roles);
      if (roles != null) {
        log.error("roles size >>> "+roles.size());
      }
    }
  }

Hi @shivakarasani199
I think you missed to initialize identityName. So please initialize it if you are getting the name from plan use the below.

identityName = provisioningPlan.getNativeIdentity();```
//After that you can use it get the identity object
Identity iden = context.getObjectByName(Identity.class, identityName);

thanks

1 Like