2 Replies Latest reply on Jan 21, 2013 11:39 AM by 958133

    OIM11gR2 Searching Role keys from role names

      Hi Experts,

      I have roles coming in String format "Role1,Role2,Role3",

      I want to fetch their role keys: I am using search criteria function as
      criteria = new SearchCriteria(RoleManagerConstants.ROLE_NAME,"Role1", SearchCriteria.Operator.EQUAL);
      roles = rmgr.search(criteria, attrNames, null);
      In the above code i have to iterate for each and every role one by one.

      Here if I want to use a single search criteria where i could pass this as a single string like
      criteria = new SearchCriteria(RoleManagerConstants.ROLE_NAME,"Role1,Role2,Role3", SearchCriteria.Operator.IN);
      Is it possible? I am trying with IN operator, but it is giving outofbound exception.
      Any Thougths?
        • 1. Re: OIM11gR2 Searching Role keys from role names
          This code should resolve your issue

          private void SearchRoles(String RoleName1,String RoleName2,String RoleName3) {
          List<Role> roles = null;
          HashMap<String, Object> mapParams = null;
          Set<String> attrNames = null;
          RoleManager roleMgr = oimClient.getService(RoleManager.class);

          SearchCriteria searchCriteria = new SearchCriteria(RoleManagerConstants.ROLE_NAME, RoleName1, SearchCriteria.Operator.EQUAL);
          SearchCriteria searchCriteria1 = new SearchCriteria(RoleManagerConstants.ROLE_NAME, RoleName2, SearchCriteria.Operator.EQUAL);
          SearchCriteria searchCriteria2 = new SearchCriteria(searchCriteria, searchCriteria1, SearchCriteria.Operator.OR);
          SearchCriteria searchCriteria3 = new SearchCriteria(RoleManagerConstants.ROLE_NAME,RoleName3, SearchCriteria.Operator.EQUAL);
          SearchCriteria searchCriteria4 = new SearchCriteria(searchCriteria2,searchCriteria3, SearchCriteria.Operator.OR);

          roles = roleMgr.search(searchCriteria4, attrNames, mapParams);

          System.out.println("Total Roles found:"+roles.size());

          for (Role role : roles)

          catch(Exception e) {
          • 2. Re: OIM11gR2 Searching Role keys from role names
            Thanks for replying,,
            I put all the role values in a set like
            Set<string> mapRoleNames= new Hashset ();
            criteria = new SearchCriteria(RoleManagerConstants.ROLE_NAME,mapRoleNames, SearchCriteria.Operator.IN);
            this worked for me.