CREATING USER BY USING DYNAMIC VALUES

CREATING USER BY USING DYNAMIC VALUES FOR OIM



// TRY THIS CODE IN ECLIPSE OR JDEVELOPER FOR CREATING USER WITH DYNAMIC FIELDS





import java.util.HashMap;
import java.util.Hashtable;

import java.util.Scanner;

import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.identity.usermgmt.vo.UserManagerResult;
import oracle.iam.platform.OIMClient;


public class CreateUser {
public static void main(String[] args) throws Exception {
            
            Scanner sc=new Scanner(System.in);
            
    System.setProperty("OIM.AppServerType", "wls");
    System.setProperty("APPSERVER_TYPE", "wls");
    System.setProperty("java.security.auth.login.config","C:\\Oracle\\Middleware\\Oracle_IDM1\\server\\config\\authwl.conf");
            
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.provider.url", "t3://<HOSTNAME>:<OIM PORT NUMBER>");
    env.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
OIMClient oimClient = new OIMClient(env);
oimClient.login("xelsysadm", "<password>");
    System.out.println("Enter the UserLogin:   =");
        String userLogin=sc.next();
                //String userLogin = "Prashant"; 
long i=1;
UserManager usrMgr = oimClient.getService(UserManager.class);
UserManagerResult userResult = null;
HashMap<String, Object> createAttributes = new HashMap<String, Object>();
String userKey = null;

createAttributes.put("User Login", userLogin);
                System.out.println("Enter the Frist Name:   =");
                String fname=sc.next();
createAttributes.put("First Name", fname+" " +userLogin);
        System.out.println("Enter the last Name:   =");
        String lname=sc.next();
createAttributes.put("Last Name", lname);
        System.out.println("Enter the country:   =");
                String country=sc.next();
                createAttributes.put("Country", country);
createAttributes.put("act_key", i);
createAttributes.put(oracle.iam.identity.utils.Constants.PASSWORD, <password>);
createAttributes.put("Xellerate Type", "End-User");
createAttributes.put("Role", "Full-Time");

userResult = usrMgr.create(new User(null,createAttributes));
userKey = userResult.getEntityId();
                System.out.println("First Nmae= "+fname+" Last Name= "+lname +" Login= "+userLogin+"  Country= "+country);
System.out.println("Created user with key = " + userKey);
oimClient.logout();
System.exit(0);
}
}

Comments

Post a Comment

Popular posts from this blog

Grant Entitlements To User Using API

list of accounts of a specific login id