You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JT400默认使用QUSER,调用RPG程序时如何切换为当前用户?

Great questions—let’s tackle them one by one to get your JT400 and RPG setup working as expected:

1. Can JT400’s default QUSER user be modified?

Absolutely. QUSER is only used as the default when you don’t provide explicit authentication credentials during your IBM i connection setup. Here are the most common ways to switch to a different user:

  • Explicit credentials in code: When instantiating the AS400 object, pass your target username and password directly:
    AS400 as400 = new AS400("your-ibm-i-system", "target-username", "target-password");
    
  • JDBC connection configuration: If you’re using JT400 for JDBC connections, include the user and password in your JDBC URL or connection properties:
    jdbc:as400://your-ibm-i-system;user=target-username;password=target-password
    
  • System properties: Set global JT400 properties before initializing your connection (useful if you want to apply this across your app):
    System.setProperty("com.ibm.as400.access.User", "target-username");
    System.setProperty("com.ibm.as400.access.Password", "target-password");
    
2. How to make RPG get the actual current user instead of QUSER via the program status data structure (PSDS)?

The root cause here is that your Java app is still connecting to IBM i using QUSER’s identity—so the RPG program runs in a job owned by QUSER, which is why the PSDS picks up that user ID. To fix this:

  1. Use the correct connection credentials: First, update your JT400 connection to use the actual current user’s credentials (follow the steps from the first question). This ensures the IBM i job associated with your connection runs under that user, not QUSER.
  2. Verify your RPG PSDS setup: Make sure your PSDS is correctly referencing the user ID field. The standard PSDS has the job’s user ID starting at position 129, with a length of 10 characters. Example RPGLE code:
    Dcl-Ds Psds Qualified;
        JobUserId Char(10) Pos(129);
    End-Ds;
    
  3. Integrated authentication (if applicable): If you’re on a Windows machine and want to use the logged-in OS user’s credentials for IBM i access, enable default user authentication:
    AS400 as400 = new AS400("your-ibm-i-system");
    as400.setUseDefaultUser(true);
    
    This will pass your Windows user’s credentials to IBM i, and the RPG job will run under that user—so the PSDS will return the correct ID.

A quick best practice: Avoid using QUSER for application connections unless strictly necessary. QUSER has broad privileges, so using a least-privilege user for your app connections is better for security.

内容的提问来源于stack exchange,提问作者Bashdi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:49:46