IBM i Global

IBM i 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  SQL limits in 7.4

    Posted 06/17/26 01:59 PM

    Hello, I have an IBM i 7.4 partition, and I want to limit SQL connection activities to read-only. Could you help me? Thanks.



    ------------------------------
    Miguel Peralta
    ------------------------------


  • 2.  RE: SQL limits in 7.4

    Posted 06/17/26 03:52 PM

    Let me see if I have this right.  If your software vendor sends you a program and instead of doing an RPG read they do an SQL UPDATE, you want to put a stop to this?

    Or more interactive stuff like, if a software developer starts up STRSQL and does an UPDATE you want to put a stop to this?

    Or are you solely concerned about client/server or web based SQL access?

    "Best practices" is that you limit users access to your data directly.  You use "application only" access as outlined at https://www.linkedin.com/pulse/piecemeal-security-rob-berendt/?trackingId=mnD3iawUTkm%2FYvsj1W5dww%3D%3D

    This basically says the authorization list assigned to your data has *ALL for the adopted authority set to the programs either from your vendor or your custom applications.  Then *USE for those users who are your Query mongers or data scientists.  All others are *EXCLUDE.

    Now, if you love to play whack-a-mole you can look at exit point software and shovel out some serious cash and tie up time setting that up.



    ------------------------------
    Robert Berendt IBMChampion
    Business Systems Analyst, Lead
    Dekko
    Fort Wayne
    ------------------------------



  • 3.  RE: SQL limits in 7.4

    Posted 06/18/26 10:30 AM

    Yes, that's correct. If the data is accessed via SQL connections, they can only read it; if it's via RPG, they can execute everything.
    Thanks for the information.



    ------------------------------
    Miguel Peralta
    ------------------------------



  • 4.  RE: SQL limits in 7.4

    Posted 06/18/26 12:31 PM

    Hi Miguel, i am not sure if i understood the question, but, i think you should need an exit program to control the exit point of SQL remote access function.



    ------------------------------
    ULISES JIMENEZ
    ------------------------------



  • 5.  RE: SQL limits in 7.4

    Posted 5 days ago

    Hi Miguel,

    To restrict SQL connections to read-only on IBM i 7.4, the most secure approach combines database object authority management with Exit Point programs for remote access.

    1. Database Authorities (Server-Side Security) This is the most robust method because it applies regardless of how the user connects.

    • Native IBM i Authorities: Grant *USE (read-only) authority instead of *CHANGE or *ALL on the target tables or libraries using: GRTOBJAUT OBJ(LIBRARY/TABLE) OBJTYPE(*FILE) USER(USERNAME) AUT(*USE)

    • SQL Statements: Execute standard GRANT/REVOKE commands to enforce explicit permissions- REVOKE INSERT, UPDATE, DELETE ON TABLE FROM USERNAME;
      - GRANT SELECT ON TABLE TO USERNAME;

    2. Exit Point Programs If connections originate from external connectors (ODBC, JDBC, OLE DB, .NET), network traffic can be controlled via database exit points.

    • Attach custom logic to exit points QIBM_QZDA_SQL2 (SQL execution) or QIBM_QZDA_NDB1 (native DB access).

    • The Exit Program inspects incoming SQL statements prior to execution and rejects requests containing INSERT, UPDATE, DELETE, ETC.

    3. Client-Side Configuration (ODBC/JDBC)

    • Set the connection string or Data Source Name to use read-only mode (AccessMode=1 or ReadOnly=True).

    • Note: This prevents accidental edits from the client app, but it must be backed by server-side security to prevent users from overriding local settings.

    4. User Profile Hardening

    • Set the user profile to LMTCPB(*YES) to block execution of system command lines through emulation tools or interactive SQL utilities.

    Regards.



    ------------------------------
    [Guido] [Martinez]
    ------------------------------



  • 6.  RE: SQL limits in 7.4

    Posted 4 days ago
    Edited by Tony Crabtree 4 days ago

    #4. LMTCPB(*YES) is often misunderstood. It does not prevent users from executing commands through all interfaces. Instead, it restricts command execution through specific command-entry methods.

    Interface Blocked by LMTCPB(*YES)?
    5250 command line Yes, except commands with ALWLMTUSR(*YES)
    FTP remote commands RCMD/QUOTE RCMD Yes, except commands with ALWLMTUSR(*YES)
    REXEC Yes, except commands with ALWLMTUSR(*YES)
    QCAPCMD API Yes, except commands with ALWLMTUSR(*YES)
    Commands run inside applications/CL programs No
    QCMDEXC No
    STRSQL SQL statements No
    ACS Run SQL Scripts No
    ODBC/JDBC SQL No
    FTP subcommands dltl, crtl, etc. No

    Object-level authorities provide the strongest and most fundamental layer of security. They determine which objects a user can access and what actions can be performed against those objects. For example, end-user profiles may be granted no direct authority to production files. This ensures that the data remains protected regardless of how the user connects to the system, whether through a 5250 session, FTP, ODBC, JDBC, SQL, or another interface.

    In this model, access to production data is provided exclusively through authorized application programs. Users are granted authority to run the application, while the application itself is responsible for accessing the underlying production objects.

    Additional access can be granted through group profiles or authorization lists when appropriate. For example, the READONLY group profile may be granted *READ authority to selected file objects. Only users who are members of the READONLY group can access those files using methods such as FTP, ODBC, or SQL, and then only for read-only purposes.

    Exit programs provide granular control over activity through specific interfaces. For example, they can restrict which commands or SQL statements are allowed through FTP, ODBC, JDBC, or DRDA connections. A common example is allowing only FTP GET operations or SQL SELECT statements while blocking updates and deletes.

    Function Usage provides broader access control by determining which users can access a particular server or function. For example, it can be used to allow only members of a group such as CANUSEFTP to access the FTP server, or only designated users to connect through SQL and ODBC services.



    ------------------------------
    Tony Crabtree
    ------------------------------



  • 7.  RE: SQL limits in 7.4

    Posted 23 hours ago
    Hi,
    Regarding your question about whether it is possible to validate SQL statements sent by a user in IBM i (for example, to restrict access so only SELECT statements are allowed), yes, it is completely feasible.
    This is achieved by intercepting external database connections (such as ODBC, JDBC, or .NET) using an exit program. Here is a breakdown of how it works technically, along with the official documentation and community code examples to help you get started:
    Technical Overview
    1. The Exit Point: You need to register your custom program under the native system exit point QIBM_QZDA_SQL2 using the ZDAQ0200 parameter format.
    2. The Code Logic: The operating system passes a structured data structure to your program (usually written in RPGLE or C). This structure contains the user profile, the request type, and the exact raw SQL text.
    3. The Verdict: Your program inspects the text string (e.g., verifying it starts with SELECT and does not contain unauthorized keywords like DELETE, UPDATE, or DROP). If authorized, it returns a parameter value of X'F1' (allow); if unauthorized, it returns X'F0' (reject), which immediately kills the execution and returns a database error to the user.
    Documentation and Code Examples:
    Important Considerations:
    While this approach is excellent for auditing or perimeter blocking, it does introduce a minor performance overhead because the program triggers for every single SQL statement sent to the server. Furthermore, parsing raw text can sometimes be bypassed using SQL evasion tricks (such as embedding inline comments like UPD/*comment*/ATE).
    Because of this, IBM always recommends pairing or prioritizing native object-level security. If a user is restricted to read-only (*READ) authority at the database level, the Db2 for i engine will automatically block any write attempts natively, which is inherently more secure.


    ------------------------------
    Cristian Ballestero
    Software Arquitect
    BAC
    ------------------------------



  • 8.  RE: SQL limits in 7.4

    Posted 21 hours ago

    If you want to parse the SQL statement, do NOT rely on your own parsing capabilities - there is too much, that you will get wrong. 

    But there is the SQL function PARSE_STATEMENT - this will do most of the heavy lifting. 

    https://www.ibm.com/docs/en/i/7.4.0?topic=services-parse-statement-table-function

    It should give you enough information - but of course it will add some overhead to SQL execution times, but you can limit this easily to "remote SQL sessions" only, and don't parse statements, that are issued from programs.

    HTH

    Daniel



    ------------------------------
    Daniel Gross
    #IBMChampion
    Senior Core Developer, Geis Group
    Pegnitz, Germany
    https://blog.qpgmr.de/
    ------------------------------