Security - DB2 V9
Security - DB2 V9
Security
Graham G. Milne ([email protected])
I/T Specialist DB2 UDB
IBM Canada
Trademarks
Page 1 of 32
developerWorks
ibm.com/developerWorks/
objectives in Section 2 of the test, which is entitled "Security". You can view these
objectives at: http://www.ibm.com/certify/tests/.
Prerequisites
To understand the concepts described in this tutorial, you should already have a
basic knowledge of database concepts and an understanding of operating system
security features.
System requirements
The examples in this tutorial are specific to DB2 9 running on a Windows operating
system (with native security features). However, the concepts and information
provided are relevant to DB2 running on any distributed platform.
You do not need a copy of DB2 9 to complete this tutorial. However, you will get more
out of the tutorial if you download the free trial version of IBM DB2 9 to work along
with this tutorial.
Setup
To complete the steps in this tutorial, you should have:
1. Logged into a Windows machine as a user who is a member of the
Administrators group. In the examples in this tutorial, we will be logged in with
the user ID gmilne.
2. Installed DB2 9.
3. Created a new group on the machine on which DB2 was installed. In this
tutorial, the group ID db2grp1 is used.
4. Created a second user ID on the machine on which DB2 was installed. In this
tutorial, for this purpose we will use the user ID test1. Note that the test1 user is
not a member of the Administrators group.
Page 2 of 32
ibm.com/developerWorks/
developerWorks
Page 3 of 32
developerWorks
ibm.com/developerWorks/
The database server is the machine (or machines in a partitioned database system)
on which the database physically resides. The DB2 database clients are machines
that are configured to run queries against the database on the server. These clients
can be local (reside on the same physical machine as the database server) or they
can be remote (reside on separate machines).
If the database resides on a mainframe machine running an operating system like
AS/400 (iSeries) or OS/390 (zSeries), it's called a host or host server. A
gateway is a machine running the DB2 Connect product. Through the gateway, DB2
client machines can connect to a DB2 database that resides on a host machine. The
gateway is also referred to as the DB2 Connect Server. Systems with the Enterprise
Server Edition product installed also have the DB2 Connect functionality built in.
Page 4 of 32
ibm.com/developerWorks/
developerWorks
Here, authentication is done implicitly. The user ID used to log onto the machine is
used and is assumed to be already verified by the operating system.
db2 connect to sample user test1 using password
Database Connection Information
Database server
= DB2/NT 9.1.0
SQL authorization ID
= TEST1
Local database alias
= SAMPLE
Here, authentication is done explicitly. The user test1 with the password password is
verified by the operating system. User test1 is successfully connected to the sample
database.
db2 connect to sample user test1 using password new chgpass confirm chgpass
The user ID test1 with password password is verified by the operating system as in
example 2. The password for test1 is then changed by the operating system from
password to chgpass. As a result, the command in example 2 will fail if you reissue it.
Page 5 of 32
developerWorks
ibm.com/developerWorks/
(SRVCON_AUTH) = KERBEROS
(AUTHENTICATION) = SERVER_ENCRYPT
Description
SERVER
SERVER_ENCRYPT
CLIENT
*KERBEROS
*KRB_SERVER_ENCRYPT
DATA_ENCRYPT
DATA_ENCRYPT_CMP
GSSPLUGIN
GSS_SERVER_ENCRYPT
Page 6 of 32
ibm.com/developerWorks/
developerWorks
*These settings are valid only for Windows 2000, AIX, Solaris, and Linux
operating systems.
Note that authentication is never performed on the gateway itself. In DB2 Version 8,
authentication must always occur at either the client or the host database server.
Page 7 of 32
developerWorks
ibm.com/developerWorks/
Let's assume the server authentication type is set to SERVER. The following
command would then be issued on the client to catalog the server database
named sample:
db2 catalog database sample at node nd1 authentication SERVER
If the authentication type is not specified, the client will try to use
SERVER_ENCRYPT by default.
Client connecting to a host database: Let's assume that the authentication
type on the gateway is set to SERVER. If an authentication type is not specified,
SERVER_ENCRYPT authentication is assumed when accessing a database
through DB2 Connect. Authentication will take place on the host database
server. The following command issued from the client will cause the client to
send unencrypted user IDs and passwords to the gateway:
db2 catalog database myhostdb at node nd1 authentication SERVER
Page 8 of 32
ibm.com/developerWorks/
developerWorks
Trusted Client
Host Client
No
Yes
CLIENT
CLIENT
CLIENT
CLIENT
No
Yes
SERVER
CLIENT
CLIENT
CLIENT
No
No
CLIENT
SERVER
CLIENT
CLIENT
No
No
SERVER
SERVER
CLIENT
CLIENT
No
DRDAONLY
CLIENT
SERVER
SERVER
CLIENT
No
DRDAONLY
SERVER
SERVER
SERVER
CLIENT
Yes
Yes
CLIENT
CLIENT
CLIENT
CLIENT
Yes
Yes
SERVER
SERVER
SERVER
SERVER
Yes
No
CLIENT
SERVER
CLIENT
CLIENT
Yes
No
SERVER
SERVER
SERVER
SERVER
Yes
DRDAONLY
CLIENT
SERVER
SERVER
CLIENT
Yes
DRDAONLY
SERVER
SERVER
SERVER
SERVER
DRDAONLY refers to host clients only, despite the fact that DB2 Version 8 clients
connect using DRDA as well.
The examples below illustrate setting authentication types and parameters on the
server and client:
Setting authentication on the server:
db2 update dbm cfg using authentication client
db2 update dbm cfg using trust_allclnts yes
db2 update dbm cfg using trust_clntauth server
db2stop
db2start
is issued from any client, authentication takes place on the client. If the command
db2 connect to sample user test1 using password
Page 9 of 32
developerWorks
ibm.com/developerWorks/
Kerberos authentication
Kerberos authentication provides DB2 a way to authenticate users without having
to flow user IDs or passwords over the network. The Kerberos security protocol
performs authentication as a third party authentication service by using conventional
cryptography to create a shared secret key. This key becomes a user's credential
and is used to verify the identity of users during all occasions when local or network
services are requested. Using the Kerberos security protocol enables the use of a
single sign-on to a remote DB2 database server.
First, let's review the setup of DB2 to use Kerberos authentication. As mentioned
above, Kerberos authentication is implemented in DB2 using the plugin architecture.
The source code for the default kerberos plugin is provided in the samples/security/
plugins directory, called IBMkrb5.c. Before the Kerberos authentication will work for
DB2, Kerberos has to be enabled and supported on both client and server. In order
for this to work, the following conditions must be met:
1. The client and server machines must belong to the same realm (trusted
domains in Windows terminology
2. The appropriate Principals (user IDs in Kerberos) must be set up.
3. The server's keytab file must be created and readable by the instance owner.
4. All machines must have synchronized clocks.
You can find more information on setting up Kerberos in the documentation
accompanying the Kerberos product installed.
To enable DB2 to use KERBEROS authentication you must first tell the client where
to find the kerberos plugin you are using. On the client, run the following command:
DB2 UPDATE DBM CFG USING CLNT_KRB_PLUGIN IBMkrb5
DB2 TERMINATE
Page 10 of 32
ibm.com/developerWorks/
developerWorks
In this example, the default KERBEROS plugin is used. This could have been
modified by the DBA to perform special functions if they were required by the
Kerberos implementation being used.
There is also the ability to tell the client exactly which server principal it is
authenticating against. This option bypasses the first step of Kerberos authentication
where the client has to discover the server principal of the instance it is connecting to.
The AUTHENTICATION parameter can be specified when cataloging the database
on the client. Its format is:
DB2 CATALOG DB dbname AT NODE node name AUTHENTICATION KERBEROS TARGET PRINCIPAL
service/host@REALM
The next step to set up Kerberos authentication is to set up the server. The
srvcon_gssplugin_list. This parameter can be set up with a list of different
supported GSS-API plugins, but you are only allowed one Kerberos plugin. If no
Kerberos plugin is in the list, the default IBMkrb5 plugin is automatically used. If
you intend to allow all authentication (instance attachments as well as database
connections) to use Kerberos, then perform the following:
DB2 UPDATE DBM CFG USING AUTHENTICATION KERBEROS
or
DB2 UPDATE DBM CFG USING AUTHENTICATION KRB_SERVER_ENCRYPT
If you only want DB2 to use Kerberos to authenticate incoming database connections
(and use SERVER for incoming instance attachments), then perform the following:
DB2 UPDATE DBM CFG USING SVRCON_AUTH KERBEROS
or
DB2 UPDATE DBM CFG USING SVRCON_AUTH KRB_SERVER_ENCRYPT
Depending on the bit width (32 or 64 bit) of the instance, DB2 will automatically load
the IBMkrb5 plugin when the instance is started.
Page 11 of 32
developerWorks
ibm.com/developerWorks/
=
=
=
= UNFENCED
=
=
= NO
= NO
In the above list, the parameters already discussed have been removed.
Table 3. Other parameters
CLNT_PW_PLUGIN
GROUP_PLUGIN
LOCAL_GSSPLUGIN
SRV_PLUGIN_MODE
SRVCON_GSSPLUGIN_LIST
SRVCON_PW_PLUGIN
CATALOG_NOAUTH
Page 12 of 32
ibm.com/developerWorks/
developerWorks
Page 13 of 32
developerWorks
ibm.com/developerWorks/
issue any DB2 commands against that instance, any databases within the instance,
and any objects within those databases. They also have the ability to access data
within the databases and grant or revoke privileges and authorities. SYSADM users
are the only users allowed to update the DBM CFG file.
SYSADM authority is controlled in the DBM CFG file via the SYSADM_GROUP
parameter. When the instance is created, this parameter is set to Administrator on
Windows (although it appears blank if you issue the command db2 get dbm cfg ). On
UNIX, it is set to the primary group of the user who created the instance.
Since SYSADM users are the only users allowed to update the DBM CFG, they are
also the only ones allowed to grant any of the SYS* authorities to other groups. The
following example illustrates how to grant SYSADM authority to the group db2grp1:
db2 update dbm cfg using SYSADM_GROUP db2grp1
Remember, this change will not take effect until the instance is stopped and then
restarted. Also, keep in mind that if you are not currently logged in as a member of
db2grp1, you may not have authority to restart the instance! You would have to log
out and log back in with an ID in the correct group, or add your current ID to db2grp1.
db2start/db2stop
db2 create/drop database
db2 create/drop tablespace
db2 backup/restore/rollforward database
db2 runstats (against any table)
db2 update db cfg for database dbname
A user with SYSADM authority can assign SYSCTRL to a group using the following
command:
db2 update dbm cfg using SYSCTRL_GROUP group name
Page 14 of 32
ibm.com/developerWorks/
developerWorks
db2start/db2stop
db2 backup/restore/rollforward database
db2 runstats (against any table)
db2 update db cfg for database dbname
Notice that users with SYSMAINT cannot create or drop databases or tablespaces.
They also cannot access any data within the databases unless they are granted the
explicit privileges required to do so.
If you have SYSADM authority, you can assign SYSMAINT authority to a group using
the following command:
db2 update dbm cfg using SYSMAINT_GROUP group name
output buffer
SYSMON authority enables the user to use all snapshot SQL table functions without
previously running SYSPROC.SNAP_WRITE_FILE. SYSPROC.SNAP_WRITE_FILE takes a
snapshot and saves its content into a file. If any snapshot table functions are called
with null input parameters, the file content is returned, instead of a real-time system
snapshot.
Users with the SYSADM, SYSCTRL, or SYSMAINT authority level also possess
SYSMON authority.
DB2 9 Fundamentals exam 730 prep, Part 2: Security
Page 15 of 32
developerWorks
ibm.com/developerWorks/
A user with SYSADM authority can assign SYSMON to a group using the following
command:
db2 update dbm cfg using SYSMON_GROUP group name
drop database
drop/create tablespace
backup/restore database
update db cfg for database db name
Page 16 of 32
ibm.com/developerWorks/
developerWorks
db2
db2
db2
db2
db2
table)
db2 load replace (must have insert and delete privilege on table)
db2 load restart/terminate after load replace (must have insert and delete
privilege on table)
Only users with either SYSADM or DBADM authority are permitted to grant or revoke
LOAD authority to users or groups. The following examples illustrate how LOAD
authority can allow our user to LOAD data into a table called sales. Assume that the
command db2 connect to sample has already been issued.
db2 grant load on database to user tst1
db2 grant insert on table sales to user tst1
With LOAD authority and insert privilege, tst1 could issue a LOAD INSERT or a
LOAD RESTART, or TERMINATE after a LOAD INSERT against the sales table.
With LOAD authority, as well as delete and insert privileges, any member of
grp1 could issue a LOAD REPLACE or a LOAD RESTART, or TERMINATE after a LOAD
REPLACE against the sales table.
No other user can perform these functions, not even the SYSADM, unless SECADM
was explicitly granted to that SYSADM user. This is important because these security
abilities are very powerful and should only be granted to a user who is defined as
a security administrator. See the "Label-based access control" section for more
information on this security feature new to DB2 V9.
DB2 9 Fundamentals exam 730 prep, Part 2: Security
Page 17 of 32
developerWorks
ibm.com/developerWorks/
Relevant objects
Description
CONTROL
DELETE
Table, View
INSERT
Table, View
SELECT
Table, View
UPDATE
Table, View
ALTER
Table
Page 18 of 32
ibm.com/developerWorks/
developerWorks
INDEX
Table
REFERENCES
Table
BIND
Package
EXECUTE
ALTERIN
Schema
CREATEIN
Schema
DROPIN
Schema
Information on object-level privileges is stored in the system catalog views. The view
names are syscat.tabauth, syscat.colauth, syscat.indexauth, syscat.schemaauth,
syscat.routineauth, and syscat.packageauth.
Explicit privileges
Privileges can be explicitly granted and revoked to users or groups using the GRANT
and REVOKE commands. Let's take a look at how you can use these commands on
various objects.
While logged in as a user with Administrator authority on Windows, bring up two DB2
command windows. Make sure that the db2instance variable is set to DB2 in both
windows!
From Window 1, issue the following command:
db2 connect to sample
Remember, the commands in Window 1 are being issued by a user with SYSADM
authority. The commands in Window 2 are being issued by tst1, a user with no
specific authority or privileges on the sample database. Note that the schema name
associated with the tables in your sample database will be the name of the user that
issued the db2sampl command. In these examples, that user is GMILNE.
Now, from Window 2, issue the following command:
db2 select * from gmilne.org
Page 19 of 32
developerWorks
ibm.com/developerWorks/
SQL0551N "TEST1" does not have the privilege to perform operation "SELECT"
on object "GMILNE.ORG".
Now the earlier command will succeed! Next, let's issue a more ambitious command
from Window 2:
db2 insert into gmilne.org values (100, 'Tutorial', 1, 'Eastern', 'Toronto')
"INSERT"
The earlier failed INSERT command should now complete successfully, because
test1 is a member of group db2grp1.
Now, enter the following command in Window 2:
db2 drop table gmilne.emp_photo
So, we'll have the grant that privilege. Enter the following from Window 1:
db2 grant dropin on schema gmilne to all
Note that revoking privileges from a group does not necessarily revoke it from all
members of that group. For example, the following command could have been used
to revoke all privileges (except CONTROL) from db2grp1 on the table gmilne.org:
DB2 9 Fundamentals exam 730 prep, Part 2: Security
Page 20 of 32
ibm.com/developerWorks/
developerWorks
However, the user test1 (who is a member of db2grp1 ) would have kept the select
privileges on that table, since he or she had been granted that privilege directly.
Implicit privileges
DB2 may grant privileges automatically when certain commands are issued, without
the need for an explicit GRANT statement to be issued, as you saw previously. The
table below summarizes some commands that result in privileges being implicitly
granted by the database manager. Note that these privileges are implicitly revoked
when the object created is dropped. They are not, however, revoked when higherlevel privileges are explicitly revoked.
Table 5. Resulting commands from privileges being implicitly granted by the
database manager
Command issued
Privilege granted
CONTROL on mytable
PUBLIC**
*When a user creates a database, that user is implicitly granted DBADM authority
on that database. With DBADM authority comes implicit CONNECT, CREATETAB,
BINDADD, IMPLICIT_SCHEMA, and CREATE_NOT_FENCED privileges. These
privileges will remain with the user even if the DBADM authority is revoked.
**PUBLIC is a special DB2 group that includes all users of a particular database.
Unlike the other groups we've discussed thus far, PUBLIC does not have to be
defined at the operating system level. There are some privileges granted to PUBLIC
by default. For example, this group receives CONNECT privilege on the database
and SELECT privilege on the catalog tables automatically. GRANT and REVOKE
commands can be issued against the PUBLIC group, like so:
db2 grant select on table sysibm.systables to public
db2 revoke select on table sysibm.systables from public
Indirect privileges
Privileges can be obtained indirectly when packages are executed by the database
manager. A package contains one or more SQL statements that have been
converted into a format that DB2 uses internally to execute them. In other words,
DB2 9 Fundamentals exam 730 prep, Part 2: Security
Page 21 of 32
developerWorks
ibm.com/developerWorks/
Organizational role
Jane
Joe
Frank
Page 22 of 32
ibm.com/developerWorks/
developerWorks
SQLDA Information
sqldaid : SQLDA
sqldabc: 896
sqln: 20
sqld: 14
Column Information
sqltype
-------------------452
CHARACTER
448
VARCHAR
453
CHARACTER
448
VARCHAR
453
CHARACTER
453
CHARACTER
385
DATE
453
CHARACTER
500
SMALLINT
453
CHARACTER
385
DATE
485
DECIMAL
485
DECIMAL
485
DECIMAL
sqllen
-----6
12
1
15
3
4
10
8
2
1
10
9, 2
9, 2
9, 2
sqlname.data
-----------------------------EMPNO
FIRSTNME
MIDINIT
LASTNAME
WORKDEPT
PHONENO
HIREDATE
JOB
EDLEVEL
SEX
BIRTHDATE
SALARY
BONUS
COMM
sqlname.length
-------------5
8
7
8
8
7
8
3
7
3
9
6
5
4
The organization has rules in place that are audited on a regular basis. Part of this
audit indicates that the employees should not have access to data that is considered
confidential. The rules stipulate that executives have full read / write access to all
employee records, Managers have read / write access to anyone in their department,
and team leads have read access to anyone in the department they lead.
To set up LBAC security to enable these rules:
1. Define the security policies and labels, and grant the security labels to the
users.
2. Modify the EMP table, including the security label column, and attach the
security policy to it.
Defining the security policies and labels
To define the security policies and labels, SECADM authority is required.
Step 1a. Create the security label component
The first thing you need to do is to determine the best type of security component
to define for this policy. In this particular case, the best fit is a policy type of "TREE".
A Tree policy means that you can define a set of labels such that the children have
a subset of the rights that their parent does. In this example, create a security
component named "J_DEPT".
Page 23 of 32
developerWorks
ibm.com/developerWorks/
The above layout indicates that the root is HR_EXECUTIVE, and all the departments
are children under that executive.
Step 1b. Define the security policy
The next step required to use LBAC security in the above example is to define the
policy associated with the security label component above. A security policy can use
more than one component.
CREATE SECURITY POLICY J_DEPT_POLICY
COMPONENTS J_DEPT
WITH DB2LBACRULES
RESTRICT NOT AUTHORIZED WRITE SECURITY LABEL
Page 24 of 32
ibm.com/developerWorks/
developerWorks
In the next step you'll define the actual permissions associated with these labels.
Step 1d. Grant rights based on labels
The following steps outline the procedures for granting the rights to the table data.
Rights are either ALL ACCESS, WRITE ACCESS, or READ ACCESS. If none of
these rights are granted to a user, then that user doesn't have the capability to
access any of the table data. Remember that executives have full access, managers
have full access to their departments, and team leads have read access to members
of the departments they lead.
db2 grant security label J_DEPT_POLICY.A00 to user Frank for read access
db2 grant security label J_DEPT_POLICY.MANAGE_D11_E21 to user Joe for all access
db2 grant security label J_DEPT_POLICY.EXECUTIVE to user Jane for all access
Setting the above labels on the users will cascade rights based on the tree
definitions in step 1a. Because user Joe is labeled as MANAGE_D11_E21, and is
given all rights, he will be able to read and write rows that have a security tag of
J_DEPT_POLICY.D11 or J_DEPT_POLICY.E21 (since they are his children).
Step 2: Modify the EMP table
When modifying the EMP table, you must create an extra column to store the security
label. This is of type "DB2SECURITYLABEL". You are going to modify the existing
EMP table in the SAMPLE database. To do this, you must user a user that has been
granted root level privilege in the policy, so in this case the user Jane. You must also
first drop the MQT table ADEFUSR from the sample database.
CONNECT TO SAMPLE
Database Connection Information
Database server
SQL authorization ID
Local database alias
= DB2/NT 9.1.0
= GMILNE
= SAMPLE
If you select from the EMP table, you will see the additional column defined. Because
you performed the changes with a user defined on the EXECUTIVE level, all the
DB2 9 Fundamentals exam 730 prep, Part 2: Security
Page 25 of 32
developerWorks
ibm.com/developerWorks/
security tags will have been added as EXECUTIVE. To change this, you need to
update the table.
db2 => select EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SALARY,
varchar(SECLABEL_TO_CHAR('J_DEPT_POLICY',DEPT_TAG),30) from gmilne.emp
EMPNO
-----000010
000020
000030
000050
000060
000070
000090
000100
000110
000120
000130
000140
000150
000160
000170
000180
000190
000200
000210
000220
000230
000240
000250
000260
000270
000280
000290
000300
000310
000320
000330
000340
200010
200120
200140
200170
200220
200240
200280
200310
200330
200340
FIRSTNME
-----------CHRISTINE
MICHAEL
SALLY
JOHN
IRVING
EVA
EILEEN
THEODORE
VINCENZO
SEAN
DELORES
HEATHER
BRUCE
ELIZABETH
MASATOSHI
MARILYN
JAMES
DAVID
WILLIAM
JENNIFER
JAMES
SALVATORE
DANIEL
SYBIL
MARIA
ETHEL
JOHN
PHILIP
MAUDE
RAMLAL
WING
JASON
DIAN
GREG
KIM
KIYOSHI
REBA
ROBERT
EILEEN
MICHELLE
HELENA
ROY
LASTNAME
--------------HAAS
THOMPSON
KWAN
GEYER
STERN
PULASKI
HENDERSON
SPENSER
LUCCHESSI
O'CONNELL
QUINTANA
NICHOLLS
ADAMSON
PIANKA
YOSHIMURA
SCOUTTEN
WALKER
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
HEMMINGER
ORLANDO
NATZ
YAMAMOTO
JOHN
MONTEVERDE
SCHWARTZ
SPRINGER
WONG
ALONZO
WORKDEPT SALARY
-------- ----------A00
152750.00
B01
94250.00
C01
98250.00
E01
80175.00
D11
72250.00
D21
96170.00
E11
89750.00
E21
86150.00
A00
66500.00
A00
49250.00
C01
73800.00
C01
68420.00
D11
55280.00
D11
62250.00
D11
44680.00
D11
51340.00
D11
50450.00
D11
57740.00
D11
68270.00
D11
49840.00
D21
42180.00
D21
48760.00
D21
49180.00
D21
47250.00
D21
37380.00
E11
36250.00
E11
35340.00
E11
37750.00
E11
35900.00
E21
39950.00
E21
45370.00
E21
43840.00
A00
46500.00
A00
39250.00
C01
68420.00
D11
64680.00
D11
69840.00
D21
37760.00
E11
46250.00
E11
35900.00
E21
35370.00
E21
31840.00
6
-----------------------------HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
HR_EXECUTIVE
42 record(s) selected.
Page 26 of 32
ibm.com/developerWorks/
developerWorks
FIRSTNME
-----------CHRISTINE
MICHAEL
SALLY
JOHN
IRVING
EVA
EILEEN
THEODORE
VINCENZO
SEAN
DELORES
HEATHER
BRUCE
ELIZABETH
MASATOSHI
MARILYN
JAMES
DAVID
WILLIAM
JENNIFER
JAMES
SALVATORE
DANIEL
SYBIL
MARIA
ETHEL
JOHN
PHILIP
MAUDE
RAMLAL
WING
JASON
DIAN
GREG
KIM
KIYOSHI
REBA
ROBERT
EILEEN
MICHELLE
HELENA
ROY
LASTNAME
--------------HAAS
THOMPSON
KWAN
GEYER
STERN
PULASKI
HENDERSON
SPENSER
LUCCHESSI
O'CONNELL
QUINTANA
NICHOLLS
ADAMSON
PIANKA
YOSHIMURA
SCOUTTEN
WALKER
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
HEMMINGER
ORLANDO
NATZ
YAMAMOTO
JOHN
MONTEVERDE
SCHWARTZ
SPRINGER
WONG
ALONZO
WORKDEPT SALARY
-------- ----------A00
152750.00
B01
94250.00
C01
98250.00
E01
80175.00
D11
72250.00
D21
96170.00
E11
89750.00
E21
86150.00
A00
66500.00
A00
49250.00
C01
73800.00
C01
68420.00
D11
55280.00
D11
62250.00
D11
44680.00
D11
51340.00
D11
50450.00
D11
57740.00
D11
68270.00
D11
49840.00
D21
42180.00
D21
48760.00
D21
49180.00
D21
47250.00
D21
37380.00
E11
36250.00
E11
35340.00
E11
37750.00
E11
35900.00
E21
39950.00
E21
45370.00
E21
43840.00
A00
46500.00
A00
39250.00
C01
68420.00
D11
64680.00
D11
69840.00
D21
37760.00
E11
46250.00
E11
35900.00
E21
35370.00
E21
31840.00
6
-----------------------------A00
B01
C01
E01
D11
D21
E11
E21
A00
A00
C01
C01
D11
D11
D11
D11
D11
D11
D11
D11
D21
D21
D21
D21
D21
E11
E11
E11
E11
E21
E21
E21
A00
A00
C01
D11
D11
D21
E11
E11
E21
E21
42 record(s) selected.
After the update, let's see what the individual users can do. You'll connect to the
database using the Executive user ID Jane. Start with the same select statement
performed before:
db2 => select EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SALARY,
varchar(SECLABEL_TO_CHAR('J_DEPT_POLICY',DEPT_TAG),30) from gmilne.emp
EMPNO
FIRSTNME
LASTNAME
WORKDEPT SALARY
Page 27 of 32
developerWorks
-----000010
000020
000030
000050
000060
000070
000090
000100
000110
000120
000130
000140
000150
000160
000170
000180
000190
000200
000210
000220
000230
000240
000250
000260
000270
000280
000290
000300
000310
000320
000330
000340
200010
200120
200140
200170
200220
200240
200280
200310
200330
200340
-----------CHRISTINE
MICHAEL
SALLY
JOHN
IRVING
EVA
EILEEN
THEODORE
VINCENZO
SEAN
DELORES
HEATHER
BRUCE
ELIZABETH
MASATOSHI
MARILYN
JAMES
DAVID
WILLIAM
JENNIFER
JAMES
SALVATORE
DANIEL
SYBIL
MARIA
ETHEL
JOHN
PHILIP
MAUDE
RAMLAL
WING
JASON
DIAN
GREG
KIM
KIYOSHI
REBA
ROBERT
EILEEN
MICHELLE
HELENA
ROY
ibm.com/developerWorks/
--------------HAAS
THOMPSON
KWAN
GEYER
STERN
PULASKI
HENDERSON
SPENSER
LUCCHESSI
O'CONNELL
QUINTANA
NICHOLLS
ADAMSON
PIANKA
YOSHIMURA
SCOUTTEN
WALKER
BROWN
JONES
LUTZ
JEFFERSON
MARINO
SMITH
JOHNSON
PEREZ
SCHNEIDER
PARKER
SMITH
SETRIGHT
MEHTA
LEE
GOUNOT
HEMMINGER
ORLANDO
NATZ
YAMAMOTO
JOHN
MONTEVERDE
SCHWARTZ
SPRINGER
WONG
ALONZO
42 record(s) selected.
As you can see, Jane has full access to all the data in the table. Now let's look at
what Joe can see. First, look at the select command again.
db2 => select EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SALARY,
varchar(SECLABEL_TO_CHAR('J_DEPT_POLICY',DEPT_TAG),30) from gmilne.emp
EMPNO
-----000060
000100
000150
000160
000170
FIRSTNME
-----------IRVING
THEODORE
BRUCE
ELIZABETH
MASATOSHI
LASTNAME
--------------STERN
SPENSER
ADAMSON
PIANKA
YOSHIMURA
WORKDEPT SALARY
-------- ----------D11
72250.00
E21
86150.00
D11
55280.00
D11
62250.00
D11
44680.00
6
-----------------------------D11
E21
D11
D11
D11
Page 28 of 32
ibm.com/developerWorks/
000180
000190
000200
000210
000220
000320
000330
000340
200170
200220
200330
200340
MARILYN
JAMES
DAVID
WILLIAM
JENNIFER
RAMLAL
WING
JASON
KIYOSHI
REBA
HELENA
ROY
SCOUTTEN
WALKER
BROWN
JONES
LUTZ
MEHTA
LEE
GOUNOT
YAMAMOTO
JOHN
WONG
ALONZO
developerWorks
D11
D11
D11
D11
D11
E21
E21
E21
D11
D11
E21
E21
51340.00
50450.00
57740.00
68270.00
49840.00
39950.00
45370.00
43840.00
64680.00
69840.00
35370.00
31840.00
D11
D11
D11
D11
D11
E21
E21
E21
D11
D11
E21
E21
17 record(s) selected.
See how he can only see information from departments D11 and E21? Let's see what
happens when he tries to select data that is in the table, but he is not allowed to see:
db2 => select EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SALARY,
varchar(SECLABEL_TO_CHAR('J_DEPT_POLICY',DEPT_TAG),30)
from gmilne.emp where empno='000130'
EMPNO FIRSTNME
LASTNAME
WORKDEPT SALARY
6
------ ------------ --------------- -------- ----------- -----------------------------0 record(s) selected.
You know from the previous select with Jane that there is an employee in there with
empno 000130, but Joe is not allowed to see it.
Now, one last test, with Frank.
First, the same select the other two users have run:
db2 => select EMPNO, FIRSTNME, LASTNAME, WORKDEPT, SALARY,
varchar(SECLABEL_TO_CHAR('J_DEPT_POLICY',DEPT_TAG),30) from gmilne.emp
EMPNO
-----000010
000110
000120
200010
200120
FIRSTNME
-----------CHRISTINE
VINCENZO
SEAN
DIAN
GREG
LASTNAME
--------------HAAS
LUCCHESSI
O'CONNELL
HEMMINGER
ORLANDO
WORKDEPT SALARY
-------- ----------A00
152750.00
A00
66500.00
A00
49250.00
A00
46500.00
A00
39250.00
6
-----------------------------A00
A00
A00
A00
A00
5 record(s) selected.
In this case you can see that Frank can only see information about users from the
department he leads. Let's see what happens when he tries to update:
db2 => update gmilne.emp set DEPT_TAG=(SECLABEL_BY_NAME('J_DEPT_POLICY','A00'))
where WORKDEPT='A00'DB21034E The command was processed as an SQL statement
because it was not a valid Command Line Processor command. During SQL processing it
returned:
SQL20402N Authorization ID "FRANK" does not have the LBAC credentials to
perform the "UPDATE" operation on table "EMPLOYEE". SQLSTATE=42519
Page 29 of 32
developerWorks
ibm.com/developerWorks/
Even though he is trying to update a record that is in his own department, you
created his access security to only allow read access to the table. Our business
requirements have been satisfied.
Section 6. Summary
Now that you've completed this tutorial, you should have a fundamental
understanding of the following topics:
Elements of a DB2 security plan: You should understand the structure of the entire
DB2 environment, which includes client, servers, gateways, and hosts. You should
also understand authentication, authorization, and privileges.
DB2 authentication types: You should know how to set authentication types using
the db2 update dbm cfg using authentication type command on the server, and
using the db2 catalog database command on the gateway and client.
DB2 authorities: You should understand the basics of the SYSADM, SYSCTRL,
SYSMAINT, and SYSMON authorities, which are set in the DBM CFG file. You
should also understand the basics of the DBADM, LOAD, and SECADM authorities,
which are set using the GRANT command and revoked using the REVOKE command.
Additionally, you should know what command each authority is allowed to run.
DB2 privileges: You should have an understanding of the different types of privileges
and what they allow a user to do. Examples are CONTROL, INSERT, DELETE,
CREATEIN, DROPIN, REFERENCES, and SELECT. You should also know how a
privilege is obtained/revoked explicitly (GRANT/REVOKE commands), implicitly, or (for
packages only) indirectly. In addition to this you should have a basic understanding of
label-based access control, and how to define different types of policies based on this
new security concept.
To access other tutorials in this series, bookmark the series page, DB2 9 DBA exam
731 prep tutorials.
Page 30 of 32
ibm.com/developerWorks/
developerWorks
Resources
DB2 9 is available as a free download.
DB2 Express-C. Download a no-charge version of DB2 Express Edition for the
community that offers the same core data features as DB2 Express Edition and
provides a solid base to build and deploy applications.
Check out the other parts of the DB2 9 Fundamentals exam 730 prep tutorial
series.
Certification exam site. Click the exam number to see more information about
Exams 730 and 731.
DB2 9 overview. Find information about the new data server that includes
patented pureXML technology.
The DB2 9 Information Center. Learn more about DB2 security.
DB2 Label-Based Access Control, a practical guide, Part 1: Understand the
basics of LBAC in DB2 (developerWorks) provides more information on labelbased access control.
DB2 UDB Security Part 2: Understand the DB2 Universal Database Security
plug-ins (developerWorks, December 2005) outlines DB2's implementation
of external security plug-ins, and how to implement them in your DB2
environment.
Page 31 of 32
developerWorks
ibm.com/developerWorks/
Page 32 of 32