Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The Oracle database views client's user login information, including ip

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Log the user login by creating a trigger, audit the login user, record the login user, host, system user and IP address:

1. Create a table in sys mode to record the details of the client logging in to the database server.

Create table login_history (username varchar2 (60),-- user name machine varchar2 (60),-- Machine name login_time date,-- Login time ip varchar2 (50)-- ip address) Or SQL > create table LOGON_TABLE as select sysdate logon_time, sys_context ('USERENV','SESSION_USER') username, sys_context (' USERENV','HOST') host, sys_context ('USERENV','OS_USER') os_user, sys_context (' USERENV','IP_ADDRESS') ip_address from dual / Table created.

two。 Create a trigger in sys mode.

Create or replace trigger login_log after logon on database begin insert into login_history select username, machine, sysdate, sys_context ('userenv',' ip_address') from v$session where audsid = userenv ('sessionid'); commit; end Or SQL > create or replace trigger tri_logon after logon on database begin insert into LOGON_TABLE (logon_time, username, host, os_user, ip_address) values (sysdate Sys_context ('USERENV',' SESSION_USER'), sys_context (' USERENV','HOST'), sys_context ('USERENV','OS_USER'), sys_context (' USERENV','IP_ADDRESS')) End; / Trigger created.

3. Some instances that view the number of sessions (log in as sys user)

-- View the login_ calendar table select * from login_history;-- View the current number of all session (*) from session sessions;-- View all the session numbers of the current client computer named RHEL select count (*) from v$session where machine = 'RHEL';-- View the current number of connections of each client computer select count (*), machine from v$session group by machine

4. View the ip of the current session

Select sys_context ('userenv','ip_address') from dual

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report