问题描述
嗨,
我需要限制/允许客户端连接会话(即:蟾蜍)连接到数据库。
我的提要:用户与数据库的连接不应超过2个。我需要限制客户端连接。
请让我知道这是否可能限制会话使用触发器?
谢谢,
我需要限制/允许客户端连接会话(即:蟾蜍)连接到数据库。
我的提要:用户与数据库的连接不应超过2个。我需要限制客户端连接。
请让我知道这是否可能限制会话使用触发器?
谢谢,
专家解答
你可以用触发器做某事,但它可以被颠覆而不会太麻烦,例如这里有一个可以让你开始
当然,精明的用户会将他们的toad.exe重命名为其他名称。
我见过比这更复杂的解决方案,即,登录时提交一个作业,然后查找TOAD将拥有的典型打开游标,然后终止该会话...但这似乎有点过头了
CREATE OR REPLACE TRIGGER SYS.SECURE__ACCESS
after logon on database
declare
l_program v$session.program%type;
l_osuser v$session.osuser%type;
l_machine v$session.machine%type;
l_user varchar2(30) := user;
l_instance v$instance.instance_name%type := sys_context('USERENV','INSTANCE_NAME');
begin
if l_user = 'MY_USER' then
select osuser, machine, program
into l_osuser, l_machine, l_program
from v$session
where sid = sys_context('USERENV','SID');
if ( lower(l_program) like '%toad%' )
and lower(l_machine) not like '%special%'
then
select count(*)
into l_is_dba
from dba_role_privs
where grantee = upper(l_osuser)
and granted_role = 'DBA';
if l_is_dba = 0 then
raise_application_error(-20999,'This account is limited etc etc');
end if;
end if;
end if;
exception
when no_data_found then null;
when too_many_rows then null;
end;
/
当然,精明的用户会将他们的toad.exe重命名为其他名称。
我见过比这更复杂的解决方案,即,登录时提交一个作业,然后查找TOAD将拥有的典型打开游标,然后终止该会话...但这似乎有点过头了
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




