Salesforce

How to dump and load Audit and related data programmatically?

« Go Back

Information

 
TitleHow to dump and load Audit and related data programmatically?
URL Namehow-to-dump-and-load-audit-and-related-data-programmatically
Article Number000115911
EnvironmentProduct: OpenEdge
Version: 10.x, 11.x, 12.x
OS: All Supported Platforms
Other: Auditing
Question/Problem Description
The code snippets below demonstrate how to create a programmatic solution for dumping and loading Audit Data, Policies and Permissions records from/to an OpenEdge database.
 
Steps to Reproduce
Clarifying Information

 
Error Message
Defect Number
Enhancement Number
Cause
Resolution

Audit Data:

When performing an ascii dump of audit data, it is always exported from the database using a UTF-8 codepage.  It is recommended to use PROUTIL -C AUDITARCHIVE to dump audit data if the database codepage is other than utf-8 and you suspect there are characters in the database that do not exist in the utf-8 codepage.

Using proutil with the auditarchive directive respects the codepage of your database, as the dump is binary.
/* Dump Audit Data 
   Note: Requires a minimum of Audit Data Reporter permission */
RUN prodict/dump/_dmpsec.p ( INPUT "<dbname>", /* Database name */
                             INPUT "All", /* Filter */
                             INPUT "", /* Dump directory */
                             INPUT "", /* LOB folder */
                             INPUT "ad" ). /* Dump type: ad, x */

/* Load Audit Data 
   Note: Requires Audit Data Archiver permission */
RUN prodict/dump/_lodsec.p ( INPUT "", /* Load directory */
                             INPUT "ad", /* Load type: ad, x */
                             INPUT "<dbname>", /* Database name */
                             INPUT "" ). /* LOB folder */

Audit Policies, Events and Security Permissions (audit permissions):

Note that you can be reasonably assured that the data in the audit Policies, Events and Security Permissions tables contain no extended characters in them.  However since some of these data are entered manually (table and field names, userids, event names, etc...) it is possible extended characters could have been entered possibly by copy/paste from rich text editors or html.

If your database codepage and client codepage (-cpinternal -cpstream) differ, you will receive a warning when dumping these data.  Be aware that if these data contain extended characters (however unlikely), they might be corrupted when converting from the database codepage to the client codepage or vice versa.

It is best to use the same codepage on both the client and the database when dumping and loading to be certain characters are not corrupted when converting characters that don't exist in one or the other codepage.

If the database is UTF-8 and the client is a character interface (Windows character and *NIX environments) you can start the client with -cpinternal utf-8  and -cpstream utf-8 as long as this runs in batch (-b) mode.
/* Dump Audit Policies as XML 
   Note: Requires Audit Administrator permission */
RUN prodict/dump/_dmpaudp.p ( "x", /* Dump type */ 
                              "*", /* Dump filter */
                              "<file-name>" ). /* Output file */

/* Dump Audit Policies as Text
   Note: Requires Audit Administrator permission */
RUN prodict/dump/_dmpsec.p ( INPUT "<dbname>", /* Database name */
                             INPUT "All", /* Filter */
                             INPUT "", /* Dump directory */
                             INPUT "", /* LOB directory */
                             INPUT "ad" ). /* Dump type */

/* Load Audit Policies as XML
   Note: Requires Audit Administrator permission */
RUN prodict/dump/_lodaudp.p ( INPUT "x", /* Mode */
                              INPUT "<file-name>.xml", /* Comma separated list of file(s) to load */
                              INPUT [ TRUE | FALSE ] ). /* Overwrite existing */

AUDIT-POLICY:REFRESH-AUDIT-POLICY("DICTDB"). 

/* Load Audit Policies as Text
   Note: Requires Audit Administrator permission */
RUN prodict/dump/_lodsec.p ( "", /* Load directory */
                             "ad", /* Load type */
                             "<dbname>", /* Database name */
                             "" ). /* LOB directory */

AUDIT-POLICY:REFRESH-AUDIT-POLICY("DICTDB").

/* Dump audit events
   Note: Requires Audit Event Inserter permission */
RUN prodict/dump_d.p ( "_aud-event", /* Table name */
                       ".", /* Output folder */
                       ""). /* codepage */

/* Load audit events
   Note: Requires Audit Event Inserter permission */
RUN prodict/load_d.p ( "_aud-event", /* Table name */
                       "."). /* Input folder */

/* Dump security (audit) permissions */
RUN prodict/dump_d.p ( "_sec-role,_sec-granted-role,_sec-granted-role-condition", /* Table list */
                       ".", /* Output folder */
                       "" ). /* codepage */

/* Load security (audit) permissions */
RUN prodict/load_d.p ( "_sec-role,_sec-granted-role,_sec-granted-role-condition", /* Table list */
                       "."). /* Input folder */

 
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:11 AM

Powered by