DB2 JavaScript request filter

The JavaScript request filter is the most flexible of all request filters. It can potentially be called for any request packet type, and can modify traffic in any way it sees fit.

Parameters


Example: change the login user ID and password

When using standard user id/password authentication, a DB2 client starts a connection to the database by sending (among other things) a SECCHK packet.

It is therefore possible to intercept that packet and modify it.

To do so, you would create a JavaScript request filter with the parameter:

You would then add the following code to the filter:

if (context.packet.USERID === 'db2inst1') {

    if (context.packet.PASSWORD !== 'Password1') {

        log.info("Correcting password...");

        context.packet.PASSWORD = 'Password1';

    }

    else {

        log.info("Password is correct");

    }

}