RE: Audit for program at login time

From: Allen, Brandon <Brandon.Allen_at_OneNeck.com>
Date: Tue, 11 Mar 2008 14:05:47 -0700
Message-ID: <04DDF147ED3A0D42B48A48A18D574C450ABB5236@NT15.oneneck.corp>


I thought for sure this was captured by "audit session", but I looked it up and found that I was wrong. I checked both the dba_audit_session view and the sys.aud$ table and v$session.program is not captured. Sounds like a good enhancement request to me, but in the meantime I think you'll have to use a logon trigger. Here is some code to get you started (Beware - I haven't tested this, use at your own risk):

create table user_log
(

   user_id           varchar2(15),
   osuser            varchar2(30),
   session_id           number(8),
   last_program      varchar2(48)

);

CREATE OR REPLACE TRIGGER "LOGON_AUDIT_TRIGGER" AFTER LOGON ON DATABASE
DECLARE
sess number(10);
s_sid number(10);
prog varchar2(48);
s_osuser varchar2(30);
BEGIN
   sess := sys_context('USERENV','SESSIONID');    SELECT program,sid,osuser INTO prog,s_sid,s_osuser FROM v$session WHERE audsid = sess and rownum<=1;

   INSERT INTO user_log VALUES
(sys_context('USERENV','session_user'),s_osuser,sys_context('USERENV','S
ESSIONID'), prog);
END; Regards,
Brandon  

Privileged/Confidential Information may be contained in this message or attachments hereto. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of this company shall be understood as neither given nor endorsed by it.

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Mar 11 2008 - 16:05:47 CDT

Original text of this message