arcpy describe connection properties

4552
5
04-18-2019 11:38 AM
ChrisWiebke
Regular Contributor

Database Connection Properties:
   Server: 
   Instance: 
   Database:
   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
DanPatterson_Retired
MVP Emeritus

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

ListUsers—ArcPy Functions | ArcGIS Desktop 

does that apply? 

ChrisWiebke
Regular 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:  https://pro.arcgis.com/en/pro-app/arcpy/functions/workspace-properties.htm

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

cp = desc.connectionProperties

cp.user

but  arcpy listuser shows

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

users = arcpy.ListUsers()

id_users = [user.ID for user in users]

print(id_users)

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

JoeBorgione
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
arcpy.ListUsers(ws)
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\__init__.py", line 1066, in ListUsers
    return utils.listofnamedtuples(gp.listUsers(sde_workspace), 'user')
  File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\geoprocessing\_base.py", 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'
arcpy.ListUsers(ws)
[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....
JoshuaBixby
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.