Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

Python Script to find Connections of a Specific User, Group

premc
Level 1
Level 1
Python Script to find Connections of a Specific User, Group

I Have tried Writing down a Script to find out the connections of a User or a specific group in a Dataiku instance. I Could either find out the user Groups in which he is present but couldn't make it to the point to extract the specific connections of this group/user in that Instance.


Operating system used: Windows

0 Kudos
1 Reply
tomas
Neuron
Neuron

Hi, this should give you the relations between users and user groups.

import dataiku
client = dataiku.api_client()
for user in client.list_users():
print(user['login'], ','.join(user.get('groups' ,[])))

Not sure what you mean by connection - if you need to list all the granted Connections in DSS for the particular user you may try:

 

import dataiku
client = dataiku.api_client()
connections = client.list_connections()
def is_allowed_to_use(user_groups):
result = []
for con, condef in connections.items():
for g in user_groups:
if g in condef['allowedGroups']:
result.append(con)
return result
for user in client.list_users():
user_groups = user.get('groups' ,[])
print(user['login'], ','.join(user_groups), is_allowed_to_use(user_groups))