5 Replies Latest reply: Feb 18, 2013 9:53 PM by Oracle.Quest RSS

    AdminRole using Code

    918074
      Hi

      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.

      http://docs.oracle.com/cd/E27559_01/apirefs.1112/e28159/oracle/iam/platformservice/api/AdminRoleService.html

      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)

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

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


          You can retrieve available admin roles of testuser from the list
          • 2. Re: AdminRole using Code
            918074
            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
              • 4. Re: AdminRole using Code
                918074
                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
                  Oracle.Quest
                  You need to specify the userkey (USR_KEY) in place of user login 'testadmin'