簡體   English   中英

為MQ.NET客戶端創建CCDT時為MQRC_NOT_AUTHORIZED

[英]MQRC_NOT_AUTHORIZED when creating CCDT for MQ.NET Client

通過.NET客戶端訪問MQ服務器時,發生以下錯誤。 創建CCDT時不詢問登錄憑據。 但是MQ服務器出於某種原因正在尋找它。

我找不到同時涵蓋CCDT和以下錯誤的任何信息。

IBM.WMQ.MQException: MQRC_NOT_AUTHORIZED

----- cmqxrsrv.c : 2356 -------------------------------------------------------
    17/04/2018 23:50:44 - Process(1848.16) User(SYSTEM) Program(amqzlaa0.exe)
                          Host(APPLE) Installation(Installation1)
                          VRMF(8.0.0.5) QMgr(LocalQM)

    AMQ5540: Application 'bin\Debug\Producer.exe' did not supply a user ID
    and password

    EXPLANATION:
    The queue manager is configured to require a user ID and password, but none was
    supplied.
    ACTION:
    Ensure that the application provides a valid user ID and password, or change
    the queue manager configuration to OPTIONAL to allow applications to connect
    which have not supplied a user ID and password. 
    ----- amqzfuca.c : 4311 -------------------------------------------------------
    17/04/2018 23:50:44 - Process(1848.16) User(SYSTEM) Program(amqzlaa0.exe)
                          Host(APPLE) Installation(Installation1)
                          VRMF(8.0.0.5) QMgr(LocalQM)

    AMQ5541: The failed authentication check was caused by the queue manager
    CONNAUTH CHCKCLNT(REQDADM) configuration.

    EXPLANATION:
    The user ID 'mqclient' and its password were checked because the user ID is
    privileged and the queue manager connection authority (CONNAUTH) configuration
    refers to an authentication information (AUTHINFO) object named
    'SYSTEM.DEFAULT.AUTHINFO.IDPWOS' with CHCKCLNT(REQDADM). 

    This message accompanies a previous error to clarify the reason for the user ID
    and password check.
    ACTION:
    Refer to the previous error for more information. 

    Ensure that a password is specified by the client application and that the
    password is correct for the user ID. The authentication configuration of the
    queue manager connection determines the user ID repository. For example, the
    local operating system user database or an LDAP server. 

    To avoid the authentication check, you can either use an unprivileged user ID
    or amend the authentication configuration of the queue manager. You can amend
    the CHCKCLNT attribute in the CHLAUTH record, but you should generally not
    allow unauthenticated remote access. 
    -------------------------------------------------------------------------------
    17/04/2018 23:50:45 - Process(14900.9) User(SYSTEM) Program(amqrmppa.exe)
                          Host(APPLE) Installation(Installation1)
                          VRMF(8.0.0.5) QMgr(LocalQM)

    AMQ9557: Queue Manager User ID initialization failed for 'mqclient'.

    EXPLANATION:
    The call to initialize the User ID 'mqclient' failed with CompCode 2 and Reason
    2035.
    ACTION:
    Correct the error and try again. 
----- cmqxrsrv.c : 2356 -------------------------------------------------------

服務器設置

通過以下鏈接創建CCDT文件:

使用IBM MQ資源管理器設置服務器

Server-connection Channel: LOCAL.DEF.SVRCONN

MCA User ID: empty

使用IBM MQ Explorer設置客戶機

Clinet channe: LOCAL.DEF.SVRCONN

Queue Manager name: LocalQM

Connection name: 192.168.1.9(1415)

192.168.1.9是本地主機地址

1415是隊列管理器, LocalQM ,TCP端口。

SET CCDT環境

1個

C:\Users\'#.lp\source>SET MQCHLLIB=C:\ProgramData\IBM\MQ\qmgrs\LocalQM\@ipcc

C:\Users\'#.lp\source>SET MQCHLTAB=AMQCLCHL.TAB
  1. 將AMQCLCHL.TAB也放到C:\\ ProgramData \\ IBM \\ MQ(我不知道為什么這可能不正確,因為日志文件上的錯誤:

    AMQ9518:找不到文件'C:\\ ProgramData \\ IBM \\ MQ \\ AMQCLCHL.TAB'。

IBM MQ.NET

代碼從這里下面

        MQQueueManager qm = null;
        System.Environment.SetEnvironmentVariable("MQCHLLIB", "C:\\ProgramData\\IBM\\MQ\\qmgrs\\LocalQM\\@ipcc");
        System.Environment.SetEnvironmentVariable("MQCHLTAB", "AMQCLCHL.TAB");

        try
        {
            Hashtable props = new Hashtable();
            props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
            qm = new MQQueueManager("LocalQM",props);
            MQQueue queue1 = qm.AccessQueue("LocalQueue", MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING);
            MQMessage msg = new MQMessage();
            msg.WriteUTF("Hello this message is from .net client");
            queue1.Put(msg);
            queue1.Close();
            qm.Disconnect();
        }
        catch (Exception ex)
        {
            Console.Write(ex);
        }

Windows 10上的IBM MQ V8

Windows 10上的MQ.NET Client V8

創建客戶渠道定義表

在.NET中使用客戶端通道定義表

該線程與MQRC_Q_MGR_NAME_ERROR相關

更新1

點擊下面的鏈接。 但是,MQ Server似乎未使用mqccred.ini上的信息。 因為發生相同的錯誤。

客戶端安全出口,用於插入用戶ID和密碼(mqccred)

設置步驟:

1創建mqccred.ini(D:\\ mqccred.ini)

QueueManager:
    Name=LocalQM
    User=mqclient
    password=password

2設置Windows環境變量

set MQCCRED=D:\mqccred.ini

3使用mqccred

DEFINE CHANNEL(LOCAL.DEF.SVRCONN) CHLTYPE(clntconn) +
CONNAME(127.0.0.1) +
QMNAME(LocalQM) +
SCYEXIT('mqccred(ChlExit)') +
REPLACE

4設置ADOPTCTX(是)

ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) ADOPTCTX(YES)

更新2

我將MQ對象更新為大寫,並且仍然收到與上面相同的錯誤,但是下面有新的錯誤日志消息:

是否需要根據使用IBM MQ .NET中的通道出口在 .NET中編寫出口程序?

22/04/2018 22:37:15 - Process(11904.1) User('#.lp) Program(mMq.Producer.exe)
                      Host(APPLE) Installation(Installation1)
                      VRMF(8.0.0.5)
AMQ9535: User exit not valid.

EXPLANATION:
Channel program 'LOCAL.DEF.SVRCONN' ended because user exit 'mqccred(ChlExit)'
is not valid. 
Architecture of the exit library does not match the process's architecture
  which is '' bit.
ACTION:
Ensure that the user exit is specified correctly in the channel definition, and
that the user exit program is correct and available. 
----- IBM.WMQ.MQChannelExitHandler.LoadExit : 0 -------------------------------
22/04/2018 22:38:21 - Process(5720.1) User('#.lp) Program(mMq.Producer.exe)
                      Host(APPLE) Installation(Installation1)
                      VRMF(8.0.0.5)
AMQ9535: User exit not valid.

EXPLANATION:
Channel program 'LOCAL.DEF.SVRCONN' ended because user exit 'mqccred(ChlExit)'
is not valid. 
Architecture of the exit library does not match the process's architecture
  which is '' bit.
ACTION:
Ensure that the user exit is specified correctly in the channel definition, and
that the user exit program is correct and available. 
----- IBM.WMQ.MQChannelExitHandler.LoadExit : 0 -------------------------------

更新3

當MCA用戶ID設置為Windows用戶時,下面有另一個錯誤。

IBM.WMQ.MQException: MQRC_Q_MGR_NOT_AVAILABLE

22/04/2018 22:38:21 - Process(5720.1) User('#.lp) Program(mMq.Producer.exe)
                      Host(APPLE) Installation(Installation1)
                      VRMF(8.0.0.5)
AMQ9535: User exit not valid.

EXPLANATION:
Channel program 'LOCAL.DEF.SVRCONN' ended because user exit 'mqccred(ChlExit)'
is not valid. 
Architecture of the exit library does not match the process's architecture
  which is '' bit.
ACTION:
Ensure that the user exit is specified correctly in the channel definition, and
that the user exit program is correct and available. 
----- IBM.WMQ.MQChannelExitHandler.LoadExit : 0 -------------------------------

更新4

對困惑感到抱歉。 更新2和更新3相同。 這兩個更新應該具有相同的錯誤:MQRC_Q_MGR_NOT_AVAILABLE,該錯誤在更新1之后出現。我錯誤地輸入了MQRC_NOT_AUTHORIZED。

隊列管理器名稱:LocalQM

餿主意。 您正在用腳射擊自己。 對隊列管理器名稱和MQ對象名稱使用UPPERCASE。 一旦您是中級或高級MQAdmin,則可以嘗試使用大小寫混合的名稱。

DEFINE CHANNEL(LOCAL.DEF.SVRCONN)CHLTYPE(clntconn)+ CONNAME(127.0.0.1)+ QMNAME(LocalQM)+ SCYEXIT('mqccred(ChlExit)')+替換

第一個問題:如果不在MQ對象名的兩邊加上引號,則MQ會自動將其大寫! 因此,MQ將針對LOCALQM而不是LocalQM看到您的命令。

第二個問題是您沒有為CONNAME指定端口號。 因此,MQ將默認為1414 但是您說您正在使用端口# 1415

而且,如果您不知道,MQ對象名稱是區分大小寫的。

如果您是我,我將刪除隊列管理器LocalQM並從LOCALQM重新開始,並創建所有具有大寫名稱的MQ對象。

使用CCDT不需要登錄憑據,這是使用CCDT的目的之一。

CCDT條目僅包含連接信息。 它們將永遠不會包含用戶/應用程序憑據。 要指定用戶/應用程序憑據,請在應用程序中指定它們,或使用mqccred客戶端安全性出口。

在當今時代,每個用戶和每個應用程序都應指定用戶憑據,以便我們可以擁有一個安全的MQ環境。


更新2018年4月23日

退出庫的體系結構與流程的體系結構不符。

體系結構是指程序的可尋址性或程序的運行框架。 它是作為32位還是64位程序運行。 如果它作為32位程序運行,則需要使用32位mqccred.dll,如果它作為64位程序運行,則需要使用64位mqccred.dll。

我似乎記得關於.NET托管模式(MQC.TRANSPORT_MQSERIES_MANAGED)程序不能使用本機生成的退出的某些信息。 您應該詢問IBM支持。

CCDT的使用並不能消除向隊列管理器證明身份的需要。 您出現的第一個錯誤是因為默認情況下,MQ需要管理員用戶密碼。

通過網絡進行客戶端連接的CONNAUTH分為四個級別:

  1. CHCKCLNT(REQDADM)這是默認值。 具有MQ管理權限的任何用戶都必須提供有效的密碼。 此外,任何沒有管理權限的用戶提供密碼都必須提供有效的密碼。
  2. CHKCLNT(OPTIONAL)這與#1類似,但對於具有MQ管理權限的用戶不需要密碼。 管理員或不提供密碼的任何用戶都必須提供有效的密碼,使用該值,不需要管理員用戶發送密碼。
  3. CHCKCLNT(REQUIRED)此值意味着所有用戶都必須提供有效的密碼。
  4. CHCKCLNT(NONE)不需要用戶提供密碼,即使他們確實提供了密碼也不會被驗證。

您可以設置對整個隊列管理器這個值AUTHINFO設置為對象CONNAUTH上的值QMGR 如果將其設置為REQADMINOPTIONAL ,則可以通過CHLAUTH規則將其針對特定頻道提升到更嚴格的值,例如REQUIRED 您不能將其設置得更低。

如果禁用安全性,則沒有安全性,任何有權訪問您的網絡的人都可以連接到隊列管理器。

您可以通過以下幾種方法來保持安全性:

  1. 您可以使用在CLNTCONN上指定的客戶端安全出口來傳遞憑據,例如mqcred。
  2. 您可以將客戶端證書與TLS一起使用,並將其映射到SVRCONN上的MCAUSER。

請注意,基於更新1,您正在指定QMNAME(LocalQM) ,因為在名稱MQ周圍沒有單引號會將其折疊為UPPERCASE並將其設置為LOCALQM

正如Roger指出的那樣,您還沒有在CONNAME上指定端口1415。 您表示對此有問題,如果其中包含()字符,則需要在CONNAME值兩邊加上單引號。


根據您的UPDATE 2進行的注釋(以下摘自已移至“聊天”的評論):

在MQ安裝目錄下,通常在Program FilesProgram Files(x86)您應該找到一個名為Tools\\c\\Samples\\mqccred ,該子目錄應該具有32bit( lib )和64bit( lib64 )的子目錄。 您應該將文件從lib復制到exits目錄,從lib64復制到exits64目錄。

如果您使用的是托管.NET客戶端模式,則只需要一個本地.NET出口即可。通過使用props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);指示不使用該模式props.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);


根據您的評論更新2a

抱歉,我正在使用MQC.TRANSPORT_MQSERIES_MANAGED 我從其他線程復制。 這是否意味着我需要編寫.NET出口?

mqcred不能與托管模式.NET一起使用,要使用出口來提供憑據,您需要在.net中編寫等效憑據。

通過屬性在程序中指定憑據比編寫類似於mqcred的托管模式出口要容易得多。

Roger對“ 在IBM MQ上發送消息:在AccessQueue上掛起 ”的回答提供了一個很好的示例,該示例演示了如何在托管模式下傳遞用戶名和密碼。 您仍然可以從CCDT獲取連接詳細信息。

  if (inParms.ContainsKey("-u")) qMgrProp.Add(MQC.USER_ID_PROPERTY, ((System.String)inParms["-u"])); if (inParms.ContainsKey("-x")) qMgrProp.Add(MQC.PASSWORD_PROPERTY, ((System.String)inParms["-x"])); if ( (inParms.ContainsKey("-u")) && (inParms.ContainsKey("-x")) ) qMgrProp.Add(MQC.USE_MQCSP_AUTHENTICATION_PROPERTY, true); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM