User Management
The OIM 11gR1 Java APIs support searching, creating, reading, updating and deleting of Users. This thread demonstrates cover how to use the OIM 11gR1 Java APIs to perform these operations.Required server files
You will need to obtain the following files from the OIM 11gR1 server:
- The OIM 11gR1 Java API classes are packaged as a jar file called oimclient.jar. This jar file is packaged within the oimclient.zip file. The oimclient.zip file is located in the OIM_ORACLE_HOME/server/client folder, on the OIM 11gR1 server.
- Copy oimclient.zip from the OIM 11gR1 server:
scp user@oimserver:/OIM_ORACLE_HOME/server/client/oimclient.zip . - Expand the oimclient.zip file:
unzip oimclient.zip
- Access the Weblogic Server system
ssh user@wlserver - Change directories to the server/lib directory.
cd WL_HOME/server/lib - Use the following command to create the wlfullclient.jar file in the server/libdirectory:
java -jar wljarbuilder.jar - Copy the wlfullclient.jar file.
Create A User In OIM using OIM API.
package com.mindtelligent.oim.user.client;
import java.util.HashMap;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.identity.usermgmt.vo.UserManagerResult;
public class UserCreate extends ClientUser
{
public UserCreate() throws Exception
{
super();
return;
}
public static void main(String[] args) throws Exception
{
UserCreate test = new UserCreate();
try
{
test.execute();
}
catch (Exception ex)
{
test.log("EXCEPTION: " + ex.getMessage());
}
return;
}
protected void execute() throws Exception
{
long i = 1;
String accountId = "hsaluja";
String first = "Harvinder";
String last = "Saluja";
HashMap<String, Object> mapAttrs = null;
UserManager umgr = null; // OIMClient API
UserManagerResult result = null; // OIMClient API
User user = null; // OIMClient API
this.log("__BEGIN__");
umgr = this.getUserManager();
mapAttrs = new HashMap<String, Object>();
mapAttrs.put("User Login", accountId);
mapAttrs.put("First Name", first);
mapAttrs.put("Last Name", last);
mapAttrs.put("usr_password", "Passw0rd");
mapAttrs.put("Email", first + "." + last + "@MindTelligent.com");
mapAttrs.put("act_key", new Long(i));
mapAttrs.put("Xellerate Type", "End-User");
mapAttrs.put("Role", "Full-Time"); // User Type
user = new User(accountId, mapAttrs);
this.log("User object created: '" + accountId + "'");
/*
* Create the user
*/
result = umgr.create(user);
this.log("Creation status: '" + result.getStatus() + "'");
this.log("__END__");
return;
}
}
package com.mindtelligent.oim.user.client;
import java.util.HashMap;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.identity.usermgmt.vo.UserManagerResult;
public class UserCreate extends ClientUser
{
public UserCreate() throws Exception
{
super();
return;
}
public static void main(String[] args) throws Exception
{
UserCreate test = new UserCreate();
try
{
test.execute();
}
catch (Exception ex)
{
test.log("EXCEPTION: " + ex.getMessage());
}
return;
}
protected void execute() throws Exception
{
long i = 1;
String accountId = "hsaluja";
String first = "Harvinder";
String last = "Saluja";
HashMap<String, Object> mapAttrs = null;
UserManager umgr = null; // OIMClient API
UserManagerResult result = null; // OIMClient API
User user = null; // OIMClient API
this.log("__BEGIN__");
umgr = this.getUserManager();
mapAttrs = new HashMap<String, Object>();
mapAttrs.put("User Login", accountId);
mapAttrs.put("First Name", first);
mapAttrs.put("Last Name", last);
mapAttrs.put("usr_password", "Passw0rd");
mapAttrs.put("Email", first + "." + last + "@MindTelligent.com");
mapAttrs.put("act_key", new Long(i));
mapAttrs.put("Xellerate Type", "End-User");
mapAttrs.put("Role", "Full-Time"); // User Type
user = new User(accountId, mapAttrs);
this.log("User object created: '" + accountId + "'");
/*
* Create the user
*/
result = umgr.create(user);
this.log("Creation status: '" + result.getStatus() + "'");
this.log("__END__");
return;
}
}