2

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.

Community
  • 1
  • 1
Doctor Parameter
  • 1,202
  • 2
  • 15
  • 21
  • Don't have Cognos in my environment to test, but what's `hPool`? Does `TM1ValString` really returns a Long data type? At which line Excel crashes on (step through it)? – PatricK Oct 01 '15 at 23:57
  • hPool is the reference to the connection, the way the API works is that all function calls return what is effectively a pointer (I'm assuming) that is represented as a long. You can then use another function to grab the actual values. If you would like I can create a more complete example. – Doctor Parameter Oct 08 '15 at 19:02
  • Thanks for explaining Blake. There is no need for more complete example as there won't be any cognos server in the workplace. Wish you luck getting it sorted. – PatricK Oct 08 '15 at 22:09

1 Answers1

0

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)       
Doctor Parameter
  • 1,202
  • 2
  • 15
  • 21