AnsweredAssumed Answered

Need to connect as gis admin service account from C#

Question asked by David.Wendelken on Jul 31, 2017
Latest reply on Jul 31, 2017 by David.Wendelken

We recently switched an ESRI webserver to use the https protocol and (unhappily!) discovered that the https://MyEsriUrl/arcgis/rest/services?f=sitemap command did not return data unless the active directory user had the GIS admin privileges.


So, my intended solution to this is to create a C# webservice to receive a parameter of https://MyEsriUrl/arcgis/rest/services?f=sitemap, which will connect to the ESRI webserver using an active directory service account that has the necessary GIS privileges.  It will receive the sitemap info and return it to the user.


(See ) for more details on the original problem.)


There are a bazillion ways to pass security credentials and I just want to use the right way the first time, or at least find it while I still have hair that hasn't been pulled out.  


Here's some sample code:


public XmlDocument GetSiteMap (string url)
  Uri uri = new Uri(url);
  string user = "domain\\user";
  string pwd = "thepassword";
  HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
  // some magic happens here...
  using(HttpWebResponse response = request.GetResponse() as HttpWebResponse)
     // I do my stuff here, no problem at this point.


Here's one approach I used to supply the magic needed:

// some magic happens here...
request.PreAuthenticate = true;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(uri, "Basic", new NetworkCredential(user, pwd));
request.Credentials = credentialCache;

No luck.  If I log on to the computer using the user/pwd and make the sitemap call in the browser I get back sitemap data.  But using the same credentials as above I get back an empty sitemap.