- package com.oimacademy.NeedEvaluate;
- import java.lang.annotation.AnnotationTypeMismatchException;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.List;
- import javax.faces.validator.ValidatorException;
- import javax.management.RuntimeErrorException;
- import javax.security.auth.login.LoginException;
- import oracle.iam.identity.exception.NoSuchUserException;
- import oracle.iam.identity.exception.UserLookupException;
- import oracle.iam.identity.exception.UserSearchException;
- import oracle.iam.platform.OIMClient;
- import oracle.iam.platform.entitymgr.vo.SearchCriteria;
- import oracle.iam.provisioning.api.ProvisioningConstants;
- import oracle.iam.provisioning.api.ProvisioningService;
- import oracle.iam.provisioning.exception.ApplicationInstanceNotFoundException;
- import oracle.iam.provisioning.exception.GenericAppInstanceServiceException;
- import oracle.iam.provisioning.exception.GenericProvisioningException;
- import oracle.iam.provisioning.exception.UserNotFoundException;
- import oracle.iam.provisioning.vo.Account;
- import Thor.API.tcResultSet;
- import Thor.API.Operations.tcLookupOperationsIntf;
- import Thor.API.Operations.tcUserOperationsIntf;
- import Thor.API.Security.XLClientSecurityAssociation;
- public class GetAccountListsFromLoggedInUser {
- public GetAccountListsFromLoggedInUser() {
- super();
- }
- public static void main(String[] args) throws Exception, AnnotationTypeMismatchException {
- System.out.println("In Main Method ....!!!!!");
- GetAccountList();
- }
- public static boolean GetAccountList() throws GenericProvisioningException, UserSearchException, UserNotFoundException, RuntimeErrorException, NullPointerException, LoginException, GenericAppInstanceServiceException, ApplicationInstanceNotFoundException, ClassNotFoundException,
- NoSuchUserException, UserLookupException, ValidatorException {
- String ctxFactory = "weblogic.jndi.WLInitialContextFactory";
- System.setProperty("APPSERVER_TYPE", "wls");
- Hashtable env = new Hashtable();
- env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);
- env.put(OIMClient.APPSERVER_TYPE_WEBLOGIC,"wls");
- //Establishing OIM Client
- OIMClient oimClient =new OIMClient(env);
- try{
- XLClientSecurityAssociation.setClientHandle(oimClient);
- }catch(Exception e) {
- System.out.println(e);
- }
- String descriptionArray[] = new String[50];
- Long accountIdArray[] = new Long[50];
- int z3 =0;
- try {
- boolean isAccountExist = false;
- ProvisioningService proSer = oimClient.getService(ProvisioningService.class);
- tcUserOperationsIntf userOps = oimClient.getService(tcUserOperationsIntf.class);
- tcResultSet rs = userOps.getSelfProfile();
- String usrKey = rs.getStringValue("Users.Key");
- String userLogin = rs.getStringValue("Users.User ID");
- SearchCriteria provisionedCriterion = new SearchCriteria(ProvisioningConstants.AccountSearchAttribute.ACCOUNT_STATUS.getId(), ProvisioningConstants.ObjectStatus.PROVISIONED.getId(), SearchCriteria.Operator.EQUAL);
- System.out.println("User Logged In::"+userLogin+"::usrKey::"+usrKey);
- List<Account> provInstList = proSer.getAccountsProvisionedToUser(usrKey, provisionedCriterion, new HashMap<String,Object>(), true);
- System.out.println("Prov List::"+provInstList.toString()); // used to print the Accounts provisioned list
- tcLookupOperationsIntf lookupIntf = oimClient.getService(tcLookupOperationsIntf.class);
- tcResultSet lookupVal = lookupIntf.getLookupValues("Lookup.OID.Accounts");
- for(Account ac : provInstList){
- String accountID = ac.getAccountID();
- System.out.println("Account ID::"+accountID);
- long accountId = Long.parseLong(accountID);
- String description= ac.getAppInstance().getDescription();
- System.out.println("Account ID::"+accountID);
- for(int i=0;i<lookupVal.getRowCount();i++){
- lookupVal.goToRow(i);
- if(lookupVal.getStringValue("Lookup Definition.Lookup Code Information.Code Key").equalsIgnoreCase(description)){
- descriptionArray[z3] = description;
- accountIdArray[z3] = accountId;
- isAccountExist = true;
- z3++;
- }
- }
- }
- for(int x1 =0; descriptionArray[x1]!=null| accountIdArray[x1]!=null; x1++){
- System.out.println(descriptionArray[x1]);
- System.out.println(accountIdArray[x1]);
- }
- return isAccountExist;
- } catch (Exception e) {
- System.out.println(e);
- return false;
- }
- }
- }
Oracle Identity Manager(OIM) is the Provisioning Solution from oracle. This page contains an index with references to all OIM related posts in the oracle identity manager Academy blog. The posts included herein are intended to provide oracle identity management customers and developers with technical information about best practices for implementing OIM based solutions.
OIM API To Get Accounts List From Logged In User
Subscribe to:
Post Comments (Atom)
-
Connection Related API's : OIM DB Connection/ Data Source connection OIMClient API / OIMConnection API OIM Platform API to getSer...
-
Error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframewor...
-
In this post, we set the middle name as “MiddleName” if user does not provide middle name during user create operation. Below are high...
Your blog is big and there is a lot of good information! Thanks This Iam Solutions easy-to-use active directory user termination tool allows IT administrators to automate common tasks when an employee leaves the company. Try out today!
ReplyDeleteCan we get the reverse? I am doing reconciliation from target system and need to find out the user key from the account id coming from target system. Thanks for the help
ReplyDelete