Pages

Tuesday, April 22, 2014

Revoking OIM Resource


Revoking the OIM Resource pro-grammatically as follows:



Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get the service objects

UserManager userManager=client.getService(UserManager.class);
tcUserOperationsIntf tcUserOperationsIntf= client.getService(tcUserOperationsIntf.class);

3.  Retrieving the User Details. 

String userId="testabc";
User user=userManager.getDetails(userId, null, true);



4.  Retrieving the User Key. 

long userKey=-1;
if(user != null)
{
userKey=new Long(user.getEntityId());
}

           

5.  Retrieving the User Provisioned Resources. 

Map<String,Long> resources= new HashMap<String,Long> ();

if(userKey !=-1)
{
   tcResultSet rs= tcUserOperationsIntf.getObjects(usrKey);
 
            if(rs != null)
            {
                int count=rs.getTotalRowCount();
                for(int i=0;i<count;i++)
                {
                        rs.goToRow(i);
                        String resourceName=rs.getStringValue("Objects.Name");
                        String status=rs.getStringValue("Process Instance.Status");
                        long instanceKey=rs.getLongValue("Users-Object Instance For User.Key");
                        long processInstanceKey=rs.getLongValue("Process Instance.Key");
                        String resourceStatus=rs.getStringValue("Objects.Object Status.Status");
                        if( (resourceStatus != null && (resourceStatus.equalsIgnoreCase("provisioned") ||
                                 resourceStatus.equalsIgnoreCase("disabled") ||
                                 resourceStatus.equalsIgnoreCase("enabled") ) )||
                                 (status != null && status.equalsIgnoreCase("c")))
                        {
                             resources.put(resourceName,instanceKey);
                        }
                }
            }
}

6.  Revoke a Resource.

String resourceName="AD User";
if(resources.containsKey(resourceName))
{

tcUserOperationsIntf.revokeObject(userKey, resources.get(resourceName));


No comments:

Post a Comment