This page contains configuration instructions to use K2BAudit with DB2 for iSeries. These instructions steps must be followed whenever a new environment using this DBMS is created. Some of them also apply when deploying an application with K2BAudit that uses DB2 for iSeries.
In your KB, a new DataStore called “K2BAudit” will appear after executing the “Initialize Audit” action. This DataStore is the location where the audit logs are stored. This DataStore must be configured to connect to the K2BAuditAnalyzer database.
If you are configuring the DataStore in the GeneXus IDE, you can find it in the DataStores section of your environment’s configuration.
|
K2BAudit DataStore |
If you are configuring the DataStore in the generated application, you must use the configuration file.
When an operation is audited, the user that is currently using the application is saved together with the operation values.
In order to get the application user, K2BAudit uses a procedure that is configured in the “After connect” property in the generator. The procedure that should be used in DB2 for iSeries environments is the “K2BSaveAuditUserAfterConnectDB2”.
|
K2BAudit After connect procedures |
In this procedure there is a section delimited by comments with the text “Set User Code”. The developer must update this section’s contents to load the correct User Code in the &User variable. The default implementation loads the user code from the application context.
|
Set User Code section |
After updating the procedure’s code, the “After connect” property in the model must be updated to reference this procedure.
|
After connect property |
K2BAudit uses stored procedures when saving the application user in the database connection so that triggers may access it. The code for these stored procedures is located in "<GX_INSTALL_DIR>\Packages\K2BTools\Audit\DB2\K2BAuditProcedures.sql".
Before running this script, replace the value "K2BTools" by the name of the application's database. For example, if your application's database is called "AppDB", the SetAudit procedure will be modified in these lines:
- CREATE PROCEDURE AppDB.SETAUDIT (instead of K2BTools.SETAUDIT)
- SPECIFIC AppDB.SETAUDIT (instead of K2BTools.SETAUDIT)
In the audited KB, delete all the code in the K2BAuditModelDBMS, and replace it with this line:
&AuditModelDBMS = “DB2”
By default, DB2 triggers are disabled. In order to enabled them, in the audited KB go to Preferences -> K2BAudit Settings, and set (in platforms category) Generate for DB2 to true.
|
Enable DB2 for ISeries triggers generation |
Type:GeneXus.Data.GxADODataException.Type:IBM.Data.DB2.iSeries.iDB2SQLErrorException.DBMS
Error Code:-204.SQL0204
Check that procedure K2BGetAuditDataBaseName is returing the name of the Application DataBase. If the problem persists, in the Default DataStore set DataBase library property to application database.
|