ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » setting user to outgoing messages

Post new topic  Reply to topic
 setting user to outgoing messages « View previous topic :: View next topic » 
Author Message
naory
PostPosted: Sat Oct 15, 2005 10:27 am    Post subject: setting user to outgoing messages Reply with quote

Novice

Joined: 05 Oct 2005
Posts: 17

Hi,

I am trying to set the user id for sent messages from the application using the JAVA API with no success.

the queue is opened with the following options:

Code:
private static final int QOPEN_WRITE_ONLY =
        MQC.MQOO_OUTPUT | 
        MQC.MQOO_SET_ALL_CONTEXT |                 
        MQC.MQOO_SET_IDENTITY_CONTEXT |
        MQC.MQOO_BIND_NOT_FIXED |   
        MQC.MQOO_FAIL_IF_QUIESCING;



and messages are sent with the following options:

Code:
MQMessage message = new MQMessage();
message.messageType = MQC.MQMT_DATAGRAM;
message.format = MQC.MQFMT_STRING;
message.writeString("some message text");

// specify for COD:
message.replyToQueueManagerName = rtoqm;
message.replyToQueueName = rtoq;

message.report =
                    MQC.MQRO_NEW_MSG_ID |
                    MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID |
                    MQC.MQRO_DEAD_LETTER_Q |
                    MQC.MQRO_COD_WITH_FULL_DATA;

//message options:
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT;


i make the following call to send the message and specify "someuser" as the alternative user:

Code:
MQQueueManager queueManager = new MQQueueManager("qmgrName");
MQQueue queue = queueManager.accessQueue(queuename,
                                               QOPEN_WRITE_ONLY,
                                               null,         // default queue manager
                                               null,         // no dynamic queue name
                                               "someuser");   // alternate user id


but still get a blank userid.


I've also tried setting the user in the following way:

Code:
//message options:
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT |
                      MQC.MQPMO_SET_IDENTITY_CONTEXT;

message.userId = "someuser";



but get exception for invalid options: com.ibm.mq.MQException: Completion Code 2, Reason 2046

can anyone please advise how to acomplish this

thanks

naor
Back to top
View user's profile Send private message
hopsala
PostPosted: Sat Oct 15, 2005 11:29 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Seems you had forgotten MQC.MQOO_ALTERNATE_USER_AUTHORITY - See:
.NET Client Connection Problems
AlternateSecurityId
2063-security error and 2035-unauthorized access error
I fear none of these is about your specific prob, but careful reading should yield some important hints.

(p.s excellent post - clear, concise, relevant code snippets and all- cheers! )
Back to top
View user's profile Send private message
wschutz
PostPosted: Sat Oct 15, 2005 12:13 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Me thinks you shouldn't be setting both of these:
Code:
       MQC.MQOO_SET_ALL_CONTEXT |                 
        MQC.MQOO_SET_IDENTITY_CONTEXT |

Try with just set identity....
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
naory
PostPosted: Sat Oct 15, 2005 2:02 pm    Post subject: Reply with quote

Novice

Joined: 05 Oct 2005
Posts: 17

setting the MQC.MQOO_ALTERNATE_USER_AUTHORITY only caused yet another 2035 error

however when i removed the MQC.MQOO_SET_IDENTITY_CONTEXT i can see the user on my outgoing messages!!

Thanks for your help.

NY
Back to top
View user's profile Send private message
hopsala
PostPosted: Sun Oct 16, 2005 4:27 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

naory wrote:
setting the MQC.MQOO_ALTERNATE_USER_AUTHORITY only caused yet another 2035 error

2035 is a good thing, it means your prog has set the options correctly, but has no authorities to use alternateUserId; you have to use setmqaut with +altusr option to the user you MQCONN with.

I believe you are confusing two seperate things - alternate user authorization and setting MQMD.UserId: AlternateUserId means your prog puts the message under a different set of authorities, i.e the authorities of the alternate user; to use this option your prog must have +altusr special authority, since this using altuser pretty much means you can have any authority you want. MQMD.UserId, on the other hand, is just another MQMD field which is normally set automatically, and if you wish to change it you must have some type of set_context authority.

I advise you read about this in the manuals before proceeding to put your code into production, you may be doing the wrong thing, while getting a seemingly correct result.
Back to top
View user's profile Send private message
naory
PostPosted: Mon Oct 17, 2005 8:22 am    Post subject: Reply with quote

Novice

Joined: 05 Oct 2005
Posts: 17

thanks for your help so far hopsala.

now i'm a little confused.

Quote:
you have to use setmqaut with +altusr option to the user you MQCONN with.


why do i also need to run the setmqaut command? isn't there a way to do this from the API?

naor
Back to top
View user's profile Send private message
naory
PostPosted: Mon Oct 17, 2005 9:51 am    Post subject: Reply with quote

Novice

Joined: 05 Oct 2005
Posts: 17

let me explain.

my ultimate goal is to be able to set the authority/user that the java application is using to put messages on a remote qmanager.

the required authority/user is 'cbxmqm' and this is also the unix user that is starting MQ, the qmanagers and the queues (member of the mqm group).

here is what i got when i logged in as the cbxmqm user and run the dspmqaut command:

Code:
[cbxmqm@qaapp2 cbxgt]$ dspmqaut -m QM.CLIENT.REMOTE -n Q.OUT -t q -p cbxmqm
Entity cbxmqm has the following authorizations for object Q.OUT:
        get
        browse
        put
        inq
        set
        crt
        dlt
        chg
        dsp
        passid
        passall
        setid
        setall
        clr


so i assume that this user already has the right authorities.

however messages i send from the java application (running in the same linux box but started by 'appuser' user) show null/blank user and cause CODs to end up on my client's deadq.


i am looking for a way to resolve this by setting this from the application.

as i explaind above i managed to set the MQMD.UserId to 'cbxmqm' and i now can see using the MQ explorer that the messages have 'cbxmqm' as the user but i have yet to test this with my client.

is that the proper way to resolve this?
will setting the altUser resolve this?

naor
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Oct 17, 2005 9:55 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

naory wrote:
my ultimate goal is to be able to set the authority/user that the java application is using to put messages on a remote qmanager.


Did you try looking at all of the properties of MQEnvironment?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Tibor
PostPosted: Tue Oct 18, 2005 2:08 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

We use the next method redefining pubsub users:
Code:
setmqaut -m RINO -n SYSTEM.BROKER.CONTROL.QUEUE -t queue -g _intgrp +inq +put +setid

and the group "_intgrp" contains all of these users.

Tibor
Back to top
View user's profile Send private message
naory
PostPosted: Sat Oct 22, 2005 1:22 pm    Post subject: Reply with quote

Novice

Joined: 05 Oct 2005
Posts: 17

a combination of the MQMD userID as well as setting it in the MQEnvironment got me the desired results.

Thank you all for your great help in getting a better understanding of it all.

naor
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » setting user to outgoing messages
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.