无法使用Cognos TM1 API连接到为CAM(Active Directory挂钩)配置的服务器

时间:2015-10-01 21:19:36

标签: vba active-directory cognos cognos-tm1

是否有连接到使用TM1 API在VBA中使用CAM身份验证的服务器?

我根据此处的答案尝试了以下代码:
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)

但是,这会导致Excel崩溃。

我知道我正在连接到正确的服务器,我知道用户名/密码是正确的,我知道TM1 API也正确安装在我的计算机上。

1 个答案:

答案 0 :(得分:0)

我基于IBM客户支持和我之间的对话提出了这个解决方案。

它需要您添加以下声明函数:

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

登录代码:

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)