OIM API To Modify User Details


  1. package com.oimacademy.users;
  2. import com.oimacademy.connection.Platform;
  3. import java.util.HashMap;
  4. import oracle.iam.identity.exception.NoSuchUserException;
  5. import oracle.iam.identity.exception.SearchKeyNotUniqueException;
  6. import oracle.iam.identity.exception.UserModifyException;
  7. import oracle.iam.identity.exception.ValidationFailedException;
  8. import oracle.iam.identity.usermgmt.api.UserManager;
  9. import oracle.iam.identity.usermgmt.vo.User;
  10. import oracle.iam.identity.utils.Constants;
  11. import oracle.iam.platform.authz.exception.AccessDeniedException;
  12. public class ModifyUserDetails {
  13.     public static void main(String[] args) {
  14.   modify();
  15.  } 
  16.      public static void modify(){
  17.    UserManager userManager = (UserManager) Platform.getService(UserManager.class);
  18.    HashMap<String, Object> modifyAttributes=null;
  19.    long MANAGERKEY = 28;
  20.    for(int i=15;i <20;i++){
  21.     modifyAttributes = new HashMap<String, Object>();
  22.     modifyAttributes.put(Constants.MANAGERKEY,MANAGERKEY);
  23.    User user= new User("TUSER_Manager" + i,modifyAttributes);
  24.    try {
  25.    userManager.modify("User Login", "TUSER_Manager" + i, user);                        
  26.   } catch (ValidationFailedException e) {
  27.    // TODO Auto-generated catch block
  28.    e.printStackTrace();
  29.   } catch (UserModifyException e) {
  30.    // TODO Auto-generated catch block
  31.    e.printStackTrace();
  32.   } catch (NoSuchUserException e) {
  33.    // TODO Auto-generated catch block
  34.    e.printStackTrace();
  35.   } catch (SearchKeyNotUniqueException e) {
  36.    // TODO Auto-generated catch block
  37.    e.printStackTrace();
  38.   } catch (AccessDeniedException e) {
  39.    // TODO Auto-generated catch block
  40.    e.printStackTrace();
  41.   }
  42.    }
  43.   } 
  44. }

No comments:

Post a Comment