1 2 Previous Next 15 Replies Latest reply: Apr 9, 2013 5:11 PM by Rajiv Dewan RSS

    Trying to create Organization in OIM 11g R2 using API

    903196
      Hi All,

      I am trying to create Organization in OIM 11g R2 using API's. I able to create a organization with attributes Organization Name and Organization Customer Type but when i am trying to add Parent Organization Name it is throwing me the following error

      Caused by: oracle.iam.platform.entitymgr.UnknownAttributeException: Organization : [Parent Organization Name]


      any help in this regard will be helpful....

      Thanks
        • 1. Re: Trying to create Organization in OIM 11g R2 using API
          Rajiv Dewan
          http://rajivdewan.blogspot.com/2013/04/create-organization-api-11g-r2.html
          • 2. Re: Trying to create Organization in OIM 11g R2 using API
            delhi
            Try this:

            long i = 1;
            String orgName = "OrganizationName";
            String result = null;

            OrganizationManager omgr = oimClient.getService(OrganizationManager.class);
            Organization org = null;

            org = new Organization();
            org.setAttribute("Organization Name", orgName);
            org.setAttribute("Organization Customer Type", "Company");

            result = omgr.create(org);

            System.out.println("Creation status: '" + result + "'");
            • 3. Re: Trying to create Organization in OIM 11g R2 using API
              delhi
              my bad, this is for R1
              • 4. Re: Trying to create Organization in OIM 11g R2 using API
                903196
                Hi i am getting the below error when i am trying to set my custom org as my parent org

                Caused by: oracle.iam.platform.kernel.ValidationFailedException: IAM-3056148:act_createby is a System Attribute and cannot be set through API.:act_createby
                • 5. Re: Trying to create Organization in OIM 11g R2 using API
                  Rajiv Dewan
                  Why are you setting act_createby attribute. It is a system attribute and it will generated by system. You can't set this attribute.

                  You might have used username and password for creating oimclient. This attribute will be populated by that ID automatically.

                  In case you have any issue; paste your code here
                  • 6. Re: Trying to create Organization in OIM 11g R2 using API
                    903196
                    This is the only thing i am setting in the code. I am not sure why act_createby is modifying

                    or.setAttribute("Organization Name", CustomOrg);
                    or.setAttribute("Organization Customer Type", "Company");
                    or.setAttribute("parent_key","27" );
                    orgService.create(or);
                    System.out.println("Org Created Successfully");
                    • 7. Re: Trying to create Organization in OIM 11g R2 using API
                      Karthik Perath
                      I am able to create organization based on your snippet. There might be something wrong in your code. Paste the complete code here..
                      • 8. Re: Trying to create Organization in OIM 11g R2 using API
                        903196
                        package oracle.iam.ui.custom;

                        import java.io.BufferedReader;
                        import java.io.FileNotFoundException;
                        import java.io.FileReader;
                        import java.io.IOException;

                        import java.util.HashMap;
                        import java.util.Iterator;
                        import java.util.Set;
                        import java.util.StringTokenizer;

                        import javax.security.auth.login.LoginException;

                        import oracle.iam.identity.exception.OrganizationManagerException;
                        import oracle.iam.identity.orgmgmt.api.OrganizationManager;
                        import oracle.iam.identity.orgmgmt.api.OrganizationManagerConstants;
                        import oracle.iam.identity.orgmgmt.vo.Organization;
                        import oracle.iam.utils.Utility;
                        import oracle.iam.utils.Constants;

                        public class Class1{


                        public static void main(String args[]) throws FileNotFoundException,
                        IOException, LoginException,
                        OrganizationManagerException {
                        oracle.iam.platform.OIMClient oimClient = null;
                        String oimURL = "t3://172.16.30.65:14000/oim";
                        String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
                        System.setProperty("java.security.auth.login.config", "C:/config/authwl.conf");
                        System.setProperty("Context.PROVIDER_URL", oimURL);

                        System.setProperty("APPSERVER_TYPE", "wls");
                        // set up the environment for making the OIM API invocation

                        java.util.Hashtable env = new java.util.Hashtable();
                        env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL,oimInitialContextFactory);
                        env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, oimURL);

                        oimClient = new oracle.iam.platform.OIMClient(env);

                        try {
                        oimClient.login("xelsysadm","Passw0rd1".toCharArray());
                        } catch (LoginException e) {
                        e.printStackTrace();
                        }

                        OrganizationManager orgService = oimClient.getService(OrganizationManager.class);
                        HashMap hm = new HashMap() ;
                        BufferedReader br = new BufferedReader(new FileReader("C:\\org.txt"));
                        try {
                        System.out.println("In try ");
                        StringBuilder sb = new StringBuilder();
                        String line = br.readLine();
                        System.out.println("Line " + line);

                        while (line != null)
                        {
                        sb.append(line);
                        sb.append("\n");
                        line = br.readLine();
                        if(line == null)
                        {
                        System.out.println("not creating org");
                        }
                        else
                        {
                        System.out.println("Creating org********************** "+ line);
                        StringTokenizer st2 = new StringTokenizer(line, ",");
                        int i = 1;
                        while (st2.hasMoreElements())
                        {
                        String para = st2.nextElement().toString();
                        System.out.println("SOP "+ i);
                        hm.put(i, para);
                        System.out.println("**** "+para);
                        i++;
                        }
                        System.out.println("HashMap Values "+ hm.size());

                        Organization or = new Organization();
                        String orgname = hm.get(1).toString();
                        String parentorgname = hm.get(2).toString();
                        System.out.println("Organization Name:: "+ orgname);
                        System.out.println("Parent Organization Name:: "+ parentorgname);
                        or = orgService.getDetails(parentorgname, null, true);

                        or.setAttribute("Organization Name", orgname);
                        System.out.println("OrgName Set");
                        or.setAttribute("Organization Customer Type", "Company");
                        System.out.println("OrgType Set");
                        or.setAttribute("parent_key", or.getAttribute("act_key").toString()); // or.getAttribute("act_key").toString() gives me the key of the organization

                        System.out.println("ParentOrg Set");
                        System.out.println("Organization "+ or);

                        orgService.create(or);
                        System.out.println("Org Created Successfully");
                        }
                        System.out.println("**********************************************************************************************************************************************************************************");
                        }
                        String everything = sb.toString();
                        System.out.println("Everything::: "+ everything);
                        } finally {
                        br.close();
                        }


                        }
                        }
                        • 9. Re: Trying to create Organization in OIM 11g R2 using API
                          Rajiv Dewan
                          or.setAttribute("parent_key", or.getAttribute("act_key").toString());
                          What is this act_key ?

                          You are referring to same or object.

                          Replace it with act_key of Parent Organization say "Top" or "Xellerate Users"

                          or.setAttribute("parent_key", "3");
                          • 10. Re: Trying to create Organization in OIM 11g R2 using API
                            903196
                            act_key in my case is 27

                            Can't i set the Parent Org with my Custom Org???
                            • 11. Re: Trying to create Organization in OIM 11g R2 using API
                              Rajiv Dewan
                              Replace or.setAttribute("parent_key", or.getAttribute("act_key").toString());

                              with or.setAttribute("parent_key", "27");

                              And I assume that some Organization exists in your environment with ACT_KEY as 27
                              • 12. Re: Trying to create Organization in OIM 11g R2 using API
                                903196
                                Yes i do have the org with act_key 27

                                I have done that changes...still it is throwing the same error


                                Exception in thread "main" oracle.iam.identity.exception.OrganizationCreateException: IAM-3056148:act_createby is a System Attribute and cannot be set through API.:act_createby
                                     at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
                                     at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
                                     at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManager_874ar_OrganizationManagerRemoteImpl_1036_WLStub.createx(Unknown Source)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                     at java.lang.reflect.Method.invoke(Method.java:597)
                                     at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
                                     at $Proxy2.createx(Unknown Source)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManagerDelegate.create(Unknown Source)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                     at java.lang.reflect.Method.invoke(Method.java:597)
                                     at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
                                     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                                     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
                                     at weblogic.security.Security.runAs(Security.java:41)
                                     at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
                                     at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
                                     at $Proxy3.create(Unknown Source)
                                     at oracle.iam.ui.custom.Class1.main(Class1.java:108)
                                Caused by: oracle.iam.identity.exception.OrganizationCreateException: IAM-3056148:act_createby is a System Attribute and cannot be set through API.:act_createby
                                     at oracle.iam.identity.orgmgmt.impl.OrganizationManagerImpl.create(OrganizationManagerImpl.java:318)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                     at java.lang.reflect.Method.invoke(Method.java:597)
                                     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
                                     at oracle.iam.platform.utils.DMSMethodInterceptor.invoke(DMSMethodInterceptor.java:25)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
                                     at $Proxy333.create(Unknown Source)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManagerEJB.createx(Unknown Source)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                     at java.lang.reflect.Method.invoke(Method.java:597)
                                     at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
                                     at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
                                     at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at com.oracle.pitchfork.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:34)
                                     at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
                                     at com.oracle.pitchfork.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:42)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
                                     at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
                                     at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
                                     at $Proxy331.createx(Unknown Source)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManager_874ar_OrganizationManagerRemoteImpl.__WL_invoke(Unknown Source)
                                     at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManager_874ar_OrganizationManagerRemoteImpl.createx(Unknown Source)
                                     at oracle.iam.identity.orgmgmt.api.OrganizationManager_874ar_OrganizationManagerRemoteImpl_WLSkel.invoke(Unknown Source)
                                     at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
                                     at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
                                     at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
                                     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                                     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
                                     at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
                                     at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
                                     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
                                     at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
                                Caused by: oracle.iam.platform.kernel.ValidationFailedException: IAM-3056148:act_createby is a System Attribute and cannot be set through API.:act_createby
                                     at oracle.iam.identity.usermgmt.utils.UserManagerUtils.createValidationFailedException(UserManagerUtils.java:337)
                                     at oracle.iam.identity.usermgmt.utils.UserManagerUtils.createValidationFailedException(UserManagerUtils.java:372)
                                     at oracle.iam.identity.utils.Utils.checkAllowedAttributes(Utils.java:2523)
                                     at oracle.iam.identity.orgmgmt.impl.handlers.create.CreateOrganizationValidationHandler.validate(CreateOrganizationValidationHandler.java:102)
                                     at oracle.iam.platform.kernel.impl.OrchProcessData.validate(OrchProcessData.java:258)
                                     at oracle.iam.platform.kernel.impl.OrchProcessData.runValidationEvents(OrchProcessData.java:203)
                                     at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.validate(OrchestrationEngineImpl.java:699)
                                     at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.process(OrchestrationEngineImpl.java:547)
                                     at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:485)
                                     at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:403)
                                     at sun.reflect.GeneratedMethodAccessor1171.invoke(Unknown Source)
                                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                     at java.lang.reflect.Method.invoke(Method.java:597)
                                     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
                                     at oracle.iam.platform.utils.DMSMethodInterceptor.invoke(DMSMethodInterceptor.java:25)
                                     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
                                     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
                                     at $Proxy251.orchestrate(Unknown Source)
                                     at oracle.iam.identity.orgmgmt.impl.OrganizationManagerImpl.create(OrganizationManagerImpl.java:306)
                                     ... 46 more
                                • 13. Re: Trying to create Organization in OIM 11g R2 using API
                                  Rajiv Dewan
                                  try this:


                                  Organization or = new Organization();
                                  String orgname = hm.get(1).toString();
                                  String parentorgname = hm.get(2).toString();

                                  /System.out.println("Organization Name:: "+ orgname);
                                  System.out.println("Parent Organization Name:: "+ parentorgname);
                                  or = orgService.getDetails(parentorgname, null, true);
                                  REMOVE ABOVE LINE AND ADD BELOW LINE

                                  or = new Organization();
                                  or.setAttribute("Organization Name", orgname);
                                  System.out.println("OrgName Set");
                                  or.setAttribute("Organization Customer Type", "Company");
                                  System.out.println("OrgType Set");
                                  or.setAttribute("parent_key", "27");
                                  • 14. Re: Trying to create Organization in OIM 11g R2 using API
                                    903196
                                    Yeah it is working now...cant i get the key using the getDetails method???
                                    1 2 Previous Next