Author |
Message
|
rbreault |
Posted: Mon Jul 23, 2007 11:31 am Post subject: Error in .NET that I cant get by |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
I have been trying to create an app to talk to mq using .Net c#. I made it so simple because I am having the same issue over and over its a
Error: CompCode: 2 Reason 2035 which hasn't helped me much. Here is what the definition of the error is.
MQRC_NOT_AUTHORIZED
The user is not authorized to perform the operation attempted:
v On an MQCONN or MQCONNX call, the user is not authorized to connect to the queue
manager.
On z/OS, for CICS applications, MQRC_CONNECTION_NOT_AUTHORIZED is issued
instead.
v On an MQOPEN or MQPUT1 call, the user is not authorized to open the object for the
option(s) specified.
On z/OS, if the object being opened is a model queue, this reason also arises if the user is
not authorized to create a dynamic queue with the required name.
v On an MQCLOSE call, the user is not authorized to delete the object, which is a permanent
dynamic queue, and the Hobj parameter specified on the MQCLOSE call is not the handle
returned by the MQOPEN call that created the queue.
This reason code can also occur in the Feedback field in the message descriptor of a report
message; in this case it indicates that the error was encountered by a message channel agent
when it attempted to put the message on a remote queue.
Corrective action: Ensure that the correct queue manager or object was specified, and that
appropriate authority exists.
On z/OS, to determine for which object you are not authorized, you can use the violation
messages issued by the External Security Manager.
I know I dont require a password as I use this in Java all the time. Here is my code
using System;
using System.Collections.Generic;
using System.Text;
using IBM.WMQ;
namespace simpleMQ
{
class simplePut
{
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage: SimplePut QName [QMgrName]");
return;
}
string qName = args[0];
string qMgrName = "ARKDEV.QUEUE.MANAGER";
string hostName = "172.31.0.253";
string channel = "SYSTEM.ADMIN.SVRCONN";
if (args.Length > 1)
{
qMgrName = args[1];
}
MQEnvironment.Hostname = (hostName);
MQEnvironment.Channel = (channel);
MQEnvironment.Port = 1414;
try
{
Console.WriteLine("Sample SimplePut started");
MQQueueManager qMgr = new MQQueueManager(qMgrName);
MQQueue queue = qMgr.AccessQueue(qName, MQC.MQOO_OUTPUT);
string line;
do
{
line = Console.ReadLine();
if (line.Length > 0)
{
MQMessage message = new MQMessage();
message.WriteString(line);
message.Format = MQC.MQFMT_STRING;
queue.Put(message);
}
} while (line.Length > 0);
queue.Close();
qMgr.Disconnect();
}
catch (MQException e)
{
Console.WriteLine("Error: {0}", e.ToString());
}
}
}
}
Any help would be great |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jul 23, 2007 11:43 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
This is not a .NET issue.
It's very very very clear what the error message means.
You don't require a password, but you're doing something *ENTIRELY* different with a Java connection.
You need to issue setmqaut commands for your user. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rbreault |
Posted: Mon Jul 23, 2007 11:57 am Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
where can I get some more information on this command
setmqaut
and maybe a example on how it is used? |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jul 23, 2007 12:05 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, if you searched here for "2035", you'd find hundreds of hits. Probably half of them would include the information you need.
Java is generally unable to retrieve an OS level user id. The .NET client is based on the C client (except the .NET Managed Client), and as such is capable of getting the OS level user id. And so it *always* passes the id for authorization during connect, put, and etc.
Java typically passes a null user id. Which has unusual effects. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rbreault |
Posted: Mon Jul 23, 2007 5:39 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
ok so I have been searching all over this forum. for 2035 I can run a lot of the commands people have talked about as I am running MQ server on AS400/iSeries I have checked.
Can I use the MQEnviorment.userid and MQEnviorment.password in my code to set this.
I understand that this question has been asked and on and on but if you could just simple point me to a post with the answer or example would be great. |
|
Back to top |
|
 |
rbreault |
Posted: Mon Jul 23, 2007 5:51 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
found the command for AS400
posting it here in case someone else needs it with a description
On i5/OS, an administrator uses the CL command GRTMQMAUT to grant authorities and the CL command RVKMQMAUT to revoke authorities. Generic profiles can be used as well. For example, the CL command:
GRTMQMAUT MQMNAME(JUPITER) OBJTYPE(*Q) OBJ('MOON.*') USER(VOYAGER) AUT(*PUT)provides the same function as the previous example of a setmqaut command; it allows the members of the group VOYAGER to put messages on any queue whose name commences with the characters MOON. .
The CL command DSPMQMAUT displays the current authorities that user or group has for a specified object. The CL commands WRKMQMAUT and WRKMQMAUTD are also available to work with the current authorities associated with objects and generic profiles. |
|
Back to top |
|
 |
rbreault |
Posted: Mon Jul 23, 2007 8:42 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
so I have found out how to add a user to the iseries and create the same user in windows but my question on this is I have IIS ASP running how can I define that user? Can it be in my code or a system setting. Changing the 400 side permissions didn't solve that issue |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 24, 2007 1:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You need to grant permissions to the USER RUNNING THE MQ CODE. You need to create a user of the same name as the Windows user on the AS400, and then use those AS400 commands to grant access to MQ resources to that user. The passwords DO NOT have to be the same.
Or set an MCAUser on the channel being used to connect to the qmgr. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rbreault |
Posted: Tue Jul 24, 2007 4:46 am Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
thank you thats what I thought when I posted the question last night I was hopeing I could add it to the code but adding a user to the 400 is fine as well. again thank you |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 24, 2007 5:06 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You should be able to configure IIS to run your particular ASP page as a particular user.
This won't necessarily be a change "in your code", but it will be a change on the Windows side rather than the AS400 side.
Or, as I said, you can use the MCAUser on the SVRCONN you're using, to set the user that the AS400 sees. This would be the user that *anyone* who connects to that channel would be *forced* to, so you don't want to set it to a priviledged user like MQM. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rbreault |
Posted: Tue Jul 24, 2007 7:30 am Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
thank you again I changed the user for IIS |
|
Back to top |
|
 |
|