Connecting Tech Pros Worldwide Forums | Help | Site Map

Tracing users by after logon trigger

Newbie
 
Join Date: Mar 2008
Posts: 3
#1: Mar 29 '08
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

amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#2: Mar 29 '08

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?
Newbie
 
Join Date: Mar 2008
Posts: 3
#3: Mar 29 '08

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
Newbie
 
Join Date: Mar 2008
Posts: 3
#4: Mar 30 '08

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
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#5: Mar 31 '08

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?? .
Newbie
 
Join Date: Jun 2009
Posts: 1
#6: Jun 18 '09

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