Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Python API to get the list of login users from Administration/Security/Users

Solved!
Dominic-S
Level 3
Python API to get the list of login users from Administration/Security/Users

Hi,

  Is there a way to use Dataiku's Python API to get the list of login users info (Login, Type, Groups, etc) posted in Administration/Security/Users?

  Thanks,

0 Kudos
1 Solution
MiguelangelC
Dataiker

Hi,

You can indeed use the Python API to access user related information.

There is a specific section for users and groups that you can check here: https://developer.dataiku.com/latest/api-reference/python/users-groups.html#users-and-groups

For example:

import dataiku
client=dataiku.api_client()
users=client.list_users()
for i in users:
    print("----------")
    myuser=client.get_user(i['login'])
    print("Login name: ",i['login'])
    print("Display name: ",i['displayName'])
    print("Type: ",i['sourceType'])
    try: print("Email: ",i['email'])
    except: print("Email: N/A")
    print("Groups :",i['groups'])
    print("Last successful login: ", myuser.get_activity().last_successful_login)

Feel free to modify this example snippet to suit your business requirements. Please note that depending on your DSS version the exact commands syntax may vary.

View solution in original post

0 Kudos
5 Replies
MiguelangelC
Dataiker

Hi,

You can indeed use the Python API to access user related information.

There is a specific section for users and groups that you can check here: https://developer.dataiku.com/latest/api-reference/python/users-groups.html#users-and-groups

For example:

import dataiku
client=dataiku.api_client()
users=client.list_users()
for i in users:
    print("----------")
    myuser=client.get_user(i['login'])
    print("Login name: ",i['login'])
    print("Display name: ",i['displayName'])
    print("Type: ",i['sourceType'])
    try: print("Email: ",i['email'])
    except: print("Email: N/A")
    print("Groups :",i['groups'])
    print("Last successful login: ", myuser.get_activity().last_successful_login)

Feel free to modify this example snippet to suit your business requirements. Please note that depending on your DSS version the exact commands syntax may vary.

0 Kudos
Dominic-S
Level 3
Author

Thanks, that is exactly what I am looking for.

0 Kudos
marwa
Level 1

it doesnt work for me , i have this error :

AttributeError: type object 'datetime.datetime' has no attribute 'datetime'

 

0 Kudos
Turribeach

Add this:

import datetime
0 Kudos
marwa
Level 1

hi , i already added import datetime

here my code

import dataiku
import datetime
client=dataiku.api_client()
users=client.list_users()
for i in users:
print("----------")
myuser=client.get_user(i['login'])
print("Login name: ",i['login'])
print("Display name: ",i['displayName'])
print("Type: ",i['sourceType'])
try: print("Email: ",i['email'])
except: print("Email: N/A")
print("Groups :",i['groups'])
print("Last successful login: ", myuser.get_activity().last_successful_login)

0 Kudos