I'm working on some scripts to manage our portal instances. I hit a snag trying to list users and groups they are part of. This simple script should do this, but only provides the username and then an empty list for the 'groups' key?
import portalpy url = 'https://serverfqn.gf.sugf.com:7443/arcgis' portal = portalpy.Portal(url, "ADMINUSER", "PASSWORD") print portal.get_version() uDict = portal.get_org_users() print uDict for u in uDict: print u.get("username") print u.get("groups")
Anyone have any tips on accessing the 'groups' list?
Thanks,
james
Just letting you know I can replicate with my ArcGIS Online account.
I get the usernames fine, but the dictionary has empty groups for all users.
Im new to python let alone portalpy, so afraid I can't offer too much help, but will throw this link at a few others to see if they can.
portal.get_org_users does return a list of users with a list of dictionaries. But, yes the groups part doesn't appear to work.
But what you can do is then use this list to recover each username, then loop through these with portal.get_user("username"), then recover the "groups" key from that.
Portalpy gets some getting your head around, often shuffling between the name of something or its id.
But it is very powerful.