Search code examples
c#.netwebsphereibm-mqmq

Websphere MQ 7 C# XMS connection using a different user


I have been using the XMS API to connect to Websphere MQ and using the following code I am able to connect fine:

    private IConnection CreateWqmConnection() 
    {
        // Create the connection factories factory using WMQ (websphere message queue)
        XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);

        // Use the connection factories factory to create a connection factory
        IConnectionFactory cf = factoryFactory.CreateConnectionFactory();

        // Set the properties

        cf.SetStringProperty(XMSC.USERID, @"user");
        cf.SetStringProperty(XMSC.PASSWORD, @"password");

        cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, MessageQueueManager);
        cf.SetStringProperty(XMSC.WMQ_HOST_NAME, MessageQueueHost);
        cf.SetIntProperty(XMSC.WMQ_PORT, MessageQueuePort);
        cf.SetStringProperty(XMSC.WMQ_CHANNEL, MessageQueueChannel);
        cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
        cf.SetStringProperty(XMSC.CLIENT_ID, UniqueClientId);

        return cf.CreateConnection();            
    }

However if I try and change the username and password to anyone other than the user I am currently logged in as I am getting a 2035 security error. I have logged into the host machine and added the user to the mqm group and I can connect using this user from my local machine using WMQ Explorer and publish messages, just not with XMS.

Additionally I have found if I debug the program under this user account I can connect, so it appears I cannot run as one user and authenticate as another. Is this the case with XMS? And is there a way around this?


Solution

  • XMS always uses the logged on user id for authenticating with queue manager. The behavior is similar to WebSphere MQ C Clients. Please refer to this page in the Infocenter for more details on alternatives.