Hi all,
I am creating an asp.net site in c# that has a requirement to offer dropdownlist with contents retrieved from TM1 and limited to only what the user running the page can see when in TM1. I am using the tm1api.dll through the dllimport attribute class created by Brian Agovino which has worked great for me when designing console apps that require TM1 data.
My first issue is that when I run the application on the server, it is not logging in with the TM1SystemServerConnectIntegratedLogin() method. I am using impersonation and have the web application set to use Integrated Windows Authentication with anonymous disabled. I can see that the web app is running under my account when I open the page, but it still does not logon to the TM1 server.
This is the code I am using, which works in console applications and oddly also works when debugging the web application in my local box (using IIS Express with same settings as server)...
Logger.Write("Connecting");
TM1API.SystemFunctions.TM1APIInitialize();
UserHandle = TM1API.SystemFunctions.TM1SystemOpen();
PoolHandle = TM1API.ValueFunctions.TM1ValPoolCreate(UserHandle);
TM1API.AdminHostFunctions.TM1SystemAdminHostSet(UserHandle, serverPC);
IntPtr serverNm = TM1API.ValueFunctions.TM1ValString(PoolHandle, serverTM1, 12);
ServerHandle = TM1API.SystemFunctions.TM1SystemServerConnectIntegratedLogin(PoolHandle, serverNm);
String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Logger.Write("Connected as " + username);
My second issue is that when it does connect through IIS Express on my local box, it fails when retrieving the names of elements in a subset. Again, When I run the same code through a console application, it will retrieve the element names with no issues. I tried kicking the process off in its own thread with the same results.
The code I am using for this is as follows...
int counter = 0;
Logger.Write("# of elements = " + numOfElements.ToString());
for (int i = 1; i <= numOfElements; i++)
{
vElement = TM1API.ObjectFunctions.TM1ObjectListHandleByIndexGet(hElement, hSubset, TM1API.SubsetFunctions.TM1SubsetElements(), TM1API.ValueFunctions.TM1ValIndex(hElement, i));
vElement = TM1API.ValueFunctions.TM1ValPoolGet(hElement, i - 1);
if (TM1API.ValueFunctions.TM1ValObjectCanRead(this.UserHandle, vElement) == 1)
{
arrCurrentElement[counter] = i - 1;
counter++;
}
}
List<string> testing = new List<string>();
Logger.Write("# of elements I have access to = " + counter.ToString());
try
{
for (int i = 0; i < counter; i++)
{
vElement = TM1API.ValueFunctions.TM1ValPoolGet(hElement, arrCurrentElement);
IntPtr elementName = TM1API.ObjectFunctions.TM1ObjectPropertyGet(hElementName, vElement, TM1API.ObjectFunctions.TM1ObjectName());
vElement = TM1API.ValueFunctions.TM1ValPoolGet(hElementName, i);
Logger.Write("Trying to get value");
StringBuilder test = TM1API.ValueFunctions.TM1ValStringGet(this.UserHandle, vElement);
if (test != null)
{
testing.Add(test.ToString());
Logger.Write("it worked! - " + test.ToString());
}
else
{
Logger.Write("Did not find a value");
}
}
}
catch (Exception ex)
{
Logger.Write(ex.ToString());
throw;
}
Thanks in advance for any help on this!
- Chet
TM1API.dll/asp.net Integrated login and valStringGet issues
-
- Posts: 4
- Joined: Wed Oct 24, 2012 7:20 pm
- OLAP Product: TM1
- Version: 10.1.1
- Excel Version: 2007