Connecting Tech Pros Worldwide Help | Site Map

Tracing users by after logon trigger

  #1  
Old March 29th, 2008, 10:51 AM
Newbie
 
Join Date: Mar 2008
Posts: 3
Hi.

I have to trace some users application to find the source of problems.
Oracle8i Enterprise Edition Release 8.1.7.0.0
Expand|Select|Wrap|Line Numbers
  1.  
  2. connect system/manager@testdb
  3.  
  4. create or replace trigger login_trigger
  5. after logon on database
  6.   begin
  7.      if (USER in ('BLAKE','SCOTT')) then
  8. execute immediate
  9.     'ALTER SESSION SET EVENTS ''10046 TRACE NAME CONTEXT FOREVER, LEVEL 12''';
  10.      end if;
  11.   end;
  12. /
  13. show error;
  14.  
  15. SQL> connect scott/tiger@testdb
  16. ERROR:
  17. ORA-00604: error occurred at recursive SQL level 1
  18. ORA-01031: insufficient privileges
  19. ORA-06512: at line 3
  20.  
  21. OK, I'll grant a priv.
  22.  
  23. SQL> connect system/manager@testdb
  24. SQL> GRANT administer DATABASE TRIGGER TO "SCOTT";
  25.  
  26. SQL> connect scott/tiger@testdb
  27. Connected.
  28.  
Good, only *.trc file is empty after that and there is no trace information for analyse.

Could you please give me a solution?

Mikhail

Last edited by amitpatel66; March 29th, 2008 at 12:21 PM. Reason: code tags
  #2  
Old March 29th, 2008, 12:22 PM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,188

re: Tracing users by after logon trigger


After the privilege is GRANT to scott, were you able to create a after logon trigger without any error under user scott?
  #3  
Old March 29th, 2008, 12:55 PM
Newbie
 
Join Date: Mar 2008
Posts: 3

re: Tracing users by after logon trigger


Quote:
Originally Posted by amitpatel66
After the privilege is GRANT to scott, were you able to create a after logon trigger without any error under user scott?
I've done it. The empty *.trc file again
ERROR: no valuable data in trace file (not from 10046 event?)
and Why should I create scott owner trigger. I have to use one trigger to trace muliple users
  #4  
Old March 30th, 2008, 05:05 PM
Newbie
 
Join Date: Mar 2008
Posts: 3

re: Tracing users by after logon trigger


Quote:
Originally Posted by amitpatel66
After the privilege is GRANT to scott, were you able to create a after logon trigger without any error under user scott?

Sorry for the trouble I'm giving you. The reason was my misunderstanding the necessary privileges and owner to create trigger. The correct sequence to prepare trace rule must be:
1 - SYSTEM user grants ADMINISTER DATABASE TRIGGER privilege to SCHEMA OWNER (e.g.SCOTT)
2 - having such privilege SCHEMA OWNER (e.g.SCOTT) should create TRIGGER AFTER LOGON to force system trace event 10046.
3 - SYSTEM or any privileged owner controls TRIGGER using DISABLE\ENABLE instruction
  #5  
Old March 31st, 2008, 01:38 PM
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,188

re: Tracing users by after logon trigger


Quote:
Originally Posted by mikys67
Sorry for the trouble I'm giving you. The reason was my misunderstanding the necessary privileges and owner to create trigger. The correct sequence to prepare trace rule must be:
1 - SYSTEM user grants ADMINISTER DATABASE TRIGGER privilege to SCHEMA OWNER (e.g.SCOTT)
2 - having such privilege SCHEMA OWNER (e.g.SCOTT) should create TRIGGER AFTER LOGON to force system trace event 10046.
3 - SYSTEM or any privileged owner controls TRIGGER using DISABLE\ENABLE instruction
Error Resolved?? .
  #6  
Old June 18th, 2009, 03:51 PM
Newbie
 
Join Date: Jun 2009
Posts: 1

re: Tracing users by after logon trigger


The logon trigger must be created by SYS AS SYSDBA.

Even if you create a DBA user or another user with the ADMINISTER DATABASE TRIGGERS privilege, it won't work.

Regards,
Flavio

Quote:
Originally Posted by mikys67 View Post
Hi.

I have to trace some users application to find the source of problems.
Oracle8i Enterprise Edition Release 8.1.7.0.0
Expand|Select|Wrap|Line Numbers
  1.  
  2. connect system/manager@testdb
  3.  
  4. create or replace trigger login_trigger
  5. after logon on database
  6.   begin
  7.      if (USER in ('BLAKE','SCOTT')) then
  8. execute immediate
  9.     'ALTER SESSION SET EVENTS ''10046 TRACE NAME CONTEXT FOREVER, LEVEL 12''';
  10.      end if;
  11.   end;
  12. /
  13. show error;
  14.  
  15. SQL> connect scott/tiger@testdb
  16. ERROR:
  17. ORA-00604: error occurred at recursive SQL level 1
  18. ORA-01031: insufficient privileges
  19. ORA-06512: at line 3
  20.  
  21. OK, I'll grant a priv.
  22.  
  23. SQL> connect system/manager@testdb
  24. SQL> GRANT administer DATABASE TRIGGER TO "SCOTT";
  25.  
  26. SQL> connect scott/tiger@testdb
  27. Connected.
  28.  
Good, only *.trc file is empty after that and there is no trace information for analyse.

Could you please give me a solution?

Mikhail
Reply