Introduction: The main function is to implement, oracle logged in user login record of success ip address, login failures Login failed record ip address
1, trigger the need for a client user's login record of success ip address
We all know that records in v $ session in the machine name of the client, but not IP, if you record clinet ip it? First run DBMS_SESSION process packages register, and then execute the stored procedure on_logon_trigger, so that when a client logged in v $ session of client_info row corresponding IP information recorded.
DBMS_SESSION process using the package, perform
BEGIN
DBMS_SESSION.set_identifier(SYS_CONTEXT('USERENV', 'IP_ADDRESS'));
END;
Then trigger trigger execution
createorreplacetrigger on_logon_trigger
after logon ondatabase
begin
dbms_application_info.set_client_info(sys_context( 'userenv', 'ip_address' ) );
end;
These processes require the implementation of the package triggers dba privileges.
-------------------------------------------------- -------------------------------------------------- ------------
<copyright, reprint articles allowed, but must indicate the source address as a link, otherwise held liable!>
original blog address: http://blog.csdn.net/ mchdba / article / details / 45749131
author: Douglas fir (mchdba)
----------------------------------- -------------------------------------------------- ---------------------------
2, and then use the super administrator through plsql logged in, you can view information about ip connection on the oracle:
Execute the query SQL:
select username,program,machine,client_info,sys_context('userenv','ip_address') as ipadd
from v$session s
where username is not null
order by username,program,machine;
Information as follows:
3, the establishment of the flip-flop to achieve when the login failure logging information:
Write a flip-flop, flip-flop of the information recorded in the alert log inside, to get the user information registration failure by viewing alert log.
Triggers are as follows:
CREATE OR REPLACE TRIGGERlogon_denied_to_alert
AFTER servererror ON DATABASE
DECLARE
message VARCHAR2(168);
ip VARCHAR2(15);
v_os_user VARCHAR2 (80);
v_module VARCHAR2(50);
v_action VARCHAR2(50);
v_pid VARCHAR2 (10);
v_sid NUMBER;
v_program VARCHAR2 (48);
BEGIN
IF(ora_is_servererror(1017)) THEN
-- get ip FOR remote connections :
IF upper(sys_context('userenv', 'network_protocol')) = 'TCP' THEN
ip := sys_context('userenv', 'ip_address');
END IF;
SELECT sid INTO v_sid FROM sys.v_$mystat WHERE rownum < 2;
SELECT p.spid, v.program
INTO v_pid, v_program
FROM v$process p, v$session v
WHERE p.addr = v.paddr
AND v.sid = v_sid;
v_os_user := sys_context('userenv', 'os_user');
dbms_application_info.read_module(v_module, v_action);
message := to_char(SYSDATE, 'YYYYMMDD HH24MISS') ||
' logon denied from ' || nvl(ip,'localhost') || ' ' ||
v_pid || ' ' || v_os_user || 'with ' || v_program || ' – ' ||
v_module || ' ' || v_action;
sys.dbms_system.ksdwrt(2, message);
ENDIF;
END;
/
Execution error:
Compilation errors for TRIGGERPOWERDESK.LOGON_DENIED_TO_ALERT
Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared
Line: 35
Text: sys.dbms_system.ksdwrt(2, message);
Error: PL/SQL: Statement ignored
Line: 35
Text: sys.dbms_system.ksdwrt(2, message);
You need to give permission
grant execute on sys.dbms_system topowerdesk;
After executing successful.
4, view alert information logon failure
Pslql login, as shown below:
Go backstage view the alert log, you will see the failure record information:
Fri May 15 19:11:09 2015
20150515 191109 logon denied from192.168.120.169 20934 Administrator with plsqldev.exe ? plsqldev.exe
20150515 191109 logon denied from192.168.120.169 20934 Administrator with plsqldev.exe ? plsqldev.exe
Fri May 15 19:11:18 2015
20150515 191118 logon denied from192.168.120.169 20958 Administrator with plsqldev.exe ? plsqldev.exe
20150515 191118 logon denied from 192.168.120.16920958 Administrator with plsqldev.exe ? plsqldev.exe