The below code is helpful to create a user in OIM .The code below has some custom attributes created by myself to create user.Modify the code as per your needs.:)
public String CreateUser(
final String UserID,
final String FirstName,
final String middleName,
final String LastName,
final String Status,
final String EmployeeType,
final String Location,
final String email,
{
String flag = "";
System.out.println("Value received from Method ");
System.out.println"-----------------------------------------------------------");
System.out.println("Value for UserID ===>"+ UserID );
System.out.println("Value for FirstName ===>"+FirstName);
System.out.println("Value for middleName ===>"+middleName);
System.out.println("Value for LastName ===>"+LastName);
System.out.println("Value for Status ===>"+Status);
System.out.println("Value for LocationType ===>"+LocationType);
System.out.println("Value for EmployeeType ===>"+EmployeeType);
System.out.println("Value for Location ===>"+Location);
System.out.println("Value for email ===>"+email);
System.out.println"-----------------------------------------------------------");
System.out.println("Value received );
HashMap userMap = new HashMap();
try {
userMap.put("Users.User ID", UserID);
userMap.put("Users.First Name", FirstName);
userMap.put("Users.Middle Name", middleName);
userMap.put("Users.Last Name", LastName);
userMap.put("Users.EmployeeType", "EMP");
userMap.put("Users.Password", "343245324");
userMap.put("Users.Confirm Password", "3432432");
userMap.put("Users.Location", Location);
userMap.put("Users.Division", LocationType);
userMap.put("Users.Email", email);
userMap.put("Users.User Type", "End-User");
userMap.put("Users.Status", "Active");
userMap.put("Users.AgentStatus", "");
userMap.put("Users.Xellerate Type", "End-User");
userMap.put("Users.Role", "Full-Time");
userMap.put("Users.Organization", "Xellerate Users");
userMap.put("Organizations.Key", "1");
userMap.put("RogueAcIdentifier","");
long test = moUserUtility.createUser(userMap);
//TODO write your implementation code here:
System.out.println("User created successfully with id <==="+ UserID +"===>");
flag = "User Created Successfully in OIM";
return flag;
} catch (Thor.API.Exceptions.tcAPIException exception) {
// e.printStackTrace();
System.out.println("Exception In OIM SERVER <===" + UserID + "===>" + exception.toString());
return exception.toString();
}
catch (Exception e) {
System.out.println("Exception In OIM SERVER while creating user <===" + e.toString());
return e.toString();
}
}
public String CreateUser(
final String UserID,
final String FirstName,
final String middleName,
final String LastName,
final String Status,
final String EmployeeType,
final String Location,
final String email,
{
String flag = "";
System.out.println("Value received from Method ");
System.out.println"-----------------------------------------------------------");
System.out.println("Value for UserID ===>"+ UserID );
System.out.println("Value for FirstName ===>"+FirstName);
System.out.println("Value for middleName ===>"+middleName);
System.out.println("Value for LastName ===>"+LastName);
System.out.println("Value for Status ===>"+Status);
System.out.println("Value for LocationType ===>"+LocationType);
System.out.println("Value for EmployeeType ===>"+EmployeeType);
System.out.println("Value for Location ===>"+Location);
System.out.println("Value for email ===>"+email);
System.out.println"-----------------------------------------------------------");
System.out.println("Value received );
HashMap
try {
userMap.put("Users.User ID", UserID);
userMap.put("Users.First Name", FirstName);
userMap.put("Users.Middle Name", middleName);
userMap.put("Users.Last Name", LastName);
userMap.put("Users.EmployeeType", "EMP");
userMap.put("Users.Password", "343245324");
userMap.put("Users.Confirm Password", "3432432");
userMap.put("Users.Location", Location);
userMap.put("Users.Division", LocationType);
userMap.put("Users.Email", email);
userMap.put("Users.User Type", "End-User");
userMap.put("Users.Status", "Active");
userMap.put("Users.AgentStatus", "");
userMap.put("Users.Xellerate Type", "End-User");
userMap.put("Users.Role", "Full-Time");
userMap.put("Users.Organization", "Xellerate Users");
userMap.put("Organizations.Key", "1");
userMap.put("RogueAcIdentifier","");
long test = moUserUtility.createUser(userMap);
//TODO write your implementation code here:
System.out.println("User created successfully with id <==="+ UserID +"===>");
flag = "User Created Successfully in OIM";
return flag;
} catch (Thor.API.Exceptions.tcAPIException exception) {
// e.printStackTrace();
System.out.println("Exception In OIM SERVER <===" + UserID + "===>" + exception.toString());
return exception.toString();
}
catch (Exception e) {
System.out.println("Exception In OIM SERVER while creating user <===" + e.toString());
return e.toString();
}
}
what jar file do i need to yous moUserUtility
ReplyDeleteif you are using 10g API,add mouserutility jars and for 11g use oimclient.jar
Delete