Tivoli Directory Integrator – Before Initialize

As I mentioned in prior PathMaker Group blogs Tivoli Directory Integrator (TDI) is a pretty neat tool that comes packaged with IBM Tivoli Identity Manager (ITIM).  TDI comes out of the box with a multitude of connectors that are used to as the name says, connect to different sources.  One of the most common business processes where TDI is used is to extract data, transform the data and then load the data into different data source (ETL).  For an example, it is common to use TDI to extract account data from Active Directory using an LDAP connector.

Have you ever wanted to build a dynamic iterator filter that can be created when the assembly line is executed?  In the following example the assembly line uses an LDAP connector to iterate Active Directory.  The requirement is to find AD accounts where the “whenChanged” is in the last 5 days and AD entry should be a user account or a user contact and have a mail attribute.

In the “Before Initialize” Hook of the Iterator, add the following logic:

/* set up LDAP Filter */
/* Date Format = 20130101000000.0Z*/

/* set the days back to set up a date range to get objects based on whenChanged */
var startingDate = 5;

/* Setting From Date */
var wkDate = new Date(); 
    
var wkDate = new Date(wkDate.setDate(wkDate.getDate() - startingDate)); 
var currYear = wkDate.getUTCFullYear();
    
var currMonth = wkDate.getUTCMonth()+1;
if (currMonth < 10) 
       currMonth = "0" + currMonth.toString();
var currDay = wkDate.getUTCDate();
if (currDay < 10) 
       currDay = "0" + currDay.toString();
var formatedStartDate = currYear.toString() + currMonth.toString() + currDay.toString() + "000000.0Z";

/* Base Filter - Must be a user or contact with a Mail Attribute to be Selected */
var baseFilter="(&(!(objectclass=computer))(mail=*)(|(objectclass=contact)(objectclass=user))";

/* Add the whenChanged logic to the Filter */
baseFilter=baseFilter + "(whenChanged>=" + formatedStartDate + ")";
baseFilter=baseFilter + ")";

/* This statement will set the Filter in the Iterator */
thisConnector.setConnectorParam("ldapSearchFilter", baseFilter);

task.logmsg(">>>>  Base Filter = " + baseFilter);

The important piece of code is “thisConnector.setConnectorParam(“ldapSearchFilter”, baseFilter);“  This will set the Search Filter on the connector tab with the filter that is contained in the “baseFilter” attribute.  The name of the connector parameter is “ldapSearchFilter”.  This can be determined by clicking on Search Filter in the Connector Tab.  This will bring up a window where the Internal Name is visible.

Expression Editor - Search Filter

Based on the code above the Assembly line will run with a date range on the “whenChanged” Active Directory attribute.  The idea here is to get the accounts that were recently updated so they can be processed for whatever reason.

If an assembly line was executed with this “Before Initialize” hook on Jan. 17, 2013 the resulting filter would look like this:

(&(!(objectclass=computer))(mail=*)(|(objectclass=contact)(objectclass=user))
(whenChanged>=20130112000000.0Z))

I have also done similar logic building SQL for JDBC connectors.  The trick is to format the SQL so the correct data will be selected.

There is still some work and customization and most of you would probably change the date logic but this should get you started on building dynamic iterator filters.

2 replies
  1. Olivia
    Olivia says:

    Hey,

    Thanks for the blogging this.
    I tried the same thing recently but then I am getting the accounts with date that are less than formatedStartDate. Did you faced any issue with it?
    Please let me know. I need urgent help.

  2. Mark Adamson
    Mark Adamson says:

    I have never had that issue with getting dates before the start date.
    One option would be to build a filter with two dates. A start and an end date.

    “(&(whenChanged>=” + formatedStartDate + “)( whenChanged<=" + formattedEndDate + "))";

    When you put the filter into an LDAP browser does the same issue appear?

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply