|
 |
|
Oracle Concepts -
Use Of Roles
Oracle Tips by Burleson Consulting |
Use Of Roles
Using roles has several benefits, including:
* Reducing the number of grants and thereby
making it easier to manage security.
* Dynamically changing the privileges for many
users with a single grant or revoke.
* Selectively enabling or disabling depending
on the application.
Roles can be used for most system and object
privileges. Privileges granted through a role cannot be used for
creating an object (views, packages, procedures, and functions). You
need to grant privileges directly to the user for this.
Creating Roles
You need to create the role first and then
grant system and object privileges to that role. When you create the
role, there are three password options available:
* No authentication
* Operating system authentication
* Password authentication
You can set operating system authentication
either when the role is created or by using the database
initialization parameters OS_ROLES=TRUE and REMOTE_OS_ROLES=TRUE. If
you are using the multithreaded server option, you cannot use
operating system authentication for roles.
To create a role, you must have the CREATE
ROLE system privilege. You can create roles with Server Manager or at
the command line in SQL*Plus. The command syntax for creating a role
is seen in Listing 39.
Listing 39: Syntax for creating a role.
A role can also be identified globally by
using the GLOBALLY keyword in the IDENTIFIED clause. This means the
role will be authenticated by the Oracle Security Server.
Here is an example:
CREATE
ROLE appusers
GLOBALLY IDENTIFIED;
To alter a role, you must have the ALTER ANY
ROLE system privilege or have been granted the role with the WITH
ADMIN OPTION. The creator of any role automatically has the WITH ADMIN
OPTION for that role.
Grants To Roles
To grant a role to a user, you must either be
the creator of that role or have the GRANT ANY ROLE privilege. You can
grant roles to users with Server Manager or at the command line in
SQL*Plus. Grants to roles will not take effect for a user if that user
is currently logged into the database with that role. When the user
exits or sets another role, the changes will take effect. Once roles
have been granted to a user, they can be enabled and disabled.
Here is an example:
GRANT
enduser
TO patrick ;
Here is an example for a role:
GRANT
create session
TO enduser;
Here is an example of granting an object
privilege to a role:
GRANT
select
ON john.emp
TO enduser;
The only system privilege which cannot be
granted to a role is the UNLIMITED TABLESPACE grant, however, it is
implicitly granted whenever the DBA or RESOURCE role grant is made to
a user. Grants on objects can be passed to other users or to roles if
the grantee has been given the WITH GRANT OPTION. However, you cannot
assign a privilege that includes the WITH GRANT OPTION to a role. The
INDEX and REFERENCES privileges cannot be granted to a role; they must
be granted only to a user. You can grant that role to a user or to
another role. However, you cannot grant a role to itself.
You can look at the data dictionary tables
shown in Table 21 for information on views for roles.
Column
Definition
DBA_ROLES
|
Column |
Definition |
|
Role |
Name of the role |
|
password_required |
Yes, No, Global or External for operating
system authentication |
DBA_ROLE_PRIVS
|
Column |
Definition |
|
grantee |
Name of the user or role receiving the
grant |
|
granted_role |
Name of the role |
|
admin_option |
Y if it was granted with the admin option |
|
default_role |
Y if this is the grantee’s default role |
ROLE_ROLE_PRIVS
|
Column |
Definition |
|
role |
Name of the role receiving the role grant |
|
granted_role |
Name of the role granted the role |
|
admin_option |
Indicates the role was granted with the
admin option |
ROLE_SYS_PRIVS
|
Column |
Definition |
|
ROLE |
Name of the role receiving the system
privilege |
|
privilege |
System privilege being granted |
|
admin_option |
Indicates the grant was with the admin
option |
Table 21: Data dictionary views for
roles.
This is an excerpt from
the eBook "Oracle
DBA made Simple".
For more details on Oracle
database administration, see the "Easy
Oracle Jumpstart" by Robert Freeman and Steve Karam. It’s
only $19.95 when you buy it directly from the publisher
here.
Related Oracle Role Articles:
Oracle Roles
General Oracle
Security
Monitoring User Roles
|