Clone Portal users, groups and content using 60 trial

2315
15
12-21-2016 07:53 PM
JulianInskip
Occasional Contributor

I am running through the “Clone Portal users, groups and content” sample notebook and I am running into a few issues. My source is an AGOL Subscription and target is a 60 day trial subscription.

1. When I try the copy_user(target, user, ‘TestPassword@123′), it does not want to create the new user (HTTPError: HTTP Error 404: Not Found).

2. When I try and copy the group (tgt_group = copy_group(target, source, group)) I get a runtime error (RuntimeError: Unable to reassign group.
You already have a group named ‘Admin Tools for AGOL’. Try a different name.
(Error Code: 400)
)

It seems as though the problem is if the target portal is a 60 day trial. I went from the 60 day trial to my on-premise portal and it ran fine.

Am I doing something wrong here?
Thanks
Julian.

15 Replies
RohitSingh2
Esri Contributor

Thanks for posting the screenshots. I believe I know what's going on here. Usernames are unique across all organizations in ArcGIS Online. There was already a user in AGOL with username atestuser, which was created on 02 Jul 2014. So the user you think that's being created in your org is actually another user from another org. 

 

It's a bug that gis.users.create() is not erroring out and returning a user with that username that already existed. I've fixed it internally, so the next update would fix it. A workaround would be to use a username with a prefix of _<yourorgname> to prevent such username clashes.

Thanks,

Rohit

RebeccaStrauch__GISP
MVP Emeritus

yes, that "test" family is definitely prolific.  Thank you for submitting a bug since an error message here would have helped.

As suggested, I add _ouragency and the gis.users.serach() now shows that is it added.

I was going to report that it still didn't show up in AGOL, but then I realized that it was inline with the "olduser" name, base on the command.  Now that I understand that, I think I can modify the notebook to get it to do what I want. (and if not, I'll open a new thread).  To make it clear to others, the newusername of "ATestuser_adfg" if is inline with the old user.

0 Kudos
PeterKnoop
MVP Regular Contributor

For those with access to Esri bugs database, it is:

BUG-000102019 When using the Python API to create a user to ArcGIS Online, python code will error out with 404: Not Found Error.

-peter

AlistairFox
Occasional Contributor

is this also the case with group.add_users(list of users). I'm not having any luck passing in a username to an existing AGOL group to add the user.

0 Kudos
RohitSingh2
Esri Contributor

Please note that this bug was fixed in version 1.0.1 released in February. See release notes:

https://developers.arcgis.com/python/guide/release-notes/

  • Fixed bug in creating new users on ArcGIS Online or Portal for ArcGIS 10.5 or newer

The level parameter was added to gis.users.create() call - http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.html#arcgis.gis.UserManager.create

group.add_users(list of users) was failing as a cascase effect of the user not being added. It should work with the fix.

Can you please update and re-try. The issue should be resolved.

AlistairFox
Occasional Contributor

i've confirmed i have 1.01 installed through arcpro python packages

i'm running my code through the arcpro python terminal

when i run this 

if found == 0 :
   print("user not found: " + mUser + " for " + row['title'])
   outkey = group.add_users(mUser)
   print ("user now added to group" + str(outkey))

i get this - user is not added

user not found: canvasseraip01 for PT ASIA INTI PRIMA - Shared
user now added to group {'notAdded': ['P', '0', 'a', '1', 'r', 'c', 's', 'e', 'V'
, 'i', 'n']}

0 Kudos