IBM i message

CPF2182: Not authorized to library

CPF2182 means the user profile running the command doesn't have the authority it needs to the library named. It comes from library and object commands such as ADDLIBLE, CHGLIBL, CRTDUPOBJ and RNMOBJ.

Other names for this code

Also written as CPF2182 not authorized to library, MSGID CPF2182, ADDLIBLE CPF2182, CHGLIBL CPF2182, MONMSG CPF2182.

What it means

CPF2182 is an escape message from QCPFMSG with the text "Not authorized to library &1". It is the library and object command version of CPF9820. A library on IBM i is an object of type *LIB, with its own owner, *PUBLIC authority, private authorities and perhaps an authorization list.

Each command needs a certain level of authority to the library. ADDLIBLE and CHGLIBL need *USE, and CHGLIBL needs it for every library in the new list. If even one is missing, CHGLIBL leaves the list as it was. CRTDUPOBJ needs *USE and add authority to the library it creates the copy in. RNMOBJ needs update and execute authority to the library that holds the object.

When the user doesn't have what the command needs, the command stops and sends CPF2182. Libraries with sensitive data are often set to *PUBLIC *EXCLUDE on purpose, so this message can simply mean that security is doing its job.

Common causes

  • The library's *PUBLIC authority is *EXCLUDE or too low, and the user has no private or group authority to it.
  • A CL program or initial program adds a library that only some of the users who run it are allowed to use.
  • CRTDUPOBJ or a similar command is copying into a library where the user can read but not add objects.
  • The user changed group profile, or the library was re-created or restored without its old private authorities.
  • The job runs under a different user profile than expected, such as a batch job submitted with a different USER.

How to find the problem

  1. Open the job log with DSPJOBLOG, put the cursor on CPF2182 and press F1. The help names the library. F9 shows the program that ran the command.
  2. Run DSPOBJAUT OBJ(QSYS/ACCTLIB) OBJTYPE(*LIB) to see who has what authority to the library.
  3. Run DSPUSRPRF for the user to see the group profile and supplemental groups, and compare them with the library's authority list.
  4. For CRTDUPOBJ and RNMOBJ, check which library parameter the message names. The user may have enough authority to one library and not the other.

How to fix it

  • If the user should have access, grant it, for example GRTOBJAUT OBJ(QSYS/ACCTLIB) OBJTYPE(*LIB) USER(CLERK01) AUT(*USE). Grant *CHANGE only if the user must create or rename objects in the library.
  • Prefer granting to a group profile or an authorization list over single users.
  • In a program that adds an optional library, monitor for CPF2182 and carry on without it, if that is safe.
  • Library authority doesn't cover the objects inside. After the library is fixed, the user may still need authority to the objects.

What it looks like

Not authorized to library ACCTLIB.

IBM documentation

IBM Display Message Descriptions (DSPMSGD). Use the documentation for your installed release.

This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.

Read the installed message description:

DSPMSGD MSGID(CPF2182) MSGF(QSYS/QCPFMSG)

Also inspect the full job log and second-level message text, including substitution values.

Report a correction to WND Software.

Questions

What is the difference between CPF2182 and CPF9820?

They mean the same thing. CPF2182 is sent by library and object commands such as ADDLIBLE, CHGLIBL and CRTDUPOBJ, and CPF9820 by commands such as CHKOBJ.

Why did CHGLIBL change nothing at all?

CHGLIBL needs *USE authority to every library in the new list. If one is missing, it leaves the whole list unchanged.

What authority do I need on a library to add it to my library list?

*USE authority to the library. That lets you search it. It doesn't give you any rights to the objects inside.