Looking at this page for getting Workspace Properties I am wondering if there is a simple way to get a Users password from an existing SDE connection on the users machine?

Using the code sample from the aforementioned link, something like this:

desc = arcpy.Describe(r"C:data\Connection to state.sde")
cp = desc.connectionProperties
print("%-12s %s" % ("  Password:", cp.password))

For clarification this is for a custom Python Script Tool that creates a new SDE connection as part of the code. Currently I have the user enter their user name and pword in the tool prompt. If I could however have them simply select an existing database connection on their machine and use the creds from that it would be much simpler and less error prone.

I do not think this presents a security risk because it would only have local application. A user would be accessing their own info to automate a process on their personal machine.

There are both Oracle and SQL Servers, I will put logic into the tool that will differentiate between the two.


You can't, the password is stored encrypted in the connection file and is not exposed as a connection property.

The only properties you can query are listed in the documentation you linked to.

What you could do is either have them input credentials and create a new connection or just reuse the existing connection.

  • That was my assumption but I thought I would put it out there. Thanks. – Simon.y Apr 23 '18 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.