5 Replies Latest reply on Feb 19, 2013 3:53 AM by Oracle.Quest

    AdminRole using Code


      Can anyone help me with the code to retrieve Admin Roles for the user using API?

      I am following the below java doc for getting admin roles. But dont know how to start coding it.


      Pls help.
        • 1. Re: AdminRole using Code
          Nishith Nayan
          use getAdminRolesForUser method for retrieving admin roles for a given user

          java.util.List getAdminRolesForUser(java.lang.String userId,
          java.util.Map paramsMap)

          AdminRoleService admin=Platform.getService(AdminRoleService.class);

          List adminRolesList=admin.getAdminRolesForUser("testuser",null);

          You can retrieve available admin roles of testuser from the list
          1 person found this helpful
          • 2. Re: AdminRole using Code
            Thanks Nishith.

            Can you tell me what I have to import for AdminRoleService in my java code.

            I tried with below import statements but it is throwing compile errors

            import oracle.iam.platformservice.api; // Error
            import oracle.iam.platformservice.api.AdminRoleService; //Error

            Pls Help..
            • 3. Re: AdminRole using Code
              Nishith Nayan
              you have to import oimclient.jar

              better goto <OIM_HOME>/server/client/oimclient.zip . extract it and import all the jars in your code.
              apart from this you can include wlfullclient.jar from <WL_HOME>/lib folder. if it is not there then generate the same.

              find from below link
              Re: Error while connecting to OIM via Jdeveloper
              1 person found this helpful
              • 4. Re: AdminRole using Code
                Hi Nitish,

                I am trying to run the below code. But I am not able to retrieve the admin roles for the user i am passing.

                AdminRoleService adm = oimClient.getService(AdminRoleService.class);
                List adminroleList = adm.getAdminRolesForUser("testadmin", null);
                System.out.println("Size is "+adminroleList.size());

                for(int j=0;j < adminroleList.size();j++){
                System.out.println("Values in List are::"+Arrays.toString(adminroleList.toArray()));

                I have assigned User Administrator admin role to this user using UI. But the size of the list always print 0.

                Pls Help.
                • 5. Re: AdminRole using Code
                  You need to specify the userkey (USR_KEY) in place of user login 'testadmin'