How to script start/stop service, with web-tier authentication?

09-14-2021 12:16 PM
Occasional Contributor III


I have done lots of searching about this but have not found anything in Esri documentation or here in the Community, so I thought I'd see if anyone can help.

My organization is in the midst of a server migration.  In our old ArcGIS Server environment, we had token authentication, but in the new one, we have web-tier authentication.  I am trying to migrate a Python script that rebuilt an address locator in the old environment; the script includes stopping and then starting services, which is necessary for rebuilding the address locator.  I have 2 main problems:

  1. The first problem is that I have no idea how to write Python for web-tier authentication, instead of tokens. I have researched this but haven't found anything.  Any suggestions?
  2. The second problem is that it sounds like it's not possible to stop/start services via a script anymore, at least not as simply as in the past (see: ). 
    • I saw that it is possible to do it with the ArcGIS API for Python, but that it requires that the server be federated ( ). 
    • The involved servers are not federated, unfortunately, but we have other servers that are federated. 
    • Does anyone know how to stop/start services in a script, services that are not on a federated server?

Thanks so much!


2 Replies
Esri Notable Contributor

You can use the requests_ntlm library using the HttpNtlmAuth or HttpNegotiateAuth functions. HttpNtlmAuth requires you to pass in a username and password but HttpNegotiateAuth can simulate a single sign on experience.

For services that are not on a federated Server using IWA, once you know what APIs are responsible for stopping/starting services, you can use the requests library; the samples on their help page are pretty useful. For example, use either function above, then use the auth object in the function:

response =,data=params,auth=auth).text

0 Kudos
Occasional Contributor III

Thank you, Jonathan!  I appreciate your reply.

I don't really know anything about requests and scripting internet-related things (someone else wrote the scripts that I have to work with), so I don't yet understand what those sources are talking about, but I will keep doing research and learning.  You have given me a helpful starting place, with those links and your reply.  Thank you!!

0 Kudos