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

3 comments:

  1. I was searching for this .....thanks to post this nice article

    GetSecurityAttributeChanges

    ReplyDelete
  2. I was searching for this .....thanks to post this nice article



    ListFundsBySymbol

    ReplyDelete
  3. Whathappen if we pass empty hashSet as return attributes? will it return all the attributes or return none?

    ReplyDelete