Hi all - I've been tasked with creating a excel report that connects to our TM1 production server that uses Integrated Login security. On development I was able to use the N_CONNECT function because we have a lower security. However for production I'm using the following code which runs but it doesn't connect to the server.
Declare Function TM1SystemServerConnectIntegratedLogin Lib "tm1api.dll" (ByVal hPool As Long, ByVal vServerName As Long) As Long
Declare Function TM1SystemOpen Lib "tm1api.dll" () As Long
Declare Function TM1ValPoolCreate Lib "tm1api.dll" (ByVal hUser As Long) As Long
Declare Function TM1ValIndex Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitIndex As Long) As Long
Declare Function TM1ValString Lib "tm1api.dll" (ByVal hPool As Long, ByVal InitString As String, ByVal MaxSize As Long) As Long
Declare Sub TM1SystemAdminHostSet Lib "tm1api.dll" (ByVal hUser As Long, ByVal AdminHosts As String)
Declare Sub TM1APIInitialize Lib "tm1api.dll" ()
Sub TM1_Connect()
Dim vServer As Long
Dim sServerName As String
Dim pPoolHandle As Long
Dim vServerName, vStringLength As Long
Dim hUser As Long
sServerName = "TDPlan_Prod"
hUser = TM1SystemOpen()
pPoolHandle = TM1ValPoolCreate(hUser)
vStringLength = TM1ValIndex(pPoolHandle, 11)
vServerName = TM1ValString(pPoolHandle, sServerName, vStringLength)
vServer = TM1SystemServerConnectIntegratedLogin(pPoolHandle, vServerName)
End Sub
Does anyone have any ideas why my code isn't connecting?
Dim hUser As Long
Dim hPool As Long
Dim vServerName As Long
Dim vStringLength As Long
Dim hServer As Long
TM1APIInitialize
hUser = TM1_API2HAN
TM1SystemAdminHostSet hUser, "YourAdminHost"
hPool = TM1ValPoolCreate(hUser)
vStringLength = TM1ValIndex(hPool, 10)
vServerName = TM1ValString(hPool, "YourTM1InstanceName", vStringLength)
hServer = TM1SystemServerConnectIntegratedLogin(hPool, vServerName)
It works for me, provided you run the script from an account in TM1.
'ENABLE THE CODE TO USE THE EXCEL TM1 HANDLE - SAVES LOGGING IN AGAIN
'(This function does not appear in the standard tm1api module supplied
' by Applix / Cognos / IBM. Added by Alan Kirk, 15-Jan-10.)
Declare Function TM1_API2HAN Lib "tm1.xll" () As Long
I attached the code to a Button and after clicking it, checked the server connections in Server Explorer and confirmed it logged me in.
I had added the declare statement before the subroutine that is supposed to be establishing the connection to TM1 but it still didn't work. I believe my problem might be with these two lines:
I've been using my username as "YourAdminHost" and the TM1 server I'm wanting to connect to as the "YourTM1InstanceName". Is this incorrect? I've just recently started learning and using TM1 so my knowledge is not as advanced as I wish it was.
schavarr wrote: ↑Fri Jul 21, 2017 2:19 pm
I had added the declare statement before the subroutine that is supposed to be establishing the connection to TM1 but it still didn't work. I believe my problem might be with these two lines:
I've been using my username as "YourAdminHost" and the TM1 server I'm wanting to connect to as the "YourTM1InstanceName". Is this incorrect? I've just recently started learning and using TM1 so my knowledge is not as advanced as I wish it was.
That's a pretty big stretch to interpret AdminHost as meaning a user name. AdminHost in TM1 is an application that acts as a traffic cop for communications between users and the TM1 Server service. By default this service is installed on the same machine that the TM1 Server service is on. So, you would put the IP address, or FQDN, of that server in this parameter.
Yes that was the part that was causing my issue. I switched out what was in that parameter and it connected. Rookie mistake! Thank you all for your help!!