【问题标题】:Override the userid send by Websphere MQ Client in C# Windows application在 C# Windows 应用程序中覆盖 Websphere MQ 客户端发送的用户 ID
【发布时间】:2016-07-05 11:37:56
【问题描述】:

我正在尝试使用完整的 MQ 客户端安装从 C# 应用程序连接到 Websphere MQ 7.5 服务器(在 Windows 域上)的测试实例,但我没有运气。我不断从 MQ 服务器收到错误代码 2035 MQRC_NOT_AUTHORIZED。最初我尝试了以下代码:

string QueueManagerName = "myNewQManager";
MQEnvironment.Hostname = "tst-mqsvr";
MQEnvironment.Channel = "test.channel";
MQEnvironment.Port = 1414;
MQEnvironment.UserId = "domainUser";
MQEnvironment.Password = "********";
//set transport properties.
MQEnvironment.properties[MQC.TRANSPORT_PROPERTY] = MQC.TRANSPORT_MQSERIES_CLIENT;
try
{
    queueManager = new MQQueueManager(QueueManagerName);
}
catch(MQException mqexp)
{
    //I get the error code 2035
    log.Error(mqexp)
}

改成这个也不行:

string QueueManagerName = "myNewQManager";
var queueProperties = new Hashtable();
queueProperties[MQC.TRANSPORT_PROPERTY] = MQC.TRANSPORT_MQSERIES_CLIENT;
queueProperties[MQC.HOST_NAME_PROPERTY] = "tst-mqsvr";
queueProperties[MQC.PORT_PROPERTY] = "1414";
queueProperties[MQC.CHANNEL_PROPERTY] = "test.channel";
queueProperties[MQC.USER_ID_PROPERTY] = "domainUser";
queueProperties[MQC.PASSWORD_PROPERTY] = "*********"; 
try
{
    queueManager = new MQQueueManager(QueueManagerName, queueProperties);
}
catch(MQException mqexp)
{
    //I still get the error code 2035
    log.Error(mqexp)
}

这个错误消失了,我可以从我的队列中连接/放置/获取消息

  • 我在我的频道上手动设置了 MCAUSER,或者
  • 我以设置 MQ 服务器的域用户身份运行应用程序(使用 RunAs)

但是,我将无法将这两种解决方法中的任何一种用于生产设置。我假设我收到错误代码 2035,因为 MQ 客户端发送了错误的用户 ID。我需要能够在服务器连接期间覆盖(或至少确定)流动的用户 ID。我该怎么办?

编辑:我的 AMQERR01.log 文件中出现以下错误

-------------------------------------------------------------------------------
7/6/2016 13:06:14 - Process(1380.10) User(MUSR_MQADMIN) Program(amqzlaa0.exe)
                      Host(TST-MQSVR) Installation(DefaultInstall)
                      VRMF(7.5.0.2) QMgr(MYNEWQMANAGER)

AMQ8075: Authorization failed because the SID for entity 'sinistrian' cannot be
obtained.

EXPLANATION:
The Object Authority Manager was unable to obtain a SID for the specified
entity. This could be because the local machine is not in the domain to locate
the entity, or because the entity does not exist.
ACTION:
Ensure that the entity is valid, and that all necessary domain controllers are
available. This might mean creating the entity on the local machine. 
----- amqzfubn.c : 2273 -------------------------------------------------------
7/6/2016 13:06:14 - Process(1380.10) User(MUSR_MQADMIN) Program(amqzlaa0.exe)
                      Host(TST-MQSVR) Installation(DefaultInstall)
                      VRMF(7.5.0.2) QMgr(MYNEWQMANAGER)

AMQ8073: Authorization failed because SID: ((None)) could not be resolved.

EXPLANATION:
The Object Authority Manager was unable to resolve the specified SID into
entity and domain information.
ACTION:
Ensure that the application provides a SID that is recognized on this system,
that all necessary domain controllers are available, and that the security
policy is set as you required. 
----- amqzfubn.c : 4397 -------------------------------------------------------
7/6/2016 13:06:14 - Process(3008.3) User(MUSR_MQADMIN) Program(amqrmppa.exe)
                      Host(TST-MQSVR) Installation(DefaultInstall)
                      VRMF(7.5.0.2) QMgr(MYNEWQMANAGER)

AMQ9557: Queue Manager User ID initialization failed.

EXPLANATION:
The call to initialize the User ID failed with CompCode 2 and Reason 2035.
ACTION:
Correct the error and try again. 
----- cmqxrsrv.c : 1975 -------------------------------------------------------
7/6/2016 13:06:14 - Process(3008.3) User(MUSR_MQADMIN) Program(amqrmppa.exe)
                      Host(TST-MQSVR) Installation(DefaultInstall)
                      VRMF(7.5.0.2) QMgr(MYNEWQMANAGER)

AMQ9999: Channel 'TEST.CHANNEL' to host 'WKS-L450 (192.168.10.23)' ended
abnormally.

EXPLANATION:
The channel program running under process ID 3008(2192) for channel
'TEST.CHANNEL' ended abnormally. The host name is 'WKS-L450 (192.168.10.23)';
in some cases the host name cannot be determined and so is shown as '????'.
ACTION:
Look at previous error messages for the channel program in the error logs to
determine the cause of the failure. Note that this message can be excluded
completely or suppressed by tuning the "ExcludeMessage" or "SuppressMessage"
attributes under the "QMErrorLog" stanza in qm.ini. Further information can be
found in the System Administration Guide.

【问题讨论】:

  • 您的队列管理器 AMKERR01.LOG 怎么说?查看详细信息时出现 2035 错误的原因有很多,这些详细信息都在错误日志中。没有它们,我们只是猜测。
  • @MoragHughson 我已经包含了错误日志内容
  • 我在日志中找到了我的问题的答案。谢谢@MoragHughson
  • 错误日志总是一个很好的查看位置。每次遇到问题时记得查看那里。

标签: c# ibm-mq windows-applications


【解决方案1】:

直到版本 7.5,MQ 客户端始终将登录的 UserId 而不是应用程序指定的 UserId 流向队列管理器进行授权。在这种情况下,您需要一个安全出口。

这在 MQ v8 中发生了变化,其中应用程序指定的 UserId 流向队列管理器以进行授权检查。更多细节在这里:https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.sec.doc/q113260_.htm

【讨论】:

  • 我目前无法升级到 MQ v8。我现在需要检测正在流向队列管理器的 UserId,以便我可以在通道上为其创建规则。
【解决方案2】:

您可以使用MQS_REPORT_NOAUTHMQSAUTHERRORS 设置来获取更多关于授权失败的信息。

【讨论】:

  • 我了解不需要为 MQ 7.1 及更高版本设置 MQS_REPORT_NOAUTH 环境变量,因为跟踪是默认生成的。但是,我在 MQ 服务器上将 MQSAUTHERRORS 设置为环境变量,但没有创建 FDC 文件。
  • FDC 将在队列管理器所在的服务器上创建。您是否在那里设置了环境变量并检查了 FDC 以及 AMQ8077 错误的日志?
  • 是的,我在队列管理器所在的服务器上设置了环境变量。我可以看到日志,但没有 FDC 文件。
  • 您在哪个目录寻找 FDC? AMQ8077 错误应该会告诉您访问失败的 ID 和原因。
  • 我在 C:\Program Files (x86)\IBM\WebSphere MQ\qmgrs\myNewQManager\errors\;我可以看到 AMQERR01.LOG、AMQERR02.LOG 和 AMQERR03.LOG(最后两个是空的)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-22
  • 2016-10-31
  • 1970-01-01
  • 2023-03-28
  • 2013-07-22
相关资源
最近更新 更多