hi,
I am trying to check if a client is assigned to a CAM group or not. For this, I am using TM1ClientGroupIsAssigned function and checking the result by wrapping it with TM1ValBoolGet , but it returns 91 , meaning some parameter has not been passed correctly, I am able to login and run the ti process successfully though.
here's the part of code I am executing, can someone please check what is wrong here
' code
SessionHandle = GetExcelSessionHandle()
pPoolHandle = TM1ValPoolCreate(SessionHandle)
vStringLength = TM1ValIndex(pPoolHandle, 10)
vUserName = TM1ValString(pPoolHandle, userName, vStringLength)
vPassword = TM1ValString(pPoolHandle, Password, vStringLength)
vgroup = TM1ValString(pPoolHandle, "ADMIN", vStringLength)
vServerName = TM1ValString(pPoolHandle, ServerName, vStringLength)
NoParameters = 3
ReDim lArray(NoParameters)
hArray = TM1ValArray(pPoolHandle, lArray(), NoParameters)
TM1ValArraySet hArray, hCAMNameSpace, 1
TM1ValArraySet hArray, vUserName, 2
TM1ValArraySet hArray, vPassword, 3
vServerHandle = TM1SystemServerConnectWithCAMNamespace(pPoolHandle, vServerName, hArray)
hclient = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerClients(), vUserName)
hgroup = TM1ObjectListHandleByNameGet(pPoolHandle, vServerHandle, TM1ServerGroups(), vgroup)
vclientgroup = TM1ClientGroupIsAssigned(pPoolHandle, hclient, hgroup)
MsgBox TM1ValBoolGet(hUser, vclientgroup)
TM1API TM1valboolget returning 91 while checking group
-
- Posts: 18
- Joined: Mon May 09, 2011 3:09 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: EXCEL 2003
- Mike Cowie
- Site Admin
- Posts: 483
- Joined: Sun May 11, 2008 7:07 pm
- OLAP Product: IBM TM1/PA, SSAS, and more
- Version: Anything thru 11.x
- Excel Version: 2003 - Office 365
- Location: Alabama, USA
- Contact:
Re: TM1API TM1valboolget returning 91 while checking group
Hi:
If you're going to use the TM1 API, one thing you'll need to get in the habit of using, along with good debugging skills, is the TM1ValType function. TM1 API functions won't throw errors/stop execution if you get an error/unexpected result from an earlier API function, so to troubleshoot this you should be testing the returned values from some of the other functions you're calling. For example, by checking the returned type of:
VB/VBA (note I've only used the former ANSI function, and not the latter Unicode function):
C:
Which will return the TM1 user name (as TM1 knows it) that you've connected with on the server (based on the index of the server). I realize it's a bit of a head-scratcher, but the TM1SystemServerConnectWithCAMNamespace function insulates you a bit from the actual user name stored for the CAM user in TM1. In other words, I think your userName is not the same as what TM1 actually uses, behind the scenes, for this user.
Again, and I can't stress it enough - TM1ValType is crucial in providing a clearer picture of the problem. Without using that and checking returned value types along the way in your code, it's like mixing cocktails without checking the bottles you're grabbing and then blaming the cocktail shaker because your martini has bubbles and tastes of dish soap.
Regards,
Mike
If you're going to use the TM1 API, one thing you'll need to get in the habit of using, along with good debugging skills, is the TM1ValType function. TM1 API functions won't throw errors/stop execution if you get an error/unexpected result from an earlier API function, so to troubleshoot this you should be testing the returned values from some of the other functions you're calling. For example, by checking the returned type of:
- vclientgroup (should be TM1ValTypeBool)
- hGroup (should be TM1ValTypeObject)
- hClient (should be TM1ValTypeObject)
- ... and so on up the chain
VB/VBA (note I've only used the former ANSI function, and not the latter Unicode function):
Code: Select all
Declare Sub TM1SystemServerClientName_VB Lib "tm1api.dll" (ByVal hUser As Long, ByVal Index As Integer, ByVal res As String, ByVal max As Integer)
Declare Sub TM1SystemServerClientNameW_VB Lib "tm1api.dll" (ByVal hUser As Long, ByVal Index As Integer, ByVal res As String, ByVal max As Integer)
Code: Select all
CHAR * TM1SystemServerClientName( TM1U hUser, unsigned index );
or
TM1_UTF16_T * TM1SystemServerClientNameW( TM1U hUser, unsigned index );
Again, and I can't stress it enough - TM1ValType is crucial in providing a clearer picture of the problem. Without using that and checking returned value types along the way in your code, it's like mixing cocktails without checking the bottles you're grabbing and then blaming the cocktail shaker because your martini has bubbles and tastes of dish soap.
Regards,
Mike
Mike Cowie
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
-
- Posts: 18
- Joined: Mon May 09, 2011 3:09 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: EXCEL 2003
Re: TM1API TM1valboolget returning 91 while checking group
Thanks a Lot Mike,
I finally managed to correct it by creating NAME attruibute in }Clints and }group dimension and using same name which I am passing into the code. It seems that the username which is passed during login is not the same user name which TM1 refers in the function. This is working for in-built TM1 security. Now I would like to make this work for cam security for that I am trying to use proc you suggested: TM1SystemServerClientName_VB but not able to get anything for user name. I am not sure what parameter values to pass in this function.
As per documentation,
"Declare Sub TM1SystemServerClientName_VB
Lib "tm1api.dll" (ByVal hUser As Long, ByVal index As Integer, ByVal
res As String, ByVal max As Integer)
Parameters
hUser is a long. It is user handle returned by the function TM1SystemServerConnect.
index is an integer. This integer is an offset into the list of available servers currently available to the client. These servers are listed in the ADMIN server user interface.
res is a string where the result is returned.
max is an integer indicating the maximum length of a string that can be accepted by res."
Based on this I am calling this function as below, but it returns blank,
Dim ClientName as String * 75
call TM1SystemServerClientName_VB(SessionHandle, 2, ClientName, 75)
MsgBox ClientName
I finally managed to correct it by creating NAME attruibute in }Clints and }group dimension and using same name which I am passing into the code. It seems that the username which is passed during login is not the same user name which TM1 refers in the function. This is working for in-built TM1 security. Now I would like to make this work for cam security for that I am trying to use proc you suggested: TM1SystemServerClientName_VB but not able to get anything for user name. I am not sure what parameter values to pass in this function.
As per documentation,
"Declare Sub TM1SystemServerClientName_VB
Lib "tm1api.dll" (ByVal hUser As Long, ByVal index As Integer, ByVal
res As String, ByVal max As Integer)
Parameters
hUser is a long. It is user handle returned by the function TM1SystemServerConnect.
index is an integer. This integer is an offset into the list of available servers currently available to the client. These servers are listed in the ADMIN server user interface.
res is a string where the result is returned.
max is an integer indicating the maximum length of a string that can be accepted by res."
Based on this I am calling this function as below, but it returns blank,
Dim ClientName as String * 75
call TM1SystemServerClientName_VB(SessionHandle, 2, ClientName, 75)
MsgBox ClientName
- Mike Cowie
- Site Admin
- Posts: 483
- Joined: Sun May 11, 2008 7:07 pm
- OLAP Product: IBM TM1/PA, SSAS, and more
- Version: Anything thru 11.x
- Excel Version: 2003 - Office 365
- Location: Alabama, USA
- Contact:
Re: TM1API TM1valboolget returning 91 while checking group
Hi:
The reason the actual TM1 client differs from the user you type in is because TM1 chooses to store the CAM ID for the user in }Clients, probably to make it unique to TM1 and not overlap with native TM1 logins or some other reason - the TM1SystemServerConnectWithCAMNamespace insulates you from this so that you don't have to enter in something like: CAMID("asda-asda-sd-as-afqfwf-13afa"). I think TM1 also adds an alias of Namespace\User to }Clients, and I would imagine that's what gets returned if you're using a function like TM1USER.
Anyway, I took a look back at my notes on this and it looks like CAM login names don't get returned by that older SystemServerClientName function (sorry about leading you down that path). I've contacted IBM support about that this morning, since I think that function should continue to work.
In the meantime, I think you instead need to check these server properties (once you've established a connection to the server):
For example:
Each one of these properties should return a handle to a string, but you'll want to check using TM1ValType as mentioned below to make sure you aren't getting back an error. I would imagine one of these properties will get you the raw TM1 user ID you're looking for.
Regards,
Mike
The reason the actual TM1 client differs from the user you type in is because TM1 chooses to store the CAM ID for the user in }Clients, probably to make it unique to TM1 and not overlap with native TM1 logins or some other reason - the TM1SystemServerConnectWithCAMNamespace insulates you from this so that you don't have to enter in something like: CAMID("asda-asda-sd-as-afqfwf-13afa"). I think TM1 also adds an alias of Namespace\User to }Clients, and I would imagine that's what gets returned if you're using a function like TM1USER.
Anyway, I took a look back at my notes on this and it looks like CAM login names don't get returned by that older SystemServerClientName function (sorry about leading you down that path). I've contacted IBM support about that this morning, since I think that function should continue to work.
In the meantime, I think you instead need to check these server properties (once you've established a connection to the server):
Code: Select all
Declare Function TM1ServerClientName Lib "tm1api.dll" () As Long
Declare Function TM1ServerClientDisplayName Lib "tm1api.dll" () As Long
Declare Function TM1ServerIntegratedClientName Lib "tm1api.dll" () As Long
Code: Select all
ClientNameHandle = TM1ObjectPropertyGet(YourValPoolHandle, YourConnectedServerHandle, TM1ServerClientName)
ClientDisplayNameHandle = TM1ObjectPropertyGet(YourValPoolHandle, YourConnectedServerHandle, TM1ServerClientDisplayName)
IntegratedClientNameHandle = TM1ObjectPropertyGet(YourValPoolHandle, YourConnectedServerHandle, TM1ServerIntegratedClientName)
Regards,
Mike
Mike Cowie
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
-
- Posts: 18
- Joined: Mon May 09, 2011 3:09 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: EXCEL 2003
Re: TM1API TM1valboolget returning 91 while checking group
Thanks a lot - Mike, this is working fine now.
- Mike Cowie
- Site Admin
- Posts: 483
- Joined: Sun May 11, 2008 7:07 pm
- OLAP Product: IBM TM1/PA, SSAS, and more
- Version: Anything thru 11.x
- Excel Version: 2003 - Office 365
- Location: Alabama, USA
- Contact:
Re: TM1API TM1valboolget returning 91 while checking group
Quick Note:
TM1SystemServerClientName_VB seems to work just fine for me when I tested them against Cognos Security logins in TM1 10.1 and CX 9.5. I think at one stage it may not have worked properly in a much earlier TM1 version, but it appears to return exactly the same thing that the TM1USER Excel/Rule/TI function does (the raw }Clients element name).
Those Server properties for client names that I mentioned in this thread may still be of use if you're looking for other attributes of users in TM1.
Regards,
Mike
TM1SystemServerClientName_VB seems to work just fine for me when I tested them against Cognos Security logins in TM1 10.1 and CX 9.5. I think at one stage it may not have worked properly in a much earlier TM1 version, but it appears to return exactly the same thing that the TM1USER Excel/Rule/TI function does (the raw }Clients element name).
Those Server properties for client names that I mentioned in this thread may still be of use if you're looking for other attributes of users in TM1.
Regards,
Mike
Mike Cowie
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
QueBIT Consulting, LLC
Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!