Example on how to use User.makeRoleMember() method.
search cancel

Example on how to use User.makeRoleMember() method.

book

Article ID: 54576

calendar_today

Updated On:

Products

CA Directory CA Identity Manager CA Identity Governance CA Identity Portal CA Risk Analytics CA Secure Cloud SaaS - Arcot A-OK (WebFort) CLOUDMINDER ADVANCED AUTHENTICATION CA Secure Cloud SaaS - Advanced Authentication CA Secure Cloud SaaS - Identity Management CA Secure Cloud SaaS - Single Sign On CA Security Command Center CA Data Protection (DataMinder) CA User Activity Reporting

Issue/Introduction

Description:

public java.util.Vector makeRoleMember(Role role, boolean addAccounts, java.lang.String operationID) throws SmApiException

This method (available in r12 only) assigns the current object (user) to the specified role, and optionally to create the associated accounts.(ProvisioningRole only).

Java Doc description for this method is not clear. Some of the parameters (operationID) are not retrievable by documented APIs. This document provide an example on how to use this method.

Solution:

Sample code of an EventListener for ModifyUserEvent:

public class ModifyUserListener extends EventListenerAdapter{
 public int after(EventContext evtCtx) throws Exception {
   try {
      IMEvent evt = evtCtx.getEvent();
      if(evt instanceof UserEvent) {
       User user=((UserEvent)evt).getUser();
       ProvisioningRole prov=evtCtx.getProvisioningRoleProvider().findProvisioningRole("MyRole-LDAP");
       if (evt instanceof IMSEvent) {
           // IMSEvent class undocumented in r12 java doc
           String eventId = ((IMSEvent)evt).getEventId();
          // This is undocumented method in java doc as well 
          String opID = (String)ProvisioningDefinitionImpl.getIMOperationId(eventId);
          Vector msg = user.makeRoleMember(prov, true, opID);
          System.out.print("----- JIAM return: " + msg + " -----");
        }
}
} catch (Exception e) { e.printStackTrace(); } return CONTINUE; } }

Expected output:

2008-11-06 17:44:27,328 INFO [STDOUT] ----- JIAM return: [, , Global User 'testuser03' provisioning role memberships added and associated accounts added or updated successfully: (accounts created: 1, updated: 0, re-created: 0, failures: 0), :ETA_S_0015<AAC>, Account for Global User 'testuser03' on LDAP Endpoint 'IM12GA-TS2_im_ldap_edir' created successfully] -----

Notes:

IMSEvent.getEventId(): this is not documented in r12 Java Doc, this seems to be the only way to retrieve event ID from current context.
ProvisioningDefinitionImpl.getIMOperationId(eventId): this is also not very clear in our java doc. Event ID has to be used as parameter.

Environment

Release:
Component: IDMGR