|
|
|
|
Re: Need help with button pressed trigger [message #538541 is a reply to message #538539] |
Fri, 06 January 2012 15:12 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
if user_has_role('username','rolename') then
-- user has the role, so do something
else
-- user does not have role, so do something else
end if;
QED
However you still are using the dba taables, which should fail for every user except the DBA. And if it doesn't, then you have a security problem in your database.
[Updated on: Fri, 06 January 2012 15:14] Report message to a moderator
|
|
|
|
|
Re: Need help with button pressed trigger [message #538591 is a reply to message #538588] |
Sat, 07 January 2012 08:51 |
|
winnitbaker
Messages: 20 Registered: January 2012
|
Junior Member |
|
|
Here you go -
SQL> create or replace function user_has_role(p_user in varchar2 default user, p_role in varchar2)
2 return boolean as
3 v_count pls_integer;
4 begin
5 select count(*)
6 into v_count
7 from dba_role_privs
8 where grantee = p_user
9 and granted_role = p_role;
10 if v_count = 0
11 then
12 return false;
13 else
14 return true;
15 end if;
16 end;
17 /
Warning: Function created with compilation errors.
SQL> show errors
Errors for FUNCTION USER_HAS_ROLE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
5/1 PL/SQL: SQL Statement ignored
7/6 PL/SQL: ORA-00942: table or view does not exist
[Updated on: Sat, 07 January 2012 08:54] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Need help with button pressed trigger [message #538600 is a reply to message #538599] |
Sat, 07 January 2012 09:26 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Where did you take DBA_ROLES from? You were dealing with DBA_ROLE_PRIVS until now ...
Here you are, once again:
SQL> grant select on dba_role_privs to scott;
Grant succeeded.
SQL> connect scott/tiger
Connected.
SQL> create or replace function user_logged_in(p_user in varchar2 default user)
2 return boolean as
3 v_count pls_integer;
4 begin
5 select count(*)
6 into v_count
7 from dba_role_privs
8 where grantee = p_user;
9 if v_count = 0
10 then
11 return false;
12 else
13 return true;
14 end if;
15 end;
16 /
Function created.
SQL>
[Updated on: Sat, 07 January 2012 09:27] Report message to a moderator
|
|
|
|
|