[英]How to pass authentication info when using Messsage Service Client for .net to connect to IBM WMQ
We are developing a console application using c# to access IBM WMQ.我们正在开发一个使用 c# 访问 IBM WMQ 的控制台应用程序。 We are using IBM Message Service Client for .net (XMS) and WebSphere MQ Client.
我们使用 IBM Message Service Client for .net (XMS) 和 WebSphere MQ Client。 Here are the code example:
下面是代码示例:
XMSFactoryFactory xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory cf = xff.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "host");
cf.SetIntProperty(XMSC.WMQ_PORT, 1445);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, "channel");
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "queueManager");
cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
cf.SetStringProperty(XMSC.USERID, @"userid");
cf.SetStringProperty(XMSC.PASSWORD, @"");
IConnection conn = cf.CreateConnection();
conn.ExceptionListener = new ExceptionListener(OnXMSExceptionReceived);
Console.WriteLine("connection created");
ISession sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
We kept getting the following error: CWSMQ0044E: The user is not authorized to connect to the queue manager.我们不断收到以下错误:CWSMQ0044E:用户无权连接到队列管理器。 The application has tried to connect to a queue manager without authorization.
应用程序试图在未经授权的情况下连接到队列管理器。 Ensure th at appropriate authority exists on the queue manager for this user.
确保该用户在队列管理器上具有适当的权限。
But we have no problem to access the same MQ using spring integration.但是我们使用spring集成访问同一个MQ是没有问题的。 here is the settings for spring integration:
这是 spring 集成的设置:
<bean id="connectionFactoryWBI" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="${hostName}" />
<property name="port" value="${port}" />
<property name="queueManager" value="${queueManager}" />
<property name="channel" value="${channel}" />
<property name="transportType" value="1" />
</bean>
<bean id="connectionFactoryWBIWithCredentials" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="connectionFactoryWBI" />
<property name="username" value="${username}" />
</bean>
I am new to XMS and .net, do not know how to pass the authentication info for connecting to MQ.我是 XMS 和 .net 的新手,不知道如何传递身份验证信息以连接到 MQ。 any recommendations are highly welcome!
非常欢迎任何建议!
XMS .NET and MQ JMS clients work little different. XMS .NET 和 MQ JMS 客户端的工作方式略有不同。 When connecting to queue manager, XMS .NET first sends the currently logged in Windows user id and then sends the application specified user id.
当连接到队列管理器时,XMS .NET 首先发送当前登录的 Windows 用户 ID,然后发送应用程序指定的用户 ID。 If these two user ids are same, then connection is created.
如果这两个用户 ID 相同,则创建连接。 But if they are different then you will get
CWSMQ0044E
error.但是如果它们不同,那么您将收到
CWSMQ0044E
错误。 This is basically MQ Reason code 2035, MQRC_NOT_AUTHORIZED.这基本上是 MQ 原因代码 2035,MQRC_NOT_AUTHORIZED。 However in case of MQ JMS, only the application specified user id is sent, Windows user id is not sent.
但是,对于 MQ JMS,仅发送应用程序指定的用户 ID,不发送 Windows 用户 ID。 Hence you don't see the error.
因此,您看不到错误。
There are number of ways to address the issue you are seeing when using XMS .NET:有多种方法可以解决您在使用 XMS .NET 时遇到的问题:
1) Use a MQ Server side Security Exit. 1) 使用 MQ 服务器端安全出口。
2) Channel Authentication Records (Available from MQ v7.1 onwards) 2) 通道认证记录(MQ v7.1 以后可用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.