Closed scrumthing closed 4 years ago
When you say "username" I assume you mean the username that is passed to CAM for authentication (normally to AD in a corporate setting)?
If so this isn't really a tm1py question or even a TM1 question. CAM does the authentication with the AD and passed back to TM1 the user ID and session ID token. There's no link between the CAMID and the username. You can retrieve the display caption for the user with the }TM1_DefaultDisplayValue attribute, but again there may, or may not be, any link between the AD username and the display name. Sometimes there may be a rule to derive one from the other, but technically they're not linked and there is no generic way to derive one from the other.
If possible the best way to manage it would be to add a custom attribute to the }Clients dimension to hold the windows username.
Hi,
As @lotsaram suggested, if you see the attribute}TM1_DefaultDisplayValue
populated with the user name for their respective CAMID you are in luck. you can use the below code to get a list of usernames:
from TM1py.Services import TM1Service
with TM1Service(address=ADDRESS, port=PORT, ssl=SSL, user=USER, password=PASSWORD) as tm1:
mdx = """SELECT NON EMPTY {[}Clients].Members} ON ROWS,
NON EMPTY {[}ElementAttributes_}Clients].[}TM1_DefaultDisplayValue]} ON COLUMNS
FROM [}ElementAttributes_}Clients]"""
df = tm1.cubes.cells.execute_mdx_dataframe(mdx, dtype={'Value': str})
client_names = list(df.Value)
print(client_names)
If not follow the below advice from lotsaram and use that attribute in the above mdx
If possible the best way to manage it would be to add a custom attribute to the }Clients dimension to hold the windows username.
Thanks guys. I am actually fine with the friendlyname, which I can get via rest. You pointed me in the right direction and thanks for clarifying the details on CAM. It's not one of my specialties. The attribute is a nice idea but not an option as I am trying to get users from multiple instances and most of them are not administrate by me.
I connect to a TM1 server using CAM and that works fine. Now I want to retrieve the users but I only get the CAM-id. Is there a nice way of getting the usernames instead?