AnsweredAssumed Answered

Request to Portal for ArcGIS with security IWA

Question asked by amenaesri-co-esridist Employee on Mar 16, 2018

Hello friends, I need your help.

 

I have a request to Portal for ArcGIS with IWA setting. The request working in IE (OK) but not in Google Chrome (Error System.Net.WebException: The remote server returned an error: (401) Unauthorized.).

 

Scenes

 

1. I set the "defaultnetworkcredencial" in the request. The user is granthed on portal.

 

HttpWebRequest webRequest = WebRequest.Create(string.Format("{0}{1}",UserEndpoint,username));
webRequest.PreAuthenticate = true;
webRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
webRequest.UnsafeAuthenticatedConnectionSharing = true;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";

 

 

Result:
Response IE. OK.
Response GC. Error System.Net.WebException: The remote server returned an error: (401) Unauthorized.

 

2. I create a new credential and setting the request.

 

HttpWebRequest webRequest = WebRequest.Create(string.Format("{0}{1}",UserEndpoint,username));
webRequest.UseDefaultCredentials = false;
webRequest.PreAuthenticate = true;
var c = new NetworkCredential("myusername", "mypass", "mydomain");
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(string.Format("{0}{1}", UserEndpoint, username)), "NTLM", c);
webRequest.Credentials = credentialCache;
webRequest.UnsafeAuthenticatedConnectionSharing = true;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";

 

 

Result:
Response in IE. OK.
Response in GC. OK.

I need to use the "defautlcredential" in my app (it also use IWA) that work both IE/GC. Any help is apreciated.


Thank you in advanced.

 

Portal for ArcGIS

Outcomes