Hi,
I'm trying to clone roles, users and groups from one environment to another one. From document, there is a clone method for roleManager, groupManager and userManager. https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#groupmanager
However, my code failed with message: AttributeError: 'GroupManager' object has no attribute 'clone'
I search examples and all of them use copy method. Any idea?
Thanks!
Solved! Go to Solution.
@NickXu I too was not able to use the clone feature for either the group or roles. The environment I am in has version 10.9.1 Enterprise. Although in my org I use the code listed in https://developers.arcgis.com/python/latest/samples/clone-a-group/#clone-the-group-in-the-target-por... for cloning groups from one org to another. For cloning users from one org to another use the code in URL https://developers.arcgis.com/python/latest/samples/clone-portal-users-groups-and-content-rn/#copy-u...
For cloning a Role, I use the following codeblock:
import arcgis
from arcgis.gis import GIS
# source GIS details
source_gis = GIS(url="portal_url", username="portal admin username", password=input("Enter source GIS password: "))
print("source connected")
# target GIS details
target_gis = GIS(url="portal_url", username="portal admin username", password=input("Enter target GIS password: "))
print("target connected")
# other variables
Role_to_be_created = [<list all role IDS to be cloned>]
# find roles in source env
for roleid in Role_to_be_created:
source_roles = source_gis.users.roles.get_role(roleid)
# Clone Role from one env to another
if not target_gis.users.roles.exists(roleid):
target_role = target_gis.users.roles.create(source_roles.name,
source_roles.description,
source_roles.privileges)
# display the role
print(target_role.name)
print(target_role.privileges)
Note: Ensure to correct the indentation if you plan to use the script.
It seems like you are on an older version of the API which does not have that feature. Try updating per documentation: Install and Setup | ArcGIS API for Python
Hi,
I'm using ArcPro 3.1 with
python 3.916 and
arcgis 2.1.0.2 py39_14 esri
arcgispro 3.1 0 esri
arcpy 3.1 py39_arcgispro_41759 [arcgispro] esri
arcpy-base 3.1 py39_41759 esri
I'll try to update arcgis to:
arcgis 2.3.1 py311_9 esri
Thanks!
Nick
@NickXu I too was not able to use the clone feature for either the group or roles. The environment I am in has version 10.9.1 Enterprise. Although in my org I use the code listed in https://developers.arcgis.com/python/latest/samples/clone-a-group/#clone-the-group-in-the-target-por... for cloning groups from one org to another. For cloning users from one org to another use the code in URL https://developers.arcgis.com/python/latest/samples/clone-portal-users-groups-and-content-rn/#copy-u...
For cloning a Role, I use the following codeblock:
import arcgis
from arcgis.gis import GIS
# source GIS details
source_gis = GIS(url="portal_url", username="portal admin username", password=input("Enter source GIS password: "))
print("source connected")
# target GIS details
target_gis = GIS(url="portal_url", username="portal admin username", password=input("Enter target GIS password: "))
print("target connected")
# other variables
Role_to_be_created = [<list all role IDS to be cloned>]
# find roles in source env
for roleid in Role_to_be_created:
source_roles = source_gis.users.roles.get_role(roleid)
# Clone Role from one env to another
if not target_gis.users.roles.exists(roleid):
target_role = target_gis.users.roles.create(source_roles.name,
source_roles.description,
source_roles.privileges)
# display the role
print(target_role.name)
print(target_role.privileges)
Note: Ensure to correct the indentation if you plan to use the script.