2009-11-19 138 views
2

我在运行Windows Server 2003的虚拟机上安装了IBM WebSphere MQ版本6的服务器端,它位于Vista桌面上。桌面安装了客户端。使用Websphere授权MQ 6

我有一个小的测试程序(从他们的代码示例),这给队列中的消息,并再次采取它关闭。这个程序在服务器绑定时直接在服务器上运行。但是,我无法通过客户端绑定从客户端获得它。

我得到的错误是CompCode 2,原因2035年,这是一个授权失败。

我怀疑这与该程序在默认情况下我的用户下运行,这是虚拟机不知道(和不能访问)域的事实做。

我已经在虚拟机上设置了一个本地用户,我想以(用户:websphere,密码:websphere)连接,但我不清楚如何让这一切工作。我有我使用下面的代码,我已经尝试过的通道和端点安全出口设置的各种组合,但我不能从2035年

任何人都逃脱有这方面的经验?帮助将非常感谢!

代码:

using System; 
using System.Collections; 

using IBM.WMQ; 

class MQSample 
{ 
    // The type of connection to use, this can be:- 
    // MQC.TRANSPORT_MQSERIES_BINDINGS for a server connection. 
    // MQC.TRANSPORT_MQSERIES_CLIENT for a non-XA client connection 
    // MQC.TRANSPORT_MQSERIES_XACLIENT for an XA client connection 
    // MQC.TRANSPORT_MQSERIES_MANAGED for a managed client connection 
    const String connectionType = MQC.TRANSPORT_MQSERIES_CLIENT; 

    // Define the name of the queue manager to use (applies to all connections) 
    const String qManager = "QM_vm_win2003"; 

    // Define the name of your host connection (applies to client connections only) 
    const String hostName = "vm-win2003"; 

    // Define the name of the channel to use (applies to client connections only) 
    const String channel = "S_vm_win2003"; 

    /// <summary> 
    /// Initialise the connection properties for the connection type requested 
    /// </summary> 
    /// <param name="connectionType">One of the MQC.TRANSPORT_MQSERIES_ values</param> 
    static Hashtable init(String connectionType) 
    { 
     Hashtable connectionProperties = new Hashtable(); 

     // Add the connection type 
     connectionProperties.Add(MQC.TRANSPORT_PROPERTY, connectionType); 

     // Set up the rest of the connection properties, based on the 
     // connection type requested 
     switch (connectionType) 
     { 
      case MQC.TRANSPORT_MQSERIES_BINDINGS: 
       break; 
      case MQC.TRANSPORT_MQSERIES_CLIENT: 
       connectionProperties.Add(MQC.HOST_NAME_PROPERTY, hostName); 
       connectionProperties.Add(MQC.CHANNEL_PROPERTY, channel); 
       connectionProperties.Add(MQC.USER_ID_PROPERTY, "websphere"); 
       connectionProperties.Add(MQC.PASSWORD_PROPERTY, "websphere"); 
       break; 
     } 

     return connectionProperties; 
    } 

    /// <summary> 
    /// The main entry point for the application. 
    /// </summary> 
    [STAThread] 
    static int Main(string[] args) 
    { 
     try 
     { 
      Hashtable connectionProperties = init(connectionType); 

      // Create a connection to the queue manager using the connection 
      // properties just defined 
      MQQueueManager qMgr = new MQQueueManager(qManager, connectionProperties); 

      // Set up the options on the queue we wish to open 
      int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT; 

      // Now specify the queue that we wish to open,and the open options 
      MQQueue system_default_local_queue = 
       qMgr.AccessQueue("clq_default_vm_sql2000", openOptions); 

      // Define a WebSphere MQ message, writing some text in UTF format 
      MQMessage hello_world = new MQMessage(); 
      hello_world.WriteUTF("Hello World!"); 

      // Specify the message options 
      MQPutMessageOptions pmo = new MQPutMessageOptions(); 
      // accept the defaults, 
      // same as MQPMO_DEFAULT 

      // Put the message on the queue 
      system_default_local_queue.Put(hello_world, pmo); 

      // Get the message back again 

      // First define a WebSphere MQ message buffer to receive the message 
      MQMessage retrievedMessage = new MQMessage(); 
      retrievedMessage.MessageId = hello_world.MessageId; 

      // Set the get message options 
      MQGetMessageOptions gmo = new MQGetMessageOptions(); //accept the defaults 
      //same as MQGMO_DEFAULT 

      // Get the message off the queue 
      system_default_local_queue.Get(retrievedMessage, gmo); 

      // Prove we have the message by displaying the UTF message text 
      String msgText = retrievedMessage.ReadUTF(); 
      Console.WriteLine("The message is: {0}", msgText); 

      // Close the queue 
      system_default_local_queue.Close(); 

      // Disconnect from the queue manager 
      qMgr.Disconnect(); 
     } 

     //If an error has occurred in the above,try to identify what went wrong. 

     //Was it a WebSphere MQ error? 
     catch (MQException ex) 
     { 
      Console.WriteLine("A WebSphere MQ error occurred: {0}", ex.ToString()); 
     } 

     catch (System.Exception ex) 
     { 
      Console.WriteLine("A System error occurred: {0}", ex.ToString()); 
     } 

     Console.ReadLine(); 
     return 0; 
    }//end of start 
}//end of sample 

回答

2

随着Windows到视窗连接,WMQ将通过SID以及“短ID”在这种情况下将是“的WebSphere”。这比使用短ID的非Windows WMQ获得的授权要好一点。问题在于非windows服务器上的某个人可以使用短ID“websphere”进行连接,并且由于没有SID,WMQ将接受连接,因为它认为它的的Windows帐户。

解决这个问题的两种方法。在QMgr主机上,您可以运行setmqaut命令来授权您实际用于连接的SID。 VM 必须能够查询Windows帐户所在的域,并且setmqaut命令必须使用-p user @ domain语法。

或者,你可以使用本地定义的ID在通道的MCAUSER像

ALTER CHL(道名)CHLTYPE(SVRCONN)MCAUSER( 'webaphere @ VM')

...其中“vm”是虚拟机的名称,并且您已通过setmqaut命令或将其放入mqm或administrators组中授权该帐户。

请记住,这是测试!具有空白或管理MCAUSER的任何通道不仅可以管理WMQ,还可以在底层主机服务器上执行任意命令。在现实世界中,您将创建可访问队列和QMgr的帐户,但不能访问管理,并将这些帐户放入所有MCAUSER值,然后为所有SYSTEM.DEF和SYSTEM.AUTO通道设置MCAUSER('nobody') 。

地段更多关于这可在我的网站t-rob.net在MQ和链接的网页。此外,检查出:

评论专栏:T.Rob Wyatt:What you didn't know you didn’t know about WebSphere MQ security

评论专栏:T.Rob Wyatt:WebSphere MQ security heats up

-1

我曾经有过同样的问题。解决方案,我们需要将用户窗口帐户分配给MQA组或管理员组。然后,将该窗口帐户的用户名添加到通道中的MCA用户。

希望这有助于

+1

这正好从没有人被授权大家都在管理员权限,并在MQ服务器上远程执行代码的能力。 – 2011-03-25 15:27:39