OIM API to Assign Mutiple RolesToUser

package com.massiveGaze.role;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import oracle.iam.identity.rolemgmt.api.RoleManager;
import oracle.iam.identity.rolemgmt.vo.Role;

import com.massiveGaze.connection.Platform;
public class AssignMutipleRolesToUser {

 public static void main(String[] args) throws Exception {
  String ROLE_NAME_PREFIX = "MyRole*";
   RoleManager roleMgr = Platform.getService(RoleManager.class);
  List<Role> roleList = new SearchRole().searchRoleConfigParams(ROLE_NAME_PREFIX);
  Set userKeys = new HashSet();
  userKeys.add("5005");
  for(Role role: roleList){
     roleMgr.grantRole(role.getEntityId(),userKeys); 
     System.out.println("Granted role -> "+role.getEntityId()+ " To user -> "+userKeys);
  }
 }

}

No comments:

Post a Comment

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts