Wednesday, October 5, 2016

Run query form java code using OIM Client login

import Thor.API.Security.XLClientSecurityAssociation;
import com.thortech.xl.client.dataobj.tcDataBaseClient;
import com.thortech.xl.dataaccess.tcClientDataAccessException;
import com.thortech.xl.dataaccess.tcDataProvider;
import com.thortech.xl.dataaccess.tcDataSet;
import com.thortech.xl.dataaccess.tcDataSetException;
import com.thortech.xl.orb.dataaccess.tcDataAccessException;

public void connectOIMDB(OIMClient oimClient){
XLClientSecurityAssociation.setClientHandle(oimClient);
tcDataProvider dataProvider = new tcDataBaseClient() ;        
        String query ="SELECT * FROM USR WHERE USR_LOGIN = 'XELSYSADM'";        
  tcDataSet dataSet = new tcDataSet();
  dataSet.setQuery(dataProvider, query);
  dataSet.executeQuery();
  System.out.println("Login ID: "+dataSet.getString("USR_LOGIN"));

}

Saturday, April 16, 2016

Event Handler to update Display Name

public EventResult execute(long processId, long eventId, Orchestration orchestration) {

HashMap<String, Serializable> parameters = orchestration.getParameters();
HashMap<String, Object> mapAttrs = new HashMap<String, Object>();

String firstName = (String)parameters.get(UserManagerConstants.AttributeName.FIRSTNAME.getId());
String lastName = (String)parameters.get(UserManagerConstants.AttributeName.LASTNAME.getId());


mapAttrs.put("base", "Mr."+firstName+" "+lastName);


orchestration.addParameter("Display Name", mapAttrs);

return new EventResult();
}

Thursday, April 14, 2016

Table contains all the Schedule tasks

QRTZ92_JOB_DETAILS - contains list of all schedule task
JOB_HISTORY- Contains the details about the execution history

Thursday, January 7, 2016

SQL: Put more than 1000 items inside an IN Clause

some time we need to provide more than 1000 items inside IN clause.  To achieve this, we need to split values across multiple INs using OR

Sample Query:

select * from USR where usr_key in (1,2,3,----1000) OR usr_key in (1001,1002,...,2000)

Tuesday, December 1, 2015

weblogic.socket.MaxMessageSizeExceededException

when  we execute some java code (OIM api) form Eclipse, we may face the below issue :
Caused by: weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000080' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'

to resolve the issue we can just add a system property in the java code

System.setProperty("weblogic.MaxMessageSize", "300000000"); and you are done :)

sample code:

public OIMClient envContext(String oimUserName, String oimPassword, String oimURL ){
/*String oimUserName = "xelsysadm";   
String oimPassword = "xxxxxxxxxxxxxxxxxxx";
String oimURL = "t3://xxxxxxxxxxxxxxxxxxxxxxxt:14000"; */

String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
OIMClient oimClient= null;
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,oimURL);
System.setProperty("java.security.auth.login.config", "./config/authwl.conf");
System.setProperty("java.security.policy", "./config/xl.policy"); 
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
System.setProperty("weblogic.Name", "oim_server1");
System.setProperty("weblogic.MaxMessageSize", "300000000");
System.setProperty("weblogic.security.SSL.trustedCAKeyStore", "./config/xxxxxxx.jks");
oimClient = new OIMClient(env);
try {
oimClient.login(oimUserName, oimPassword.toCharArray());
System.out.println("Successfully Connected with OIM ");
} catch (LoginException e) {
System.out.println("Login Exception"+ e);
}
return oimClient;
}

Retry Evaluate user policies task

Some time we need to retry Evaluate user policies task. But  some time when we  run the Evaluate user policies task again, the task seems to ignore users who failed the previous run. To solve this issue we need to execute the below query to reset the POLICY_EVAL_NEEDED flag in DB.

query:
UPDATE USER_PROVISIONING_ATTRS SET POLICY_EVAL_IN_PROGRESS = 0, POLICY_EVAL_NEEDED = 1, UPDATE_DATE = SYSDATE where USR_KEY IN( all affected  user Ids)

Sunday, July 19, 2015

OIM API- Update Schedule task attribute

Some time we need to update schedule task attribute like time stump; so that when the schedule task execute next time it can start executing after that time stump. we can use the below code to achieve that.

private void updateSchedulerTimeStamp(Date curTime,String scheduledTaskName)
{
try
{
String currentTime = curTime.toString();
SimpleDateFormat lastExecutionTimeParser1 = new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy");
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
curTime = lastExecutionTimeParser1.parse(currentTime);
String curDate=sdf.format(curTime);
HashMap <String,String> hashmap = new HashMap<String,String>();
hashmap.put("Task Scheduler.Name", scheduledTaskName);
tcSchedulerOperationsIntf tcSchOper = (tcSchedulerOperationsIntf) Platform.getService(tcSchedulerOperationsIntf.class);
tcResultSet tcresultset = tcSchOper.findScheduleTasks(hashmap);


if(tcresultset != null && tcresultset.getRowCount() > 0)
{
tcresultset.goToRow(0);
long schedularKey = tcresultset.getLongValue("Task Scheduler.Key");
String schedularKeyStr = String.valueOf(schedularKey);
hashmap.clear();
hashmap.put("Task Scheduler.Key", schedularKeyStr);
hashmap.put("Task Scheduler.Task Attributes.Name", "Last Execution Time");
tcResultSet tcresultset1 = tcSchOper.findScheduleTaskAttributes(hashmap);
if(tcresultset1 != null && tcresultset1.getRowCount()>0){
tcresultset1.goToRow(0);
long scheduleTaskAtrKey = tcresultset1.getLongValue("Task Scheduler.Task Attributes.Key");
hashmap.put("Task Scheduler.Task Attributes.Value", curDate);
tcSchOper.updateScheduleTaskAttribute(schedularKey,scheduleTaskAtrKey, hashmap);  

}
else{
logger.finest("CLASS_NAME - Nirupam - in updateSchedulerTimeStamp Method :Resultset is null: ");
}

}
}
catch(Exception e)
{
logger.finest("CLASS_NAME - Nirupam - in updateSchedulerTimeStamp Method :Exception:"+e);
}

}