OIM API To Search Accounts/Entitlements based on Input Value


  1. package com.oimacademy.provision;
  2. import java.util.HashMap;
  3. import java.util.Set;
  4. import oracle.iam.platform.entitymgr.vo.SearchCriteria;
  5. import oracle.iam.provisioning.api.ProvisioningConstants;
  6. import oracle.iam.provisioning.api.ProvisioningServiceInternal;
  7. import oracle.iam.provisioning.impl.ProvisioningServiceInternalImpl;
  8. import com.oimacademy.connection.Platform;
  9. public class SearchAccounts {
  10.  private static ProvisioningServiceInternal provisioningServiceInt=Platform.getService(ProvisioningServiceInternal.class);
  11.  public static void main(String[] args) {
  12.   HashMap<String, String> controls = new HashMap<String, String>();
  13.   SearchCriteria crit1 = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.APPINST_NAME.getId(),"ABC",SearchCriteria.Operator.EQUAL);
  14.   SearchCriteria crit2 = new SearchCriteria(ProvisioningConstants.EntitlementInstanceSearchAttribute.ENTITLEMENT_ID.getId(), "XYZ",SearchCriteria.Operator.EQUAL);
  15.   SearchCriteria sc1 = new SearchCriteria(crit1, crit2,SearchCriteria.Operator.OR);
  16.   SearchCriteria crit3 = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.APPINST_ID.getId(),"",SearchCriteria.Operator.EQUAL);
  17.   SearchCriteria crit4 = new SearchCriteria(ProvisioningConstants.EntitlementInstanceSearchAttribute.ENTITLEMENT_CODE.getId(), "",SearchCriteria.Operator.EQUAL);
  18.   SearchCriteria sc2 = new SearchCriteria(crit3, crit4,SearchCriteria.Operator.OR);
  19.   SearchCriteria sc3 = new SearchCriteria(sc1, sc2,SearchCriteria.Operator.AND);  
  20.   controls = new HashMap<String, String>();
  21.   controls.put("Auditable", "false");  
  22.   Set<String> uniqueUsersBasedOnSearchCriteria = provisioningServiceInt.getUniqueUsersBasedOnSearchCriteria(sc3, controls);  
  23.   SearchCriteria sc4 = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.USER_ID.getId(),uniqueUsersBasedOnSearchCriteria, SearchCriteria.Operator.IN);
  24.   SearchCriteria sc5 = new SearchCriteria(sc3, sc4,SearchCriteria.Operator.AND);
  25.   controls = new HashMap<String, String>();
  26.   controls.put("Auditable", "true");
  27.   provisioningServiceInt.searchAccounts(crit1, controls);
  28.  }
  29. }

No comments:

Post a Comment