I'm trying to help my users migrate between servers. I would like to be able to determine which server and database a layer is pointing to for its data source. We have mxds and layer files numbering in the thousands.
I tried this piece of code from the Help:
if lyr.serviceProperties["ServiceType"] != "SDE":
print "Service Type: " + servProp.get('ServiceType', 'N/A')
print " URL: " + servProp.get('URL', 'N/A')
print " Connection: " + servProp.get('Connection', 'N/A')
print " Server: " + servProp.get('Server', 'N/A')
print " Cache: " + str(servProp.get('Cache', 'N/A'))
print " User Name: " + servProp.get('UserName', 'N/A')
print " Password: " + servProp.get('Password', 'N/A')
print ""
else:
print "Service Type: " + servProp.get('ServiceType', 'N/A')
print " Database: " + servProp.get('Database', 'N/A')
print " Server: " + servProp.get('Server', 'N/A')
print " Service: " + servProp.get('Instance', 'N/A')
print " Version: " + servProp.get('Version', 'N/A')
print " User name: " + servProp.get('UserName', 'N/A')
print " Authentication: " + servProp.get('AuthenticationMode', 'N/A')
print ""
Returns:
Database: maint
Server: KCGIS-AGS10
Service: N/A
Version: sde.DEFAULT
User name: BULLD
Authentication: OSA
For my ArcSDE sourced layers, it returns the name of the ArcMap host for the "Server" property, and "N/A" for the "Service" property even though the layer uses a direct connect sde:sqlserver:gisprod. The workspacePath property of the layer is not reliable because connection files can be named <ANYTHING>.sde and we have at least a dozen ArcSDE servers in the enterprise.