473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Auditing with an Oracle back end?

Hello,

I have a .net web app with an Oracle back end and I need to audit my database. I created this template trigger that I was using on inserts, edit & deletes however...

Expand|Select|Wrap|Line Numbers
  1. "CREATE OR REPLACE TRIGGER {0}.BIUD_{3} 
  2.   BEFORE INSERT OR UPDATE OR DELETE ON {0}.{2} 
  3.   REFERENCING OLD AS OLD NEW AS NEW 
  4.   FOR EACH ROW 
  5. BEGIN 
  6.   IF inserting THEN 
  7.     SELECT {0}.{1}.nextval 
  8.     INTO   :NEW.{4} 
  9.     FROM   dual; 
  10.  
  11.     INSERT INTO {0}.{5} 
  12.                ({4}{6}, 
  13.                 auditaction, 
  14.                 audituser, 
  15.                 auditdate) 
  16.     VALUES     (:NEW.{4}{7}, 
  17.                 'INSERT', 
  18.                 substr(sys_context('userenv','os_user'), INSTR(sys_context('userenv','os_user'),'\')+1), 
  19.                 SYSDATE); 
  20.   END IF; 
  21.  
  22.   IF updating THEN 
  23.     INSERT INTO {0}.{5} 
  24.                ({4}{6}, 
  25.                 auditaction, 
  26.                 audituser, 
  27.                 auditdate)
  28.     VALUES     (:OLD.{4}{7}, 
  29.                 'UPDATE', 
  30.                 substr(sys_context('userenv','os_user'), INSTR(sys_context('userenv','os_user'),'\')+1), 
  31.                 SYSDATE); 
  32.   END IF; 
  33.  
  34.   IF deleting THEN 
  35.     INSERT INTO {0}.{5} 
  36.                ({4}{6}, 
  37.                 auditaction, 
  38.                 audituser, 
  39.                 auditdate) 
  40.     VALUES     (:OLD.{4}{8},
  41.                 'DELETE', 
  42.                 substr(sys_context('userenv','os_user'), INSTR(sys_context('userenv','os_user'),'\')+1), 
  43.                 SYSDATE); 
  44.   END IF; 
  45. END;
  46. /"
  47.  
I only get the username if I use impersonation and I restrict the web app to a user group (no anonymous login).
I have 1 oracle question and 1 .Net question.
Is it possible to get the correct username in Oracle without using impersonation?
If not, is there anyway I can configure .net so I don't have to use impersonation to send the user name?
If not I'm going to have to do my auditing at the application level, boooo.
Jul 6 '09 #1
1 2540
OK, to solve this I added ModifiedBy and IsDeleted Columns to all my tables.
In my DAL I set it up so that ModifiedBy is automatically set to the user I want.
I also changed my DAL to implement soft deletes and then my DAL automatically performs a hard delete after every soft delete. A soft delete is merely an update where the IsDeleted field is set to 1.
In my trigger I changed the audit username value to the modifiedby field that my dal passes. For deletes, I do the auditing on the soft delete that my DAL performs as that is the only opportunity to capture the user name.

This is a screwy fix to this problem, but it is a fix none the less.
Jul 8 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: cxw0106 | last post by:
Is there any way to implement File Auditing in .NET? Thanks.
4
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript...
10
by: Paulo Jan | last post by:
Hi all: Let's say I'm designing a database (Postgres 7.3) with a list of all email accounts in a certain server: CREATE TABLE emails ( clienteid INT4, direccion VARCHAR(512) PRIMARY KEY,...
0
by: RdR | last post by:
Is it true that DB2 will have an auditing tool to be used for auditing requirements such as Sarbanes-Oxley, etc? Something called Websphere Compliance Auditing? Rumours have it that IBM has a new...
10
by: Andrea M. Segovia | last post by:
Hello, I am a newbie to Oracle databases.... We have a visualization front-end tool connected to an Oracle back-end database on a Tru64 UNIX server. We also have clients with MS access...
4
by: Ed Rauscher | last post by:
Does ayone know what Class is used to enable Registry Auditing? Any help would be great.
14
by: Jonas | last post by:
Hi! I'm developing the middletiers of an ASP.NET application in VB.NET. I've got a business logic layer in which I would like to perform auditing to a database. Instead of making an auditing...
6
by: Rico | last post by:
Hello, I'm creating an audit table and associated triggers to be able to capture any updates and deletes from various tables in the database. I know how to capture the records that have been...
0
by: dba | last post by:
Hi folks, I would just like to share with you SQL CodeSecure, a newly released database protection and auditing tool from SqlLabs: SQL CodeSecure provides ultimate protection from unauthorized...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.