473,385 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Trigger to restrict alter session

We have a third party application that connects to an oracle database using a generic login. This application has a connection dialog that allows you to select a schema to connect to and I want to restrict some people from using some of those schemas. I created the trigger below which fires when someone first logons to the foo schema, it checks a table that I have created and if they are in the table then it alters their session to the one I have specified in the table. I have found that if someone switches schemas, then this doesn't fire. If I logon to fooey schema and then so an "alter session set current_schema = foo" then the trigger is not fired. I assume since I am not loging into a schema but merely switching schema that this is why it doesn't fire. How do I get this to fire when someone switches schemas? Is this the wrong trigger type? I looked at the list of triggers that I could create but didn't see anything that looked correct.

create or replace trigger user_logon
after logon on foo.schema
declare
nRowCount number;
sDef_Schema varchar(64);
sOS_User varchar(64);
BEGIN
SELECT SYS_CONTEXT('USERENV', 'OS_USER') INTO sOS_User FROM DUAL;
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM valid_users where OS_USER = ''' || sOS_User || '''' INTO

nRowCount;
if nRowcount > 0 then
EXECUTE IMMEDIATE 'SELECT DEFAULT_SCHEMA from valid_users where OS_USER = ''' || sOS_User || ''''

INTO sDef_Schema;
EXECUTE IMMEDIATE 'alter session set current_schema = ' || sDef_Schema;
end if;
END;
Sep 22 '10 #1
2 4761
amitpatel66
2,367 Expert 2GB
Instead of handling and performing this validation at database level, why dont to restrict users by controlling the schema list before they login in front end application? The drop down for X user should show only those schema to which it has right to login in to. For user Y, it should should specific list of schema that it can access.
Sep 23 '10 #2
Unfortunately this is a third party app, so I don't have control to restrict what schemas are show.

Thinking about this more, is there a way for a logon trigger to execute a set role? The app uses a generic login to oracle but in the trigger I can see the OSUSER who is trying to connect. In sqlplus I can alter the roles and restrict what schemas this app sees. I understand that there is a set role that will set the role of the session but from all the info that I am finding it looks like you cannot do this from within a logon trigger. Is this true for 10g?
Sep 24 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: valexena | last post by:
In order to set SQL*PLUS session so that NLS_DATE_FORMAT information is altered in a specific way every time I log into Oracle which method would be used? -- Posted via http://dbforums.com
2
by: moklet | last post by:
i've been trying to create an insert/update trigger on v_$session but with no success. following is my code: 1 create or replace trigger trg_module 2 instead of insert or update on t_$session...
10
by: Bob Bedford | last post by:
In the attempt to keep the URL and code quite clean, and avoid to have a very loooong url, we have used $_session for storing values trough the pages. Now, we have some clients that doesn't get...
5
by: rich00 | last post by:
i am developing an asp.net web based application using javascript as the server side scripting language. The application makes constant use of an access database and session variables. in a random...
2
by: Dima Gofman | last post by:
I have a trigger on UPDATE on a table. I'm running some maintenance UPDATE and DELETE queries which I want the trigger to ignore but at the same time I want other UPDATE queries that other users...
3
by: Jim Carlock | last post by:
I have a problem where session cookies get left inside the temporary folder. Is this a common problem or is there perhaps something I've over looked - there a way to make sure the session...
3
by: Wojto | last post by:
Hi there! I need to write a trigger that will check referential integrity of my data. I have few FOREIGN KEY constraints but, as You probably konow, the cannot be deferred (in the meaning of SQL...
5
by: mikys67 | last post by:
Hi. I have to trace some users application to find the source of problems. Oracle8i Enterprise Edition Release 8.1.7.0.0 connect system/manager@testdb create or replace trigger...
0
by: sybrandb | last post by:
amitvij78 <member43015@dbforums.comwrote in message news:<3406595.1065533154@dbforums.com>... NLS_LANG is an environment variable (Unix) or a registry variable (Winblows) Sybrand Bakker...
2
by: =?Utf-8?B?R2Vvc3Ns?= | last post by:
Dear All, I try to change a master page in the OnPreInit in a asp.net page. (Session variable is guaranteed to have been assigned) protected override void OnPreInit(EventArgs e){ if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.