'GIS' object has no attribute 'admin' while logged in as an admin

1389
11
Jump to solution
10-06-2022 02:42 PM
tslack
by
New Contributor III

Hey there,

I am trying to get a python script working that stops all the services following this

https://support.esri.com/en/technical-article/000019994

I get the general idea but I am getting the error 'GIS' object has no attribute 'admin' when trying to access the servers list. We use Enterprise Logins via SAML with One identity provider.

I am running this

 

from arcgis.gis import GIS
import arcgis.gis.admin

gis = GIS("https://url.domain.ca/portal")
print("Logged in as: " + gis.properties.user.username)
print("Servers: " + gis.admin.servers.list())

 

 Which gives me:

Logged in as: TSlack@CITY
Traceback (most recent call last):
File "<string>", line 6, in <module>
AttributeError: 'GIS' object has no attribute 'admin'

If I run

 

print("Logged in as: " + gis.properties.user.role)

 

it tells me im an org_admin which is correct, my user account as administrator privileges.

Any idea where I am going wrong here? Im using the latest ArcGIS Pro version with all updates. My python version output is below:

 

import sys
import matplotlib
import numpy
import scipy
print(sys.version)
print(matplotlib.__version__)
print(numpy.__version__)
print(scipy.__version__)
3.9.11 [MSC v.1931 64 bit (AMD64)]
3.4.3
1.20.1
1.6.2

 

arcgis API is version 2.0.1

0 Kudos
1 Solution

Accepted Solutions
tslack
by
New Contributor III

The issue had to do with the fact our Enterprise is running 10.6

ESRI Support said "Our 10.6.1 Enterprise deployment built with SAML isn't maintained very well anymore as the product is in mature support. I've tried to bring it back to life but the IDP it leverages no longer exists, and I've been unable to create a new one to test this."

My main goal was getting a script to run that stopped services on Server and I was given a link to https://enterprise.arcgis.com/en/server/10.7/develop/windows/example-stop-or-start-all-services-in-a...

which I was able to modify for my purposes.

View solution in original post

0 Kudos
11 Replies
RogerDunnGIS
Occasional Contributor II

I don't have experience with SAML or One, but the code linked in your example worked for me (where I specify user name and password in the GIS constructor).  It reports that I, too, am an org_admin.  Do you get a result for the following line of code, or does it just throw an exception?

print(type(gis.admin))
# Mine shows <class 'arcgis.gis.admin.portaladmin.PortalAdminManager'>
0 Kudos
tslack
by
New Contributor III

Hey @RogerDunnGIS 

Same result.

 

print(type(gis.admin))
Traceback (most recent call last):
  File "<string>", line 6, in <module>
AttributeError: 'GIS' object has no attribute 'admin'

Problem with SAML/One sign is that I think it prevents me from logging in with a user account I create thats not part of the enterprise so I can't test it with a non SAML account?

 

0 Kudos
RogerDunnGIS
Occasional Contributor II

In a web browser, are you able to navigate to the following URL (using your example)?:

https://url.domain.ca/portal/portaladmin

Also, if and when Python does end up resolving gis.admin, your last print statement won't work.  You can't concatenate (+) a string ("Servers:") with a list (gis.admin.servers.list()).  Rather you may want to write

print("Servers:")
for server in gis.admin.servers.list():
    print(server.name)

or something like that.  I can't remember if name is a property or not.

0 Kudos
tslack
by
New Contributor III

@RogerDunnGIS 

https://url.domain.ca/portal/portaladmin

Resolves fine and I am automatically logged in as my account.

Thanks for the correction on the python there, I still get the exception returned unfortunately.

AttributeError: 'GIS' object has no attribute 'admin'

0 Kudos
by Anonymous User
Not applicable

This is a long shot, but the admin module introduced at 1.2.  What version of arcgis are you using?

print(arcgis.__version__)

The server doesn't have a .name attribute, but you can call the str() on it:

print("Servers: " + (', '.join([str(srv) for srv in gis.admin.servers.list()])))

which puts out a list like:

Servers: <Server at https://site.domain.com:6443/arcgis/admin>, <Server at https://site.domain.biz/citygis/admin>

0 Kudos
tslack
by
New Contributor III

Version is 2.0.1 and that last argument gave me the same error AttributeError: 'GIS' object has no attribute 'admin'

really strange.

0 Kudos
by Anonymous User
Not applicable

Yeah, it will throw the error if .admin isn't found in the GIS module.  We stop/start ours a little differently using the admin server connection if you are interested.

 

0 Kudos
RogerDunnGIS
Occasional Contributor II

I hate to say it, but we community members can only do so much.  If you've got the latest version and you're on maintenance/subscription, you should probably contact technical support, who can help you for free.  They're good at what they do and might be able to solve your issue quicker than we can.  They can also set up screen sharing and what not.  They might be aware of some of the nuances of using the GIS object with SAML and One identity.

0 Kudos
tslack
by
New Contributor III

Appreciate the help. I guess I'll do just that. I'll try to remember to update the thread with a result.

0 Kudos