Unable to connect to IBM MQ from C# console application with credentials

Srinivas Nalla 96 Reputation points
2021-08-24T23:17:49.393+00:00

Hi,
I am unable to connect to IBM MQ from C# console application with credentials. Here is the code. Its throwing "2035 Not Authorized" error.

protected MQQueueManager mqQueueManager;

public override void Open() {
Hashtable properties = new Hashtable();
properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
properties.Add(MQC.HOST_NAME_PROPERTY, mq_hostName);
properties.Add(MQC.CHANNEL_PROPERTY, mq_channel);
properties.Add(MQC.PORT_PROPERTY, mq_port);
properties.Add(MQC.USER_ID_PROPERTY, mq_userName);
properties.Add(MQC.PASSWORD_PROPERTY, mq_password);
properties.Add(MQC.USE_MQCSP_AUTHENTICATION_PROPERTY, true);

try {
mqQueueManager = new MQQueueManager(mq_queueManagerName, properties);
Console.WriteLine("Connected to MQ");
}
catch (MQException e) {
log.Fatal("MQ Queue Manager creation Error", e);
throw e;
}
}

What I have tried:

If I comment user name and password properties. It’s able to connect. Not sure, why it’s not working with credentials. Please let me know if anyone has encountered this issue and any pointers to resolve the same. Thanks in advance!

Thanks
-Srini

Developer technologies C#
{count} votes

Accepted answer
  1. Srinivas Nalla 96 Reputation points
    2021-08-25T18:21:25.807+00:00

    Its an issue with user name. We are migrating Java application to .NET and in user name "@keyman " was there at the end. Looks like, this format is required for Java and its working fine there. When we use same user name in .NET, it was not working and throwing error "2035 MQRC_NOT_AUTHORIZED". Once we removed @keyman from it, it started working.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.