Select to view content in your preferred language

gis.users.search - Exception: User does not exist or is inaccessible.

243
2
Jump to solution
10-30-2024 01:58 AM
ÅsaBlomberg
Occasional Contributor

We want to get a list of all users on Enterprise.

gis = GIS(url="url", username="user", password="pwd", expiration=9999)
users = gis.users.search('*',  max_users=1000)

But we get this error: 
Exception: User does not exist or is inaccessible.
(Error Code: 400)

It works for max_users=10 but not with 100. The login user has Creator and Administrator privileges. Any suggestions how to get around this error?

0 Kudos
1 Solution

Accepted Solutions
HenryLindemann
Esri Contributor

So sometimes you have a corrupt profile or more than 10 000 user accounts in that cases you need to step through the accounts one for one, you can use the code below to get to your user object. Just put it into a try catch if there is something broken

 

user_manager = arcgis.gis.UserManager(gis)
user_account='0123456789ABCDEF AND !_esri'
users_count = user_manager.advanced_search(query=user_account, return_count=True)
    for user_num in range(1, users_count + 1):
            user_dict = user_manager.advanced_search(query=user_account, start=user_num, max_users=1)
            print(f"Checking {user_dict['results'][0].username}")
            user = user_dict['results'][0]

 

Regards
Henry

View solution in original post

2 Replies
HenryLindemann
Esri Contributor

So sometimes you have a corrupt profile or more than 10 000 user accounts in that cases you need to step through the accounts one for one, you can use the code below to get to your user object. Just put it into a try catch if there is something broken

 

user_manager = arcgis.gis.UserManager(gis)
user_account='0123456789ABCDEF AND !_esri'
users_count = user_manager.advanced_search(query=user_account, return_count=True)
    for user_num in range(1, users_count + 1):
            user_dict = user_manager.advanced_search(query=user_account, start=user_num, max_users=1)
            print(f"Checking {user_dict['results'][0].username}")
            user = user_dict['results'][0]

 

Regards
Henry

ÅsaBlomberg
Occasional Contributor

Thank you! It works perfectly 🙂

0 Kudos