Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on September 15, 2023 8:31AM
Likes: 0
Replies: 4
I want to find out who are the members of a given group , how do I do that?
In the DSS > Administration > Security > Users, I can see each user and the groups they belong to, but that will require me to go user by user , looking if they are in a group or not.
DSS > Administration > Security > Groups > doesn't seem to show the member of each group.
I looked into dsscli but I can't find a command there to show the members of a given group,
I guess I could use the REST API to list all users, get the info of each user, and compute the group membership myself but is that really the only option that I have?
Hi,
You can indeed use the DSS Python API to get this information and format it to your business requirements.
Nevertheless, from the DSS UI you can filter the users list based on group names. See for example:
Run this on a Jupyter Notebook and you can download a CSV with all your users and their groups:
import dataiku import pandas as pd, numpy as np from dataiku import pandasutils as pdu import base64 from IPython.display import display, HTML client = dataiku.api_client() users_list = client.list_users() df_user_groups = pd.DataFrame(columns=['user_id', 'group_name']) for user in users_list: for group in user['groups']: data_record = pd.DataFrame.from_dict({'user_id': [user['login']], 'group_name': [group]}) df_user_groups = pd.concat([df_user_groups, data_record], ignore_index=True) def create_download_link( df, title = "Download CSV file", filename = "dataiku_user_groups.csv"): csv = df.to_csv() b64 = base64.b64encode(csv.encode()) payload = b64.decode() html = '<a download="{filename}" href="data:text/csv;base64,{payload}" target="_blank">{title}</a>' html = html.format(payload=payload,title=title,filename=filename) return HTML(html) create_download_link(df_user_groups)
Add to a Python recipe and you can create a dataset with it for easy exploring. You could also create a WebApp that displays them.
i tried this code , but have this error :
My bad, it was missing an import, added it now:
from IPython.display import display, HTML