Pages

Monday, August 1, 2011

Searching the User In OIM API

I am searching the user based on his/her user login and returning the First Name, Last Name and Employee Number. For this example required the following objects to search the users in OIM.


Pre-Requisite


Please follow the link and pre pare for OIM environment customization

OIM Client Code Setup

Searching User


Create the Search Criteria

SearchCriteria criteria = new SearchCriteria("User Login", <User Namee>, SearchCriteria.Operator.EQUAL);

The above search criteria is username is equal against with OIM user database.

Creating User Manager Object

UserManager usermgr = (UserManager) client.getService(UserManager.class);

Setting the Return Attribute

Set retAttrs = new HashSet();

retAttrs.add("First Name");
retAttrs.add(Last Name");
retAttrs.add("Employee Number");

Invoking the Seach Process

List<User> users = usermgr.search(criteria, retAttrs, null);

Iterating the Search Result


int size=users.size();

for (int i = 0; i < size; i++) { User user=users.get(i); Map attrs=user.getAttributes();

Set keys=attrs.keySet();

for (String string : keys)

{

Object attr=attrs.get(string);
System.out.println("Key "+ string + " value "+attr);
}
}

References

Oracle Identity Manager API

Oracle Identity Manager Developer Guide

Developing the Custom OIM Client Code Setup

The following steps being used to Customize the OIM functionality as per your requirement.

Initial Setup OIM Customization

Pre-Requisite

Generate the wlfullclient.jar
and set the classpath of the oimclient.jar, spring.jar, commons-logging.jar and generated wlfullclient.jar.

Please follow the link and it will generate the wlfullclient.jar wl full client

Configuring the JAAS Config File

xellerate{
weblogic.security.auth.login.UsernamePasswordLoginModule
required debug=true;
};

Configuring the System Properties

Java Code
System.setProperty("java.security.auth.login.config","JAAS Login Config File")
Command Line
Configuring the System Properties Command Line

java -Djava.security.auth.login.config=<file Name with absolute path> ClassName

Creating the OIM Client Context

Hashtable oimenv= new Hashtable();

oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,OIMClient.WLS_CONTEXT_FACTORY);

oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,"t3://<OIM Host Name>:<OIM Port>");
OIMClient client= new OIMClient(oimenv);

Authenticating the User Against OIM

try

{

client.login(<User Name>, <Password with Char Array>);
For Example User Name is xelsysadm and Password is Xelsysadm password.
} catch (LoginException e)

{

e.printStackTrace();

}