Sunday 25 December 2016

Search User Key based on User Login in OIM11gR2

Search User Key based on User Login in OIM11gR2-
========================================================================

public String searchUserKey(String _usrLogin)
{
String _methodName = "searchUserKey()-";
Thor.API.Operations.tcUserOperationsIntf userintf = Platform.getService(Thor.API.Operations.tcUserOperationsIntf.class);

 //String returnMsg = "userid not existing in OIM";
 String userKey="";
 java.util.HashMap<String, String> userMap = new java.util.HashMap<String, String>();
     
 userMap.put("Users.User ID", _usrLogin);
 Thor.API.tcResultSet moResultSet = null;
  try {
    moResultSet = userintf.findUsers(userMap);
    String[] CName=moResultSet.getColumnNames();
    userKey=moResultSet.getStringValue("Users.Key");
 }
catch (tcColumnNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
       
return userKey;
}

Search Role Key Based on Role Name in OIM11gR2

Search Role Key based on Role Name in OIM11gR2-
==================================================================

public String searchRolekey(String roleName)
{
System.out.println("************Inside Fetch Role***************");

Thor.API.Operations.tcGroupOperationsIntf _groupService =  oimClient.getService(Thor.API.Operations.tcGroupOperationsIntf.class);

HashMap<String, String> roleMap = new HashMap<String, String>();

System.out.println("*********Role Name is*********: "+roleName);
roleMap.put("Groups.Role Name", roleName);

String roleKey="";
tcResultSet roleResultSet = null;
try {
roleResultSet = _groupService.findGroups(roleMap);
//String[] CNameforRole=roleResultSet.getColumnNames();
groupKey = roleResultSet.getStringValue("Groups.Key");
System.out.println("********Role key is********: "+groupKey);

}
catch (tcColumnNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return roleKeyKey;

}