Skip to content

Data Store Database Password Update via Portal #2527

Open

Description

@djantz

Describe the bug
The following script works for registered databases, as long as they have not been created as an item in Portal. https://support.esri.com/en-us/knowledge-base/how-to-programmatically-update-a-password-change-in-an--000022551. If a Portal item exists, management is required via the Portal item rather than arcgis/admin/data/item/enterpriseDatabases//edit which returns "The data store item can only be managed via Portal". Following the steps in the KB, ds.update() returns False. Attempts to update the Portal item result in the Portal item being updated, but not the Server datastore.

To Reproduce

  1. Register a database. This can be done through ArcGIS Pro (which natively creates a Portal item), or through Manager and then clicking the Create Item button (user profile icon)
  2. Follow steps in above KB article
  3. Observe the ds.update() returns False
  4. Attempt to update the Portal item
item = gis.content.get(<item_id>)
print(item.get_data())
# Replace the connectionString with what was generated from the KB steps
new_data = {"path", "type", "connectionString", etc...}
item.update(data=new_data)
  1. Navigate to the Portal item and settings. View that the Database Connection section shows the updated connectionString info, but the Server section no longer validates.
  2. Navigate to the datastore item in arcgis/admin. View that the connectionString does not match what was updated in Portal.

Screenshots
If applicable, add screenshots to help explain your problem.

Expected behavior
Successful update of datastore when Portal item exists and management is required via Portal.

Platform (please complete the following information):

  • OS: Windows Server 2022
  • Browser: NA
  • Python API Version: 2.4.3

Additional context
Info also posted to https://community.esri.com/t5/arcgis-enterprise-ideas/expose-database-datastore-item-update-password-to/idi-p/1701215

Activity

  1. djantz commented on Jul 16, 2026

    @djantz
    Author

    Just stumbled on this which seems to be the missing "link" between Portal item and Server https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis._impl._datastores.PortalDataStore.refresh_server

    If this checks out, updating the KB with reference to this would be helpful and this bug may be closed.

  2. self-assigned this
    on Jul 16, 2026
  3. kgalliher commented on Jul 16, 2026

    @kgalliher
    Collaborator
  4. kyroskoh commented on Aug 13, 2026

    @kyroskoh

    Workaround: Portal item update + refresh_server

    @djantz’s note about PortalDataStore.refresh_server is the missing sync step. Server Admin /edit (KB 000022551) is blocked when the datastore is Portal-managed, and item.update(data=...) alone does not push credentials to federated servers.

    I put a temporary hotfix on my fork that:

    1. Updates the Portal Data Store item info.connectionString
    2. Calls gis.datastore.refresh_server for each registered server
    3. Optionally validates afterward
    4. Optionally monkey-patches Datastore.update so KB-style scripts fall back to that Portal path when Server returns “managed via Portal”

    Docs (README): https://github.com/kyroskoh/arcgis-python-api/blob/fix/issue-2527-portal-datastore-password/misc/tools/issue_2527/README.md
    Branch: https://github.com/kyroskoh/arcgis-python-api/tree/fix/issue-2527-portal-datastore-password
    Code: misc/tools/issue_2527/

    from misc.tools.issue_2527 import apply, update_password
    
    # Preferred explicit API
    result = update_password(
        gis,
        ds_item,  # Portal Data Store item or item id
        sde_path=r"C:\path\updated.sde",
        server=hosting_server,
    )
    
    # Or keep KB-style ds.update(...) working
    apply(gis)
    ds.update(pro2)

    When Esri releases a fix

    After upgrading to a fixed ArcGIS API for Python (or when a first-class update-password API ships):

    1. Restore the stock method if you used the monkey-patch:
    from misc.tools.issue_2527 import unapply
    unapply()
    1. Remove apply(...) / update_password(...) imports and calls from your scripts.
    2. Use Esri’s supported/fixed path (or Portal UI Update Password).
    3. Optionally delete misc/tools/issue_2527/ (or stop using this fork branch) so the hotfix is not reapplied by mistake.

    This approximates the Portal UI Update Password flow (Manage data store items). Full usage, limits, and references are in the README. Related community idea: https://community.esri.com/t5/arcgis-enterprise-ideas/expose-database-datastore-item-update-password-to/idi-p/1701215

  5. added 3 commits that reference this issue on Aug 13, 2026
  6. kgalliher commented on Aug 13, 2026

    @kgalliher
    Collaborator

    Try this and let us know if the results are what you are expecting.

    from arcgis.gis import (
        GIS,
        ItemProperties,
        ItemTypeEnum,
        SharingLevel
    )
    from utils.logging import enable_verbose_logging
    
    enable_verbose_logging()
    
    # connect to the ArcGIS Enteprise portal using the GIS class
    gis = GIS(
        url="https://organization_url.com/webadaptor_name",
        username="<ORG_ADMIN_USERNAME>",
        password="ORG_ADMIN_PASSWORD"
    )
    
    # use the federation to get Server ids for the 
    # hosting server in the organization's federation
    servers_dict = gis.admin.federation.servers
    server_list = servers_dict["servers"]
    host_id = [srvr["id"] for srvr in server_list if srvr["serverRole"] == "HOSTING_SERVER"][0]
    
    # use the ServerManager to get the hosting server Server object and use the datastores
    # property to get that Server's DatastoreManager
    host = gis.admin.servers.get(role="HOSTING_SERVER")[0]
    host_dsmgr = host.datastores
    
    # assign a variable to the path of the database connection file
    # with the updated credentials
    conn_file_upd = r"/path/to/the/updated/credentials file/updated_egdb_file.sde"
    
    # use the server's DataStoreManager to generate a connection string for the database connection file
    conn_string = host_dsmgr.generate_connection_string(conn_file_upd)
    
    ## create the text parameter for the updated datastore item's text argument
    ## see https://developers.arcgis.com/rest/enterprise-administration/server/data.htm
    ## see https://developers.arcgis.com/rest/enterprise-administration/server/dataitem.htm
    text_param = {"info": {"isManaged": False,
                            "dataStoreConnectionType": "shared",
                            "connectionString": conn_string},
                  "type": "egdb",
                  "path": "/enterpriseDatabases/sql_server_datastore_item"}
    
    # create an ItemProperties object to use for updating the existing datastore 
    # item. Make sure to use the text parameter whose argument is the data item
    # dictionary defined in the step above
    item_props = ItemProperties(
        title= "SqlServer dev0016118 Item API",
        item_type= ItemTypeEnum.DATA_STORE,
        tags= ["api_created", "datastore_item" ,"bulk_publishing"], 
        snippet= "Adding a datastore item to use api for management.",
        text= text_param,
    )
    
    # use the ContentManager to get the existing datastore item's id
    ds_item = gis.content.get("<datastore item id>")
    
    # use the update method with the new ItemProperties object to update the 
    # existing datastore item with the new credentials
    ds_item.update(
        item_properties=item_props
    )
    
    # Get an instance of the PortalDataStore object to manage the datastore item
    p_ds = gis.datastore
    
    # validate the data store item can be connected to before registering
    validation_state = p_ds.validate(
                            server_id=host_id,
                            item=ds_item
    )
    
    # refresh the datastore information on the server side 
    p_ds.refresh_server(
        item=ds_item,
        server_id=host_id
    )
    
    # share the datastore item with the organization
    ds_item.sharing.sharing_level = SharingLevel.ORG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions