Page 1 of 1

VBA code for Integrated Login

Posted: Tue Feb 24, 2009 2:10 pm
by eyalfluk
Hello,
I have often used this piece of vb code for connecting to TM1 from an Excel application (using TM1 Dll functions):

Public Function Connect(AdminHost As String, ServerName As String, UserName As String, Password As String) As Long
Dim hUser As Long
Dim hServer As Long

hUser = TM1SystemOpen()
TM1SystemAdminHostSet hUser, Trim(AdminHost)
hServer = TM1SystemServerConnect(hUser, Trim(ServerName), Trim(UserName), Trim(Password))
Connect = hUser
End Function

Now I need to connect to a server configured with:
IntegratedSecurityMode = 3

The Connect function doesn't work for this situation.
Do you have any solution for this?

Thanks in advance,
Eyal Fluk
Biconix Intl.

Re: VBA code for Integrated Login

Posted: Tue Feb 24, 2009 2:50 pm
by Renaud MARTIAL
Eyal,

the API documentation indicates that it is not possible :(
NOTE: If your server is set up to accept only integrated login
(IntegratedSecurityMode=3), you cannot log in to the TM1 server using the
API. If your server is set up to use integrated security exclusively, set the
IntegratedSecurityMode setting to 2, and establish a user in the TM1 security
system specifically for the API. For additional information on TM1
authentication, see the TM1 Security Guide.
Regards,

Renaud.

Re: VBA code for Integrated Login

Posted: Tue Feb 24, 2009 4:00 pm
by David Usherwood
Hmmmm.
I've been working recently with IL (mainly patching round the unusable, poorly documented ETLDAP stuff). With IL, since you don't need to provide a user and password, do you need this code at all? Try just skipping it and 'assuming' you are already logged in. And let the forum know what happened.

Re: VBA code for Integrated Login

Posted: Tue Feb 24, 2009 4:56 pm
by George Regateiro
Though I dont know alot about the VBA piece, but I was told when I inquired about the .NET API that the APIs are still in developement and the Intergrated Login was not included as of this point.

Re: VBA code for Integrated Login

Posted: Tue Feb 24, 2009 6:48 pm
by Bert
Have you tried TM1SystemServerConnectIntegratedLogin?

Declare Function TM1SystemServerConnectIntegratedLogin Lib "tm1api.dll" (ByVal hPool As Long, ByVal sServerName As Long) As Long

Bert.

Re: VBA code for Integrated Login

Posted: Wed Feb 25, 2009 3:08 am
by Gregor Koch
Hi

If you have IntegratedSecurityMode = 2

Application.Run "N_CONNECT", TheServer, "", ""

does the trick (at least on 9.0 SP3 and SP4) . Whereby 'TheServer' is the tm1 server name.

Normally this function needs the user and password but with integrated login it works without it.

There are some minor clitches when you do have the Server Explorer open and you are not connected, subsequently open the report which uses this function which will result in a 'blank' (at least that's what you'll get from the Who Am I) user in the Server Explorer.
Other than that it works just fine.

Hope this helps and works on Mode 3

Cheers

Gregor

Re: VBA code for Integrated Login

Posted: Wed Feb 25, 2009 10:58 pm
by paulsimon
Eyal

I think that the IntegratedLogin bit should only be necessary if you are connecting via the API outside of Excel.

In Excel you can piggy back the connection from Excel to TM1 via a much older API call. I can't remember it off hand, but you will find it if you search the forum, and it is built in to my TM1EasyAPI.

If you are still in the pre-Cognos license model where you need to be concerned about multiple connections from users, then this method has the advantage of not creating another connection, ie it uses the same connection as the one that the user has already established via Excel, and just gets a handle to it.

Regards


Paul Simon

Re: VBA code for Integrated Login

Posted: Wed Mar 09, 2011 4:42 pm
by mce
What if I use IntegratedSecurityMode = 5 ? How do I login using n_connect in this case?
How do I specify the namespace?

Re: VBA code for Integrated Login

Posted: Wed Mar 09, 2011 10:28 pm
by Alan Kirk
PaulSimon wrote: In Excel you can piggy back the connection from Excel to TM1 via a much older API call. I can't remember it off hand,

Code: Select all

Declare Function TM1_API2HAN Lib "tm1.xll" () As Long
It's used in all of TM1Tools' API calls. It's also undocumented, though I have been lobbying, cajoling, pushing and screaming at Iboglix Support to do so for years now. :evil:

They seem to be of the opinion that all API code will involve connecting and disconnecting each time you need to do something, despite the fact that in Excel-based solutions this view is somewhat disconnected from reality.

The biggest potential "gotchas" when using that function are that you must not call either TM1SystemClose or TM1APIFinalize, or you'll destabilise your Excel session and send it crashing into the ground in a flaming heap.