使用 Oracle Identity Manager API 将组织成员从一个转移到另一个

Move Organization Members from one to another using Oracle Identity Manager API

我正在尝试通过 Oracle Identity Manager API 将组织成员从父组织移动到其子组织。我有他们两个的 orgkey。我写了下面的代码片段。我能够在变量 srcOrgOrganizationMembers 中获取上级组织成员的列表。收到错误

oracle.iam.identity.exception.ValidationFailedException: IAM-3056148 : usr_pwd_warn_date is a System Attribute and cannot be set through API

请问如何解决这个问题。提前感谢您的帮助!

 OrganizationManager orgManager = oimClient.getService(OrganizationManager.class);


         List<String> childOrgList = new ArrayList<String>();

         String orgkey = "54";

         try {

                HashMap<String, Object> configParams = new HashMap<String, Object>();
                Set<String> retAttrs = new HashSet<String>();
                List<Organization> ChildOrg = new ArrayList<Organization>();

                ChildOrg = orgManager.getChildOrganizations(orgkey, retAttrs, configParams);

                List srcOrgOrganizationMembers = orgManager.getOrganizationMembers(orgkey, retAttrs, null, configParams);
                System.out.println("Child Organizations Details : " + ChildOrg);
                System.out.println("Parent Organization Users : " + srcOrgOrganizationMembers);



                   System.out.println("Child Organizations Details : " + ChildOrg);

                   if (ChildOrg != null) {

                          for (int s = 0; s < ChildOrg.size(); s++) {

                                String childorgkey = ChildOrg.get(s).getEntityId();
                                System.out.println("Child Org Key : " + childorgkey);

                                childOrgList.add(childorgkey);



                                List<Organization> grandChildOrg = new ArrayList<Organization>();
                                grandChildOrg = orgManager.getChildOrganizations(childorgkey, retAttrs, configParams);
                                if (grandChildOrg != null) {

                                       for (int a = 0; a < grandChildOrg.size(); a++) {

                                              String grandchildorgkey = grandChildOrg.get(a).getEntityId();
                                              System.out.println("Grand Child Org Key : " + grandchildorgkey);

                                              childOrgList.add(grandchildorgkey);

                                              List<Organization> garndgrandChildOrg = new ArrayList<Organization>();
                                              garndgrandChildOrg = orgManager.getChildOrganizations(grandchildorgkey, retAttrs,
                                                           configParams);
                                              if (garndgrandChildOrg != null) {

                                                    for (int b = 0; b < garndgrandChildOrg.size(); b++) {

                                                           String garndgrandchildorgkey = garndgrandChildOrg.get(b).getEntityId();
                                                           System.out.println("Grand Grand Child Org Key : " + garndgrandchildorgkey);

                                                           childOrgList.add(garndgrandchildorgkey);

                                                    }

                                              }

                                       }

                                }

                          }

                   }

                   System.out.println("Child Org List outside while: " + childOrgList);

                   UserManager orgUsrMgr = oimClient.getService(UserManager.class);
                   System.out.println("\n \n values in orgUsrMgr" + orgUsrMgr);

                   List<User> resultUsers = new ArrayList<User>();


                   for(String childOrgzKey : childOrgList){

                           UserManagerResult result = null; 

                           for(Object usrObj : srcOrgOrganizationMembers){

                            User fromUser = (User)usrObj; 
                            HashMap mapOfSrcUserAttribute = fromUser.getAttributes();
                            //System.out.println("Organization Names of the Users" + fromUser.getAttribute("Organization Name") );
                            //User toUser = new User("");


                            //fromUser.setAttribute("Organization Name", "Requests");

                          System.out.println("\n\n Values in Source User Hashmap :" + mapOfSrcUserAttribute );

                          /*
                           System.out.println("\n\n Values in Source User Hashmap Keys :" + mapOfSrcUserAttribute.keySet() );

                            for(Object attrName : mapOfSrcUserAttribute.keySet()){ 
                                toUser.setAttribute(attrName.toString(), mapOfSrcUserAttribute.get(attrName));
                            }
                            System.out.println("\n\n Values in toUser : " + toUser);*/

                           fromUser.setOrganizationKey(childOrgzKey);

                            try {
                                 result = orgUsrMgr.modify(fromUser);
                                 System.out.println(fromUser +"User Sucessfully got Created" + result);
                                 resultUsers.add(fromUser);

                                 } catch (Exception e) {
                                  System.out.print(e);
                            }

                       }
                   }

                  System.out.println("List of all created users = " + resultUsers);

您需要使用以下方法更改组织

User usr = new User(fromUser.getId());
usr.setOrganizationKey(childOrgzKey);

orgUserMgr.modify(user)