Question: I read that V4R2 supports column-level security in database files. Could you please explain column-level security and how it may apply to existing applications?
Answer: Column-level security, which was added in V4R2, allows you to control who can update and reference fields (columns) in a database file. The words update and reference sound like the capability to modify and read selected columns. The term update does mean the capability to update a column, but, unfortunately, reference authority is not control of read authority. Object reference authority simply provides authority to specify the field as part of the parent key in a referential constraint. (Referential constraints are conditions that the database will enforce between files: for example, that an employee master record must exist before you can have an associated skill file record for that master file record.)
While column-level security is a step in the right direction toward meeting the needs of applications, without read authority at the column level, IBM has missed an important function that most AS/400 installations want: a way to control what users can read in the contents of a field (column). Because read-level security is not implemented, the new column-level security functions will have limited application for most AS/400 installations.
The specification of column-level security is done using the SQL statements GRANT and REVOKE. There is no CL command equivalent for column-level security. An example of a column-level security specification is shown in Figure 1. First, the CREATE TABLE statement creates the table (physical file) with four fields (NAME, ADDRESS, CITY, and SALARY). You could use DDS to create the file and then use SQL statements to secure the file. The second and third SQL statements are GRANT statements that specify that users WOELMT and QUSER are authorized to update the
NAME, ADDRESS, and CITY fields. Since the SALARY field is omitted, they are not authorized to modify the SALARY field. User WOELMT is granted authority to use the NAME field in a referential integrity statement only.
To display the column-level authority information, use the Display Object Authority (DSPOBJAUT) command:
DSPOBJAUT +
OBJ(EVANS/FILE0) +
OBJTYPE(*FILE)
The display in Figure 2 shows the object-level authorities granted by the SQL statements in Figure 1. Note the additional command key F16 to display the field (column) authorities. Also note that, when you create a table using SQL CREATE TABLE statements, the public authority to the table is *EXCLUDE. The GRANT SELECT authority gives the users read access to the table. The GRANT REFERENCES gives user WOELMT the *OBJREF authority shown at the R column.
When F16 is pressed, the display in Figure 3 shows the authority to individual fields in the file. Reviewing the SALARY field, we see that users WOELMT and QUSER are not allowed to update the field. INSERT authority was granted for the file, allowing user WOELMT to add a new record, including the salary field; however, the user profile is prevented from modifying any existing fields.
Object security information is stored in user profiles. When you back up user profiles with the Save System (SAVSYS) or Save Security Data (SAVSECDTA) command, the user profiles and all object security information are saved. For column (field) security, the information is stored not in the user profile but with the database file. Saving user profiles does not save the column security information. This information is saved when the file is saved.
I saved FILE0 and restored the file to a different library named WOETEMP. Then, I repeated the display of object authority for the restored file. In Figure 4, notice that only the owner’s authority is restored: The users WOELMT and QUSER do not have any authority for the restored file. However, when you press F16, you see in Figure 5 that the field-level authorities were saved and then restored when the file was restored. This is further verification that the field (column) authorities are stored with the file and not the user profile.
The field-level authority is enforced when the user attempts to update a record. When a user violates a field-level authority check, the subsequent error messages do an excellent job of describing the problem. For example, when signed on as user QUSER, I used the DFU (Data File Utility) to update the FILE0. DFU could change the fields NAME, CITY, and ADDRESS since the user QUSER had update (*UPD) authority on these fields. However, when QUSER attempted to modify the salary field, the messages shown in Figure 6 were issued.
The errors are reported in the generic range (CPF51xx-CPF53xx) for I/O errors, so existing applications that monitor for I/O errors will be notified of field (column) security violations, and standard error recovery procedures will be invoked.
A word of caution about field (column) security: Once you start maintaining the authority for a file using SQL statements, you must continue using SQL. I discovered that when I used the Edit Object Authority (EDTOBJAUT) command to change the object access for user WOELMT, and all of the field level authorities for WOELMT were lost. Compare column authority in Figure 5 to the column authority after EDTOBJAUT in Figure 7, and you can see the column authority for user WOELMT has been removed.
There is no CL command interface to specify field (column) security, but the Operations Navigator can be used to specify column security. Figure 8 shows the
Operations Navigator display of the permissions (authorities) for the file FILE0. Figure 9 shows the detailed permissions (authorities) for file FILE0. Selecting the option for column (field) authorities displays multiple screens reflecting the users authorized to the different fields in the FILE0. The Operations Navigator shows column authorities for the file owner even though there was no SQL GRANT statement for user profile WOEVANS. Using the Operations Navigator to specify column security is easy when compared to using the SQL statements. Using a graphical interface is superior to using SQL statements.
Enter SQL Statements
Type SQL statement, press Enter.
> CREATE TABLE MYLIB/FILE0 (NAME CHAR (30) NOT NULL WITH DEFAULT,
ADDRESS CHAR (20) NOT NULL WITH DEFAULT, CITYST CHAR (15) NOT NULL
WITH DEFAULT, SALARY DEC (10, 2) NOT NULL WITH DEFAULT)
Table FILE0 created in MYLIB.
> GRANT INSERT, SELECT, REFERENCES(NAME), UPDATE(NAME, ADDRESS,
CITYST) ON MYLIB/FILE0 TO WOELMT
GRANT of authority to FILE0 in MYLIB completed.
> GRANT INSERT, SELECT, UPDATE(NAME, ADDRESS, CITYST) ON MYLIB/FILE0
TO QUSER
GRANT of authority to FILE0 in MYLIB completed.
===>
Bottom
F3= Exit F4=Prompt F6=Insert line F9=Retrieve F10=Copy line
F12=Cancel F13=Services F24=More keys Display Object Authority
Object . . . . . . . : FILE0 Owner . . . . . . . : WOEVANS
Library . . . . . : MYLIB Primary group . . . : *NONE
Object type . . . . : *FILE
Object secured by authorization list . . . . . . . . . . . . : *NONE
Object -----Object------ ------Data-
User Group Authority O M E A R R A U D E
WOEVANS * ALL X X X X X X X X X X
QUSER USER DEF X X X X
WOELMT USER DEF X X X X X
*PUBLIC *EXCLUDE
Bottom
Press Enter to continue.
F3= Exit F12=Cancel F16=Display field authorities F17=Top F18=Bottom Display Field Authority
Object . . . . . . . : FILE0 Owner . . . . . . . : WOEVANS
Library . . . . . : MYLIB Primary group . . . : *NONE
Object type . . . . : *FILE
Figure 1: SQL commands for column-level security
Figure 2: Display of object authority
Object -----------Field Authorities-
Field User Authority Mgt Alter Ref Read Add Update
NAME WOELMT USER DEF X X X X
QUSER USER DEF X X X
ADDRESS WOELMT USER DEF X X X
QUSER USER DEF X X X
CITYST WOELMT USER DEF X X X
QUSER USER DEF X X X
SALARY WOELMT USER DEF X X
QUSER USER DEF X X
Bottom
Press Enter to continue.
F3= Exit F12=Cancel F16=Display field authorities F17=Top F18=Bottom Display Object Authority
Object . . . . . . . : FILE0 Owner . . . . . . . : WOEVANS
Library . . . . . : MYLIB Primary group . . . : *NONE
Object type . . . . : *FILE
Object secured by authorization list . . . . . . . . . . . . : *NONE
Object -----Object------ ------Data-
User Group Authority O M E A R R A U D E
WOEVANS * ALL X X X X X X X X X X
*PUBLIC *EXCLUDE
Bottom
Press Enter to continue.
F3= Exit F12=Cancel F16=Display field authorities F17=Top F18=Bottom Display Field Authority
Object . . . . . . . : FILE0 Owner . . . . . . . : WOEVANS
Library . . . . . : MYLIB Primary group . . . : *NONE
Object type . . . . : *FILE
Object -------Field Authorities-
Field User Authority Mgt Alter Ref Read Add Update
NAME WOELMT *NONE X X X X
QUSER * NONE X X X
ADDRESS WOELMT *NONE X X X
QUSER * NONE X X X
CITYST WOELMT *NONE X X X
QUSER * NONE X X X
SALARY WOELMT *NONE X X
QUSER * NONE X X
Bottom
Press Enter to continue.
F3= Exit F12=Cancel F16=Display field authorities F17=Top F18=Bottom Display All Messages
System: MCRISC
Job . . : QPADEV0001 User . . : WOELMT Number . . . : 121443
3> chgdta file0_dfu
Not authorized to field SALARY of file FILE0.
Figure 3: Display of field authorities
Figure 4: Authority of restored file
Figure 5: Field authorities of restored file
Not authorized to process request on member FILE0.
You are not authorized to perform the requested operation.
All records added, changed, or deleted will be printed.
Bottom
Press Enter to continue.
F3= Exit F5=Refresh F12=Cancel F17=Top F18=Bottom Display Field Authority
Object . . . . . . . : FILE0 Owner . . . . . . . : WOEVANS
Library . . . . . : MYLIB Primary group . . . : *NONE
Object type . . . . : *FILE
Object -----------Field Authorities-
Field User Authority Mgt Alter Ref Read Add Update
NAME QUSER *NONE X X X
ADDRESS QUSER *NONE X X X
CITYST QUSER *NONE X X X
SALARY QUSER *NONE X X
Bottom
Press Enter to continue.
F3= Exit F12=Cancel F16=Display field authorities F17=Top F18=Bottom
LATEST COMMENTS
MC Press Online