arcpy describe connection properties

04-18-2019 11:38 AM
Occasional Contributor

Database Connection Properties:
   Is Geodatabase?: false
   Authentification Mode: OSA

   user:  Method user does not exist

I am able to return all the above connection properties with my python script except the user property.  I am logged onto our network, and created the sde connection file using operating system authentification.  Should arcpy describe connection properties be returning the user property too?

0 Kudos
5 Replies
MVP Emeritus

The only arcpy reference to list users and sde expects a geodatabase

ListUsers—ArcPy Functions | ArcGIS Desktop 

does that apply? 

Occasional Contributor

Dan,  Thank you.  Maybe it does have to be a geodatabase?  Although I am not using the List Users command.  I am returning a workspace property, as documented here:

0 Kudos
MVP Emeritus

Workspace properties—ArcPy Functions | ArcGIS Desktop yes they show the connected user in the script example

cp = desc.connectionProperties


but  arcpy listuser shows

arcpy.env.workspace = "C:\\MyProject\\admin.sde"

users = arcpy.ListUsers()

id_users = [user.ID for user in users]


So I would also give that a try if you are using the workspace

MVP Emeritus

Seems like I had an issue with ListUsers() a year ago or so.  In our environment, we have to use the SDE user connection in order to get ListUsers() to return a list.  We have two sets of connection files, one for 'SUperUser' the other for 'SDE'.  Notice in line 2 I log on as 'SuperUser' and it fails, while on line 18 as SDE user all is good....

import arcpy
arcpy.env.workspace = r'I:\GIS\ArcSDE\SuperUser\addressing\SLCOad@addressingTEST.sde'
ws = arcpy.env.workspace
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\", line 1066, in ListUsers
    return utils.listofnamedtuples(gp.listUsers(sde_workspace), 'user')
  File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\geoprocessing\", line 510, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Connection information provided was for a non-administrative user

ws = r'I:\GIS\ArcSDE\SdeUser\sde@addressingTEST.sde'
[user(ClientName=u'AD-TCURTIS-###', ConnectionTime=datetime.datetime(2019, 4, 18, 13, 34, 50), ID=417726, IsDirectConnection=True, Name=u'SLCOAD'), user(ClientName=u'AD-TCURTIS-###', ConnectionTime=datetime.datetime(2019, 4, 18, 13, 45, 36), ID=417727, IsDirectConnection=True, Name=u'SLCOAD'), user(ClientName=u'is-jborgione-###', ConnectionTime=datetime.datetime(2019, 4, 18, 15, 59, 37), ID=417728, IsDirectConnection=True, Name=u'SLCOAD'), user(ClientName=u'is-jborgione-###', ConnectionTime=datetime.datetime(2019, 4, 18, 16, 1, 43), ID=417729, IsDirectConnection=True, Name=u'SDE')]
That should just about do it....
MVP Esteemed Contributor

When set to Operating System Authentication (OSA), there is no user property for the database connection because there is no stored user in the database connection.  OSA relies on passing the process credentials to the database to make a connection, while database authentication relies on passing a username and password.