8 Replies Latest reply: Feb 22, 2013 1:38 AM by 965440 RSS

    List of all roles a user belong

    sjit
      Hi,
      I want to get a list of all roles a user belongs to using OIM 11g API.
      oracle.iam.identity.usermgmt.api.UserManager
      oracle.iam.identity.rolemgmt.api.RoleManager

      A sample code will be highly helpful.

      Thanks
        • 1. Re: List of all roles a user belong
          Nishith Nayan
          One I remember in 10g

          tcUserOperationIntf.getGroups(long plUserKey)

          try same one if it works.
          I will look at 11gAPI and let you know
          • 2. Re: List of all roles a user belong
            Nishith Nayan
            find the 11g API


            RoleManager.getUserMemberships


            verify below code:

            import oracle.adf.share.logging.ADFLogger;

            import oracle.iam.identity.exception.NoSuchRoleGrantException;
            import oracle.iam.identity.exception.RoleGrantLookupException;
            import oracle.iam.identity.exception.UserMembershipException;
            import oracle.iam.identity.rolemgmt.api.RoleCategoryManager;
            import oracle.iam.identity.rolemgmt.api.RoleManager;
            import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
            import oracle.iam.identity.rolemgmt.vo.Role;
            import oracle.iam.identity.usermgmt.vo.User;
            import static oracle.iam.identity.utils.Constants.SEARCH_ENDROW;
            import static oracle.iam.identity.utils.Constants.SEARCH_STARTROW;
            import oracle.iam.platform.entitymgr.vo.SearchCriteria;
            import oracle.iam.platform.entitymgr.vo.SearchCriteria.Operator;
            import oracle.iam.ui.platform.model.config.ConstantsDefinition;


            public static final String ROLE_NAME = RoleManagerConstants.ROLE_NAME;
            public static final String ROLE_KEY = RoleManagerConstants.ROLE_KEY;


            private List<Role> getRoles(String userKey) {
            SearchCriteria criteria =
            new SearchCriteria(ROLE_NAME, ConstantsDefinition.WILDCARD, Operator.EQUAL);
            HashMap<String, Object> configParams = new HashMap<String, Object>();
            configParams.put(SEARCH_STARTROW, 0);
            configParams.put(SEARCH_ENDROW, 200);

            List<Role> roles = new ArrayList<Role>();


            try {
                      RoleManager roleMgr=Platform.service(RoleManager.class);
            roles.addAll(roleMgr.getUserMemberships(userKey,
            criteria, null,
            configParams, true));




            } catch (Exception eUserMembershipException e) {
            logger.info(e);
            }
            return roles;
            }
            • 3. Re: List of all roles a user belong
              sjit
              Thanks.

              Which jar contains the below class

              oracle.iam.ui.platform.model.config.ConstantsDefinition;


              Thanks
              • 4. Re: List of all roles a user belong
                Karthik Perath
                If you are using JDeveloper IDE to develop this program you can get these libraries in <OIM_HOME>/jdev.lib.

                This particular import is available in OIM Model Shared Library.library in jdev.lib folder. Add these librares to classpath of your project.
                • 5. Re: List of all roles a user belong
                  sjit
                  Thanks Karthik.
                  Can you please tell me how can I add these in Eclipse.
                  • 6. Re: List of all roles a user belong
                    Nishith Nayan
                    for the time use "*" instead of ConstantsDefinition.WILDCARD and move ahead
                    • 7. Re: List of all roles a user belong
                      sjit
                      Thanks a Lot Nishith..
                      • 8. Re: List of all roles a user belong
                        965440
                        Hi karthik,

                        I also wanted to kow the list of roles a user belongs to.

                        I am using Jdev.

                        I am unable to find Oracle Model Shared Library.

                        Can you please specify from where can I get this libraray.

                        Thanks,
                        Aparna