vbaactive-directorycognoscognos-tm1

Cannot connect to server configured for CAM (Active directory hook) using the Cognos TM1 API


Is there anyway to connect to a server that uses CAM authentication in VBA using the TM1 API?

I've tried the following code based on the answer found here:
SystemServerCAMSecurityRequired error when authenticating using Cognos

Dim credentials(1 To 3) As Long
credentials(1) = TM1ValString(hPool, Trim(CAMNamespace), 0)
credentials(2) = TM1ValString(hPool, Trim(ClientName), 0)
credentials(3) = TM1ValString(hPool, Trim(ClientPassword), 0)
vCredentials = TM1ValArray(hPool, credentials, 3)
hServer = TM1SystemServerConnectWithCAMNamespace(hPool, vServerName, vCredentials)

However, this causes Excel to crash.

I know I'm connecting to the correct server and I know the usernames / passwords are correct, I know that the TM1 API is installed correctly on my computer as well.


Solution

  • I've come up with this solution based on dialog between IBM customer support and I.

    It requires you add the following declare function:

    Declare PtrSafe Function TM1SystemServerConnectWithCAMNamespace Lib "tm1api.dll" (ByVal hPool As Long, ByVal vServerName As Long, ByVal vCAMArr As Long) As Long
    

    The login code:

    Dim hArray As Long
    Dim lArray(3) As Long
    
    'Login to TM1 using CAM authentication
    hArray = TM1ValArray(hPool, lArray(), 3)
    TM1ValArraySet hArray, TM1ValString(hPool, "DOMANIN_NAME", 0), 1          
    TM1ValArraySet hArray, TM1ValString(hPool, “TM1_USER_NAME”, 0), 2
    TM1ValArraySet hArray, TM1ValStringEncrypt(hPool, “TM1_PASSWORD”, 0), 3
    hServer = TM1SystemServerConnectWithCAMNamespace( _
        hPool, TM1ValString(hPool, "TM1_SERVER_NAME", 0), hArray)