Question & Answer
Question
How do you get a listing of authorities for all objects in a library.
Answer
With the introduction of the IBM i SQL Service OBJECT_PRIVILEGES, you can create an SQL report containing the authorities for all objects in a library.
The information returned is similar to the information available through the Display Object Authority (DSPOBJAUT) CL command
Authorization: All authorized users are returned for an object when at least one of the following is true:
- The caller has *OBJMGT authority.
- The caller is the owner of the object.
- The object is an authorization list.
- The caller is authorized to the Database Security Administrator function of IBM i. The Change Function Usage (CHGFCNUSG) command, with a function ID of QIBM_DB_SECADM, can be used to change the list of users allowed to use the function.
Otherwise, only authorizations for the caller are returned.
To get a listing of authorities for all objects in QGPL, follow the steps:
1) STRSQL to start SQL(The ACS Run SQL Scripts can also be used)
2) Run the following SQL:
SELECT *
FROM QSYS2.OBJECT_PRIVILEGES
WHERE SYSTEM_OBJECT_SCHEMA = 'QGPL'

The SQL lists the Authorities for all objects in library QGPL:

In addition, you could use the SQL Create Table function to create a file with all of the authorities for the library:
1) STRSQL to start SQL(The ACS Run SQL Scripts can also be used)
2) Run the following SQL:
CREATE TABLE QGPL/AUTQGPL AS
(SELECT *
FROM QSYS2.OBJECT_PRIVILEGES
WHERE SYSTEM_OBJECT_SCHEMA = 'QGPL')
WITH DATA

The SQL statement creates a file called AUTGPL in library QGPL.
More information on the IBM i SQL Service can be found on the following link:
Listing the Authorities of All Objects in an IFS Directory refer to the following link:
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]
Was this topic helpful?
Document Information
Modified date:
11 November 2020
UID
ibm16206867