To compile the adapter, the following steps must be executed:
1. Create a work folder, let's say c:\work and inside create the following structure:
c:\work\com\oracle\events\
2. Create a java file in c:\work\com\oracle\events\ named loginuseridgenern.java
3. Copy the source code provided in this document to the java file.
package com.oracle.events;
import java.util.Random;
import java.io.*;
import com.thortech.xl.dataobj.tcDataSet;
import com.thortech.xl.util.logging.LoggerMessages;
import com.thortech.xl.util.logging.LoggerModules;
import com.thortech.util.logging.Logger;
public class loginuseridgenern extends com.thortech.xl.client.events.tcBaseEvent {
private static Logger logger = Logger.getLogger(LoggerModules.XL_JAVA_CLIENT);
public loginuseridgenern() {
setEventName("Generating a random userid for a User.");
}
protected void implementation() throws Exception {
if (getDataObject().isDeleting()) {
return;
}
if (getDataObject().isUpdating()) {
return;
}
String generatedLogin= getloginid();
getDataObject().setString("usr_udf_username",generatedLogin);
//or try usr_login instead of usr_udf_username
return;
}
private String getloginid() {
String fl ="";
try{
java.io.FileReader fr = new java.io.FileReader("c:\\Temp\\seq.txt");
BufferedReader br = new BufferedReader(fr);
String str = br.readLine();
fr.close();
//java.io.FileWriter fw = new java.io.FileWriter("c:\\Temp\\aaa.txt");
int aInt=Integer.parseInt(str)+1;
String seq=String.format("%03d",aInt);
String fn=getDataObject().getString("usr_first_name");
String ln=getDataObject().getString("usr_last_name");
//Find Length of ln
int length=ln.length();
/*
* If Length of The LastName is Less Than 6 Characters Then
* Concate complete Last Name with first Character Of First Name
*
*
*/
if(length<6)
{
fl="x_"+fn.substring(0,1)+ln.substring(0,length)+seq;
}
else
{
fl="x_"+fn.substring(0,1)+ln.substring(0,6)+seq;
}
// fw.write("Userid is :" + fl+ seq);
// fw.flush();
// fw.close();
java.io.FileWriter fw1 = new java.io.FileWriter("c:\\Temp\\seq.txt");
String s = ""+aInt;
fw1.write(s);
fw1.flush();
fw1.close();
}catch(Exception ioex){
System.out.println("eror writing file" + ioex.getMessage());
}
return fl;
}
}
4. In c:\work create a file named compile.bat with the following contents:
set OIM_LIBS=D:\oracle\oimserver\xellerate\lib
set CLASSPATH=%OIM_LIBS%\xlLogger.jar;%OIM_LIBS%\xlDataObjects.jar;%OIM_LIBS%\xlVO.jar;%OIM_LIBS%\xlUtils.jar
javac -classpath %CLASSPATH% com\oracle\events\loginuseridgenern.java
jar cf loginuseridgenern.jar *
5. Run compile.bat and check for any compilation errors.
6. At this point a JAR file named loginuseridgenern.jar will be created in c:\work folder.
Running the Code:
To add the new created event handler to OIM server, perform the following steps:
1. Copy the file loginuseridgenern.jar from c:\work to OIM_HOME\xellerate\EventHandlers
2. Open Design Console and navigate to:
Development Tools -> Business Rule Definition -> Event Handler Manager

3. Create a new Event Handler and specify:
Event Handler Name: loginuseridgenern
Package: com.oracle.events
Pre-Insert: Checked

4. Save the event handler
5. Navigate to Development Tools -> Business Rule Definition -> Data Object Manager

6. Search for "Users" and add the event handler to the Pre-Insert list.

7. Click on event handler name and OK.


8. Save.
From now on, all OIM users that will be created will have a userid with First name first alphabet last name first alphabet and a unique sequence number, regardless the given user id in the Administrative Console, or the userid that comes in some cases, in the reconciliation event.
Execution in OIM design Console:
1.Create users

2.Create User Details

3.UserId with First letter of first name, last name and sequence is generated





4.New User is provisioned to Active Directory
