BUG

State of credentials (username & password) property for SDE layers in a map are not updated when using ArcPy mapping methods

Last Published: October 1, 2025

Description

The ArcPy mapping module provides a number of methods that allow changes to a layer's workspace path or data source. These methods include:

MapDocument.findAndReplaceWorkspacePaths
MapDocument.replaceWorkspaces
Layer.findAndReplaceWorkspacePath
Layer.replaceDataSource
Table.findAndReplaceWorkspacePath
Table.replaceDataSource

Replacing the SDE connection properties for layers is a supported workflow. However, in cases where a layer's SDE connection where the credentials (username & password) are in one state (saved/not saved) are being replaced with a connection with a different saved/not saved state, the new state is not honored.

For example, there may be a map with layers originally using an SDE connection where the credential are saved (there is no prompt to enter credentials when opening the map). Replace the layers with a SDE connection where the credentials are not saved. There is an expectation that the next time the map is opened there will be a prompt for credentials - the layer should now be using a connection where this information is not saved. Instead, there is still no prompt for credentials.

Cause

This is a known limitation at ArcGIS 10 when using a local path to the SDE connection file.

For example, the following code does not update credentials:

Code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Data\Sde Map.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Data\MyServer.sde",
r"C:\Data\MyServer Enter Credentials.sde")
mxd.saveACopy(r"C:\Data\Sde Map Output.mxd")
del mxd


Note:
Use bug NIM058538 when referencing this issue.

Workaround

Use a UNC path to point to the new sde connection files. For example:

Code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Data\Sde Map.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\Data\MyServer.sde",
r"\\10FinalXp\Data\MyServer Enter Credentials.sde")
mxd.saveACopy(r"C:\Data\Sde Map Output.mxd")
del mxd

    Article ID: 000010966

    Software:
    • ArcMap

    Get support with AI

    Resolve your issue quickly with the Esri Support AI Chatbot.

    Start chatting now

    Related Information

    Discover more on this topic

    Get help from ArcGIS experts

    Contact technical support

    Start chatting now

    Go to download options