LDAP Dynamic Filters

The strategy here is to make use of a prolog that gets a filter (or a flag) from the Task Call Block. The syntax is a little different than that of the JDBC so I've included an example here. This one also does a recently updated and uses some LDAP date math to adjust the filter to anything changed in the last 5 min.

//*****************************************************************************
// Get TCB Parameters.
//*****************************************************************************
var tcb = task.getTCB();
var initParams = tcb.getProperty("assemblyline.operation.initialize");
var operationType  = initParams.getAttribute("operationType")


//*****************************************************************************
// Determine the query to use.
//*****************************************************************************

var filter = "";
if (operationType != null && operationType.getValue().equals("FULL")) {
task.logmsg("INFO","Full Run");
filter = "objectClass=*";
else {
task.logmsg("INFO","Recently Modified Run");
var fiveMinAgo = new Date(java.lang.System.currentTimeMillis() - 300000);
var ldapFiveMinAgo = system.formatDate(fiveMinAgo, "yyyyMMddHHmmss") + "Z";
filter = "erLdapLastModifiedTime>=" + ldapFiveMinAgo;

}

//*****************************************************************************
// Set LDAP Connector paramters.
//*****************************************************************************                                      
YOUR_LDAP_ITERATOR.setConnectorParam("ldapSearchFilter", filter);



Comments