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?
Solved! Go to Solution.
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
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
Thank you! It works perfectly 🙂