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.a pi.UserManager;
import oracle.iam.identity.usermgmt.v o.User;
import oracle.iam.identity.usermgmt.v o.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.AppSer verType", "wls");
System.setProperty("APPSERVER_ TYPE", "wls");
System.setProperty("java.secur ity.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.i nitial", "weblogic.jndi.WLInitialContex tFactory");
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(UserManag er.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.ia m.identity.utils.Constants.PAS SWORD, <password>);
createAttributes.put("Xellerat e 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);
}
}
It's so helpful...
ReplyDeleteThanks a lot
ReplyDelete