Saturday 15 August 2015

Custom Connector Creation- DB Connector

Creating Database as Target resource-


1) Login to Database through Admin User "sys as sysdba". Below is the Property-



2) Create Schema in DB-
create user IDAM_USER identified by Welcome1;  

grant connect , resource , create session to IDAM_USER;




3) Connecting to IDAM_USER Schema (Created above)















4) Run the below command for creating the table in Schema and insert some record for verifying the data-


create table appusers(userid varchar2(20),firstname varchar2(30),lastname varchar2(30),email varchar2(30),address1 varchar2(30),address2 varchar2(30),zip varchar2(30),mobile varchar2(20),ssn varchar2(15));

insert into appusers values('tusr1','test','user1','tuser1@test.com','main st','new york','21334','12566777','2425366');

insert into appusers values('tusr2','test','user2','tuser2@test.com','main st','new york','21443','7761342','89320');















5) Target Resource created as DB. Now we will create Custom connector for making the connection of OIM and Target resource.

=========================================================

Steps for creating the Custom Connector
--------------------------------------------------------------------------------------------------
Below are the required component for creating the Custom Connector-
High Level Steps-

1.                   IT resource Type
2.                   IT resource
3.                   Resource Object
4.                   Process Form
5.                   Process task Adaptor
6.                   Process definition
7.                   Process task

After creating the Custom Connector Component perform the below operation-

1) Create and Activate the Sandbox in Sysadmin console.
2) Create Form through Form Designer from Sysadmin console.
3) Publish the Sandbox.
4) Create Application Instance and select the IT Resource, resource Object and Form created above.
5) Run the Catalog Synchronization Job for adding the Newly created Application Instance in Catalog table for making the Application Instance as requestable.
6) Create User and request the Application Instance and verify in target DB. (appusers table)

-------------------------------------------------------------------------------------------------

1) Creating IT Resource Type-

Design Console--> Resource Management-->IT Resource Type Definition

In Server Type provide the IT Resource Name as- "TargetDB"and save it. After saving,  Add button will be enabled so add the IT Resource Type Parameter-
URL, Username, Password, Tablename  




















2) Creating IT Resource
a) Login to Sysadmin Console-->Configuration--> IT Resource

Click on Create IT Resource-
















b) provide the below details-
















c) Click on Continue and Provide the IT resource Parameter value-

Password- ******** (provide whatever you have set the password)
Tablename- appusers
URL- jdbc:oracle:thin:@localhost:1521:OIMDB
Username- IDAM_USER
















d) Click on Continue and Finish
















3) Create Resource Object-

Provide the Name as "TargetDBRO" and select the Type as "Application" and save the Resource Object.
















4) Create Process Form-

Design Console--> Development Tools--> Form Designer
Provide Table Name - UD_Target_P
Provide the Description and Save.
After saving the Process Form add the below Fields on Process Form. These fields are same as the Database fields which I have created in appuser table.












a) Process Form Fields are added like below- Same as map other fields also-





















b) If you want to pre-populate above fields value on process Form then Go To Pre-populate Tab and attach the Pre-populate Adapter- LDAP String to each fields. 

Note- Since I have Installed the OID connector for connecting to OUD server so I have the LDAP String Pre-populate adapter so attaching the same. If you don't have the Pre-populate adapter then create your own Pre-populate adapter for populating the Process Form Fields value from user profile.
(Attaching the Pre-populate adapter is not mandatory you can enter the value on process Form Directly)

For attaching the Pre-populate adapter go to Prepopulate tab-->Click on Add-->Select Field from dropdown on which you want to attached the adapter and select the adapter from dropdown and click OK.













5) Process Task Adapter Creation-

a) Crate a Java code and make a Jar of this class.
package com.pts;
import java.sql.*;

public class ProvisionUser {

 private String dburl;
 private String uid;
 private String pwd;
 private String tablename;
 private Connection conn=null;
 private Statement stmt=null;
 private ResultSet rset=null;

    public ProvisionUser(String url,String ui,String pw,String tname) {
    
      dburl=url;
      uid=ui;
      pwd=pw;
      tablename=tname;
     }
    
     private Connection connect(){
         System.out.println("... Inside Connect....");
        
         System.out.println(" ....URL......"+dburl);
         try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
         System.out.println(".....Getting Connection......");
         if(conn==null)
          conn=DriverManager.getConnection(dburl,uid,pwd);
         
          System.out.println(" ....Got Connection......"+conn);
         }catch(Exception ee){
             ee.printStackTrace();
         }
         return conn;
     }
    
     private void disconnect() {
         System.out.println("... Inside DisConnect....");
         try{
             if(rset!=null) rset.close();
             if(stmt !=null) stmt.close();
             if(conn!=null) conn.close();
            
             System.out.println("... Done DisConnect....");
         }catch(Exception ee){
             ee.printStackTrace();
         }
     }
    
     public String createUser(String uid,String fname,String lname,String mail,String address1,String address2,String zip,String mobile,String ssn){
     
      String query="insert into "+tablename+" values ('"+uid+"','"+fname+"','"+lname+"','"+mail+"','"+address1+"','"+address2+"','"+zip+"','"+mobile+"','"+ssn+"')";
      System.out.println(" Query is "+query);
      try{
      this.connect();
      stmt=conn.createStatement();
      stmt.execute(query);
          System.out.println(" User created successfully");
      this.disconnect();
      }catch(Exception ee){
          ee.printStackTrace();
          return "FAILURE";
      }
    
      return "SUCCESS";
    
     }
    
    
  /* public static void main(String args[]){
        String url="jdbc:oracle:thin:@localhost:1521:OIMDB";
        ProvisionUser user=new ProvisionUser(url,"IDAM_USER","Welcome1","appusers");
         user.createUser("akini","ananth","kini","akini@yahoo.com","247 arriba dr","apt 11","94086","123456","35355");
    }*/
       
}

Test Code in Eclipse and comment the main method and create the Jar file.


Make the Jar and Copy this Jar in "Java Task" folder  in OIM. Below is the Java Task Path-

D:\OIM\OIMInstall\Oracle\Middleware\Oracle_IDM1\server\JavaTasks


Note- Same as Create Java Code for Disable User, Enable User, Delete User, Modify User.

b) Creating Adapter through Adapter Factory-

i) Providing the Adapter Name, Adapter Type and Description


ii) Save this and Go to Variable List tab and create the Constructor and Method variable-
Constructor Variable Creation-
Constructor Variables are- URL, UID, Password and Table name and its Type Should be IT Resource. Because these are the parameters through which we are making connection with Target resource.
Below is the creation of URL variable same as Create Variable uid, password and tablename













same as create varibale uid, password and tablename.

iii) Method Variable Creation-













iv) Variables are created and looks like below-












C) Go To Adapter Task Tab and click on Add button Select Java and Continue-
















d) Provide the Task Name- TargetCreateUser and select the Java Class, constructor and Method created in (5a)


































e) Click on Save button and map the Constructor and Method variable-

Here we are mapping Adapter Factory variable with our Java Class variable.

i) Constructor Variable mapping Example-



















Same as map other variable. Mapping should be in sequence.

ii) Method Variable mapping Example-




iii) Output Return Variable would be mapped as below-






























iv) After mapping  Build the Adapter so that Compile status would become OK.













6) Creating Process definition  and Process task-

Design Console--> Process management--> Process Definition
Provide the Name- TargetDBPD
Type- Provisioning
ObjectName- TagetDBRO
Table Name- UD_Target_P
Click on Save












Click on Add button and add the Task Name and Task Description-  Create User and Click on Save-












Go to Integration Tab add the Adapter and Map the Variable-

Constructor Variable with IT Resource and Method Variable with User Definition.












After Variable mapping on Integration Tab it looks like below-













Response Tab- Add the Success and Failure Message















Task to Object status Mapping Tab-

Completed with Provisioned
Rejected with Provisioning




















Now Connector is created. Perform below Steps-

1) Create and Activate the Sandbox in Sysadmin console.

2) Create Form through Form Designer from Sysadmin console.
























3) Publish the Sandbox.

4) Create Application Instance and select the IT Resource, resource Object and Form created above.

























5) Run the Catalog Synchronization Job for adding the Newly created Application Instance in Catalog table for making the Application Instance as requestable.

6) Create User and request the TargetDBApp application Instance and verify in target DB. (appusers table)

Special Thanks to- Alok Kumar for helping during Custom Connector Creation :)

4 comments:

  1. IS there possible to use this Schema of Connector for using with DBTable, WebService and Exchange? Thanks in Advance...

    ReplyDelete