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

Document ID : KB000054576
Last Modified Date : 14/02/2018
Show Technical Document Details


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.


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] -----


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.