MQ8 + JDk8 的授权错误
Authorization errors with MQ8 + JDk8
在使用 JMS 示例代码时,放置在应用程序中的 MQ8 + JDk8 出现以下授权错误
MQException received while attempting reconnect: Reason Code=2035
Exception text: com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'.
AMQERR01.LOG 说
AMQ8077: Entity 'clientadmin' has insufficient authority to access object
'TLSTEST.QM'.
EXPLANATION:
The specified entity is not authorized to access the required object. The
following requested permissions are unauthorized: connect
ACTION:
Ensure that the correct level of authority has been set for this entity against
the required object, or ensure that the entity is a member of a privileged
group.
AMQ9557: Queue Manager User ID initialization failed for 'clientadmin'.
EXPLANATION:
The call to initialize the User ID 'clientadmin' failed with CompCode 2 and Reason
2035.
ACTION:
Correct the error and try again.
按照以下站点和命令执行的步骤,但无法解决问题
http://www-01.ibm.com/support/docview.wss?uid=swg21680930
http://www-01.ibm.com/support/docview.wss?uid=swg21577137
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(OPTIONAL)
REFRESH SECURITY TYPE(CONNAUTH)
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(NONE)
REFRESH SECURITY TYPE(CONNAUTH)
ALTER QMGR CHLAUTH(DISABLED)
Resolved with Below commands
删除了'SecurityPolicy=user',仅如下设置Auth并重新启动QM
setmqaut -m TLSTEST.QM -t qmgr -p clientadmin +all
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n RECEIVE +all
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n SEND +all
只是想知道,如何在 qmgr 的所有队列中设置“+all”?将为 qmgr 中的所有队列设置@通道级别?
Worked-Success with below commands and settings
'SecurityPolicy=user'
setmqaut -m TLSTEST.QM -t qmgr -p clientadmin +connect +dsp +inq
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n RECEIVE +put +get +browse +dsp +inq
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n SEND +put +get +browse +dsp +inq
AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(OPTIONAL)
将要求发送的密码是有效密码。
您遇到的 AMQ8077
错误是因为用户没有连接到队列管理器的权限。
您必须获得 运行t OAM 许可才能允许 clientadmin
到 connect
到队列管理器。
默认情况下,在 Linux 上,您可以仅针对用户所属的组授予 运行t MQ OAM 权限,在您的情况下,clientadmin
是一个组成员。在 MQ v8.0 及更高版本中,如果已将以下设置添加到 qm.ini 中,您还可以对用户本身授予 运行t OAM 权限:
Service:
SecurityPolicy=user
以上设置不是必需的,它只是允许两种不同的方式来获得运行t OAM权限。这记录在 IBM MQ v8.0 知识中心页面“Principals and groups”中。此页面声明:
UNIX and Linux systems
ACLs are based on both user IDs and groups and you can use either for authorization.
With Version 8.0, you can use the user-based model for authorization, and this allows you to use both users and groups. However, when you specify a user in the setmqaut command, the new permissions apply to that user alone, and not any groups to which that user belongs.
See Installable services for more information.
When you are using the group-based model for authorization, the primary group to which the user ID belongs is included in the ACL.
The individual user ID is not included and authority is granted to all members of that group. Because of this, be aware that you can inadvertently change the authority of a principal by changing the authority of another principal in the same group.
这在 IBM MQ v8.0 知识中心页面“Installable services”中有记录。此页面声明:
SecurityPolicy=user|group|default
On UNIX and Linux systems the value specifies whether the queue manager uses user-based or group-based authorization. Values are not case sensitive.
If you do not include this attribute, default is used, which uses group-based authorization. Restart the queue manager for changes to become effective.
获得 OAM 权限以针对组连接到队列管理器,您可以使用 MQSC 命令 SET AUTHREC
:
SET AUTHREC PROFILE('self') GROUP('groupname') OBJTYPE(QMGR) AUTHADD(CONNECT,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t qmgr -g groupname +connect +dsp +inq
获得 OAM 权限以针对用户本身连接到队列管理器,您可以使用 MQSC 命令 SET AUTHREC
:
SET AUTHREC PROFILE('self') PRINCIPAL('clientadmin') OBJTYPE(QMGR) AUTHADD(CONNECT,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t qmgr -p clientadmin +connect +dsp +inq
您还需要对要访问的队列进行 PUT 或 GET 访问。以下使用 MQSC 命令的示例 SET AUTHREC
正在使用主体,但您可以根据需要将其更改为使用组:
SET AUTHREC PROFILE('QUEUE.NAME') PRINCIPAL('clientadmin') OBJTYPE(QUEUE) AUTHADD(PUT,GET,BROWSE,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t queue -p clientadmin +put +get +browse +dsp +inq
Update 2017/02/21
不推荐在没有 SecurityPolicy=user 的情况下使用 -p 在 Linux 上设置权限。这是因为此操作不会针对使用 -p 指定的用户设置权限,而是在您 运行 命令时针对该用户的主要组设置权限。
这会导致各种情况,下面是我能想到的几个例子:
- 如果您有两个用户具有相同的主要组,并且您为他们提供了不同的访问级别,那么他们最终都会获得与您 运行 的最后一个 setmqaut 命令所产生的相同访问级别。
- 即使您一开始就为他们提供了相同级别的访问权限,您也可能希望删除这两个用户之一的访问权限,并发出具有指定权限
-remove
的类似命令。结果将 而不是 是您从两个用户中的一个删除了访问权限,而是从两个用户中删除了它。
- unix 帐户的主要组发生变化的情况并不少见。如果用户在更改后不属于作为辅助组的同一组的成员,他们将失去对 MQ 的访问权限。
也不建议为non-administrative用户提供+all
,如果你这样做你不妨将用户添加到mqm
组并为他们提供完整的MQ管理权限。
您应该改为向用户提供所需的特定权限。我在我的示例中提供了一组有限的权限,应该适用于大多数应用程序。
在使用 JMS 示例代码时,放置在应用程序中的 MQ8 + JDk8 出现以下授权错误
MQException received while attempting reconnect: Reason Code=2035
Exception text: com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'.
AMQERR01.LOG 说
AMQ8077: Entity 'clientadmin' has insufficient authority to access object
'TLSTEST.QM'.
EXPLANATION:
The specified entity is not authorized to access the required object. The
following requested permissions are unauthorized: connect
ACTION:
Ensure that the correct level of authority has been set for this entity against
the required object, or ensure that the entity is a member of a privileged
group.
AMQ9557: Queue Manager User ID initialization failed for 'clientadmin'.
EXPLANATION:
The call to initialize the User ID 'clientadmin' failed with CompCode 2 and Reason
2035.
ACTION:
Correct the error and try again.
按照以下站点和命令执行的步骤,但无法解决问题
http://www-01.ibm.com/support/docview.wss?uid=swg21680930
http://www-01.ibm.com/support/docview.wss?uid=swg21577137
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(OPTIONAL)
REFRESH SECURITY TYPE(CONNAUTH)
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(NONE)
REFRESH SECURITY TYPE(CONNAUTH)
ALTER QMGR CHLAUTH(DISABLED)
Resolved with Below commands
删除了'SecurityPolicy=user',仅如下设置Auth并重新启动QM
setmqaut -m TLSTEST.QM -t qmgr -p clientadmin +all
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n RECEIVE +all
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n SEND +all
只是想知道,如何在 qmgr 的所有队列中设置“+all”?将为 qmgr 中的所有队列设置@通道级别?
Worked-Success with below commands and settings
'SecurityPolicy=user'
setmqaut -m TLSTEST.QM -t qmgr -p clientadmin +connect +dsp +inq
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n RECEIVE +put +get +browse +dsp +inq
setmqaut -m TLSTEST.QM -t queue -p clientadmin -n SEND +put +get +browse +dsp +inq
AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(OPTIONAL)
将要求发送的密码是有效密码。
您遇到的 AMQ8077
错误是因为用户没有连接到队列管理器的权限。
您必须获得 运行t OAM 许可才能允许 clientadmin
到 connect
到队列管理器。
默认情况下,在 Linux 上,您可以仅针对用户所属的组授予 运行t MQ OAM 权限,在您的情况下,clientadmin
是一个组成员。在 MQ v8.0 及更高版本中,如果已将以下设置添加到 qm.ini 中,您还可以对用户本身授予 运行t OAM 权限:
Service:
SecurityPolicy=user
以上设置不是必需的,它只是允许两种不同的方式来获得运行t OAM权限。这记录在 IBM MQ v8.0 知识中心页面“Principals and groups”中。此页面声明:
UNIX and Linux systems
ACLs are based on both user IDs and groups and you can use either for authorization.
With Version 8.0, you can use the user-based model for authorization, and this allows you to use both users and groups. However, when you specify a user in the setmqaut command, the new permissions apply to that user alone, and not any groups to which that user belongs.
See Installable services for more information.
When you are using the group-based model for authorization, the primary group to which the user ID belongs is included in the ACL.
The individual user ID is not included and authority is granted to all members of that group. Because of this, be aware that you can inadvertently change the authority of a principal by changing the authority of another principal in the same group.
这在 IBM MQ v8.0 知识中心页面“Installable services”中有记录。此页面声明:
SecurityPolicy=user|group|default
On UNIX and Linux systems the value specifies whether the queue manager uses user-based or group-based authorization. Values are not case sensitive. If you do not include this attribute, default is used, which uses group-based authorization. Restart the queue manager for changes to become effective.
获得 OAM 权限以针对组连接到队列管理器,您可以使用 MQSC 命令 SET AUTHREC
:
SET AUTHREC PROFILE('self') GROUP('groupname') OBJTYPE(QMGR) AUTHADD(CONNECT,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t qmgr -g groupname +connect +dsp +inq
获得 OAM 权限以针对用户本身连接到队列管理器,您可以使用 MQSC 命令 SET AUTHREC
:
SET AUTHREC PROFILE('self') PRINCIPAL('clientadmin') OBJTYPE(QMGR) AUTHADD(CONNECT,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t qmgr -p clientadmin +connect +dsp +inq
您还需要对要访问的队列进行 PUT 或 GET 访问。以下使用 MQSC 命令的示例 SET AUTHREC
正在使用主体,但您可以根据需要将其更改为使用组:
SET AUTHREC PROFILE('QUEUE.NAME') PRINCIPAL('clientadmin') OBJTYPE(QUEUE) AUTHADD(PUT,GET,BROWSE,DSP,INQ)
同样可以使用命令行工具完成 setmqaut
:
setmqaut -m <queue_manager_name> -t queue -p clientadmin +put +get +browse +dsp +inq
Update 2017/02/21
不推荐在没有 SecurityPolicy=user 的情况下使用 -p 在 Linux 上设置权限。这是因为此操作不会针对使用 -p 指定的用户设置权限,而是在您 运行 命令时针对该用户的主要组设置权限。
这会导致各种情况,下面是我能想到的几个例子:
- 如果您有两个用户具有相同的主要组,并且您为他们提供了不同的访问级别,那么他们最终都会获得与您 运行 的最后一个 setmqaut 命令所产生的相同访问级别。
- 即使您一开始就为他们提供了相同级别的访问权限,您也可能希望删除这两个用户之一的访问权限,并发出具有指定权限
-remove
的类似命令。结果将 而不是 是您从两个用户中的一个删除了访问权限,而是从两个用户中删除了它。 - unix 帐户的主要组发生变化的情况并不少见。如果用户在更改后不属于作为辅助组的同一组的成员,他们将失去对 MQ 的访问权限。
也不建议为non-administrative用户提供+all
,如果你这样做你不妨将用户添加到mqm
组并为他们提供完整的MQ管理权限。
您应该改为向用户提供所需的特定权限。我在我的示例中提供了一组有限的权限,应该适用于大多数应用程序。