Oracle 登入觸發器
CREATE OR REPLACE TRIGGER SYS.CONTROL_LOGON
AFTER LOGON
ON DATABASE
DECLARE
UIP VARCHAR2(300);
PRGRM VARCHAR2(60);
CUSER VARCHAR2(60);
MO VARCHAR2(60);
/******************************************************************************
this trigger is to monitor the control of logon
******************************************************************************/
BEGIN
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS'),USERNAME,PROGRAM,MODULE INTO UIP,CUSER,PRGRM,MO FROM V$SESSION WHERE AUDSID=USERENV('sessionid') and rownum=1;
IF CUSER IN ('EXPENSECTL') AND INSTR(UPPER(PRGRM),'TOAD')>0 AND UIP IN ('10.161.32.1','10.130.2.144','10.130.2.121','10.130.2.241','10.244.154.47','10.130.2.79','10.164.68.63','10.164.68.65','10.134.130.131','10.161.32.65','10.134.130.117') THEN
NULL;
ELSIF CUSER IN ('EXPENSECTL') AND INSTR(UPPER(PRGRM),'TOAD')>0 THEN
INSERT INTO sys.C_LOGIN_LOG_T(SELECT USERNAME,COMMAND,SCHEMANAME,PROGRAM,TERMINAL,SYS_CONTEXT('USERENV','IP_ADDRESS') IP,SYSDATE FROM V$SESSION WHERE AUDSID=USERENV('SESSIONID'));
COMMIT;
RAISE_APPLICATION_ERROR(-20001,'IP登入管控!');
END IF;
END ;
/
select
SYS_CONTEXT('USERENV','TERMINAL') terminal,
SYS_CONTEXT('USERENV','LANGUAGE') language,
SYS_CONTEXT('USERENV','SESSIONID') sessionid,
SYS_CONTEXT('USERENV','INSTANCE') instance,
SYS_CONTEXT('USERENV','ENTRYID') entryid,
SYS_CONTEXT('USERENV','ISDBA') isdba,
SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,
SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,
SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
SYS_CONTEXT('USERENV','CURRENT_USER') current_user,
SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,
SYS_CONTEXT('USERENV','SESSION_USER') session_user,
SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,
SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,
SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,
SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,
SYS_CONTEXT('USERENV','DB_NAME') db_name,
SYS_CONTEXT('USERENV','HOST') host,
SYS_CONTEXT('USERENV','OS_USER') os_user,
SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,
SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,
SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol, SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,
SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,
SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE') authentication_type,
SYS_CONTEXT('USERENV','AUTHENTICATION_DATA') authentication_data
from dual ;
CREATE OR REPLACE TRIGGER SYS.CONTROL_LOGON
AFTER LOGON ON DATABASE
DECLARE
PRGRM VARCHAR2(60);
MO VARCHAR2(60);
BEGIN
SELECT PROGRAM, MODULE INTO PRGRM, MO FROM V$SESSION WHERE AUDSID=USERENV('sessionid') and rownum=1;
IF PRGRM IN ('scanbarcode.exe', 'PALLET.exe') THEN
EXECUTE IMMEDIATE 'ALTER SESSION SET CURSOR_SHARING=EXACT' ;
ELSIF
NULL ;
RAISE_APPLICATION_ERROR(-20001, '程式登入管控!');
END IF;
END ;
/
CREATE OR REPLACE TRIGGER SYS.CURSOR_SHARING AFTER LOGON ON DATABASE
DECLARE
UIP VARCHAR2(300);
PRGRM VARCHAR2(60);
CUSER VARCHAR2(60);
MO VARCHAR2(60);
BEGIN
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS'),USERNAME,PROGRAM,MODULE INTO UIP,CUSER,PRGRM,MO FROM V$SESSION WHERE AUDSID=USERENV('sessionid') and rownum=1;
IF INSTR(UPPER(PRGRM),'TOAD.EXE')>0 THEN
EXECUTE IMMEDIATE 'ALTER SESSION SET CURSOR_SHARING=FORCE';
END IF;
END;
---------------------------------------------------------------------------------------
不過版本不一樣, 執行結果也有不一樣, 研究中 。
9i 中執行如下SQL
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS'),USERNAME,PROGRAM,MODULE
FROM V$SESSION WHERE AUDSID=USERENV('sessionid')
得到結果把後臺程式及其他同仁登入的程式也抓出來了:
SYS_CONTEXT('USERENV','IP_ADDRESS'),USERNAME,PROGRAM,MODULE
10.161.32.120,,oracle@imbfatp (PMON),
10.161.32.120,,oracle@imbfatp (DBW0),
10.161.32.120,,oracle@imbfatp (LGWR),
10.161.32.120,,oracle@imbfatp (CKPT),
10.161.32.120,,oracle@imbfatp (SMON),
10.161.32.120,,oracle@imbfatp (RECO),
10.161.32.120,,oracle@imbfatp (CJQ0),
10.161.32.120,,oracle@imbfatp (ARC0),
10.161.32.120,,oracle@imbfatp (ARC1),
10.161.32.120,SYS,toad.exe,TOAD 9.7.2.5
10.161.32.120,SYS,toad.exe,TOAD 9.7.2.5
10.161.32.120,SYS,toad.exe,TOAD 9.7.0.51
10.161.32.120,SYS,Toad.exe,Toad.exe
在10g 中執行同樣的語句, 只有一個結果 。
SYS_CONTEXT('USERENV','IP_ADDRESS'),USERNAME,PROGRAM,MODULE
10.161.32.120,SYS,toad.exe,TOAD 9.7.0.51
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-711607/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle開發基礎-觸發器Oracle觸發器
- 禁止oracle表的觸發器triggerOracle觸發器
- 登入觸發器不生效,只在alert日誌中顯示觸發器
- oracle儲存過程和觸發器Oracle儲存過程觸發器
- MySQL入門-- TRIGGER(觸發器)MySql觸發器
- Oracle登入命令Oracle
- 淺入淺出SQL Server 觸發器SQLServer觸發器
- [MySQL光速入門]026 觸發器 trigger!!!MySql觸發器
- mysql觸發器MySql觸發器
- D觸發器觸發器
- SqlServer服務中利用觸發器對指定賬戶進行登入ip限制提升安全性SQLServer觸發器
- SqlServer-觸發器SQLServer觸發器
- logon觸發器for dbaGo觸發器
- MySQL使用觸發器MySql觸發器
- 語句觸發器觸發器
- MySql-觸發器MySql觸發器
- sqlserver 列觸發器SQLServer觸發器
- 除錯觸發器除錯觸發器
- 建立MySQL觸發器MySql觸發器
- oracle安裝後無法登入Oracle
- 瞭解SQL Server觸發器及觸發器中的事務AWSQLServer觸發器
- 批量機器登入
- 觸發器 REFERENCING OLD AS OLD觸發器
- 行為和觸發器觸發器
- MySQL觸發器介紹MySql觸發器
- sql-server觸發器SQLServer觸發器
- 客戶端登入Oracle 12.2伺服器報ORA-01017的解惑客戶端Oracle伺服器
- SQL Server:觸發器詳解SQLServer觸發器
- mvvm模式 事件觸發器[wpf]MVVM模式事件觸發器
- 怎麼登入遠端伺服器 遠端登入VPS伺服器伺服器
- 怎麼登入伺服器 如何登陸伺服器伺服器
- Linux伺服器---ssh登入Linux伺服器
- SQL觸發器例項講解SQL觸發器
- MSMQ 觸發器 安裝失敗MQ觸發器
- SQL Server 觸發器詳情HOPPSQLServer觸發器
- MySQL觸發器的使用規則MySql觸發器
- SqlServer觸發器的建立與使用SQLServer觸發器
- oracle windows sqlplus ora-01017 登入被拒絕OracleWindowsSQL
- 【網頁登入】QQ 登入、微信登入、微博登入、GitHub 登入網頁Github