简体   繁体   English

使用用于 .net 的消息服务客户端连接到 IBM WMQ 时如何传递身份验证信息

[英]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 以后可用)

This issue has been discussed here .这个问题已经在这里讨论

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .Net:无法从程序集“IBM.XMS.Client.WMQ,版本=8.0.0.7”加载类型“IBM.WMQ.ManagedCommonServices” - .Net : Could not load type 'IBM.WMQ.ManagedCommonServices' from assembly 'IBM.XMS.Client.WMQ, Version=8.0.0.7 如何使用 c#.net 与 ibm websphere mq 建立连接 - how to get connect with ibm websphere mq by using c#.net 如何将Windows身份验证凭据从客户端传递到Web API服务 - How to pass Windows Authentication credential from client to Web API service 如何处理来自 IBM WMQ 的 C# 中的 RFH2 标头? - How to handle the RFH2 header in C# from IBM WMQ? 应该在.NET库中为IBM MQ WebSphere使用哪个命名空间(IBM.WMQ与IBM.WMQAX)(amqmdnet.dll) - Which namespace (IBM.WMQ vs. IBM.WMQAX) should be used in the .NET library for IBM MQ WebSphere (amqmdnet.dll) IBM.XMS.XMSC不包含WMQ_Client_Reconnect_Q_MGR的定义 - IBM.XMS.XMSC does not contain a definition for WMQ_Client_Reconnect_Q_MGR 如何在未在客户机器上安装IBM WebSphere MQ客户机的情况下连接到IBM WebSphere MQ? - How do I connect to the IBM WebSphere MQ without having the IBM WebSphere MQ Client installed on the client machine? 通过开发.Net Web服务读取身份验证信息(委托人) - Read authentication info (Principal) by developing a .Net Web Service 使用客户端证书身份验证连接到Web服务 - Connecting to a Web Service using Client Certificate authentication 如何在asp.net中查找客户信息 - how to find client info in asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM