Analysis of oracle logon trigger

Source: Internet
Author: User


Oracle logon trigger analysis oracle logon trigger is generally used to audit user logon information or restrict user logon. Although it is not commonly used, it is still a good way.
Note: you cannot audit dba user logon. The following is a specific example: www.2cto.com 1. CREATE an audit TABLE: create table logonlog (OS _user varchar2 (30), user_name varchar2 (30), logon_time date, session_user varchar2 (30), ip_address varchar2 (15), program varchar2 (30); 2, create logon trigger, and restrict www users to log on to create or replace trigger on_logon after logon databasedeclare www.2cto.com user_name varchar2 (30); OS _user varchar2 (30); v_sid number; v_su varchar2 (15 ); v_program varchar2 (30); v_ip varchar2 (15); beginexecute immediate 'select distinct sid from sys. v _ $ mystat 'into v_sid;
Execute immediate 'select osuser, username, program from sys. v _ $ session where sid =: b1 'into OS _user, user_name, v_program using v_sid; select sys_context ('userenv', 'session _ user') into v_su from dual; select sys_context ('userenv', 'IP _ address') into v_ip from dual; insert into sys. logonlog values (OS _user, user_name, sysdate, v_su, v_ip, v_program); IF (user_name = 'www ') THEN DBMS_SESSION.SET_IDENTIFIER ('About to raise app_error .. '); RAISE_APPLICATION_ERROR (-20003, 'you are not allowed to connect to the database'); end if; end;/3, when can I use www.2cto.com It is advised you use this trigger only when (1) not using archive logging on the database or non-archive mode (2) there are few logons to the database. how To Create A Trigger To Capture User Information On Logon [ID 454088.1]
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.