Hi Guys,
I am using this code to automatically login into ArcGIS portal, it is working perfectly in 2.5.
We have setup new environment to test existing addin with 2.6, repackage with 2.6 nugget and deployed.
The code snippet I am currently using is -
private void ForceLoginToDefinedPortal()
{
var portals = ArcGISPortalManager.Current.GetPortals();
var resultPortal = portals.FirstOrDefault(p => p.PortalUri.Host.Equals(this.Config.DefaultPortal, StringComparison.OrdinalIgnoreCase));
this.ModuleLogManager.LogInfo($"Got registered portal {resultPortal != null}");
try
{
if (resultPortal != null)
{
this.ModuleLogManager.LogInfo($"switch active portal to {this.Config.DefaultPortal}");
ArcGISPortalManager.Current.SetActivePortal(resultPortal);
this.ModuleLogManager.LogInfo($"Start sign in to active portal to {this.Config.DefaultPortal}");
resultPortal.SignIn();
this.ModuleLogManager.LogInfo($"Sign in success to active portal to {this.Config.DefaultPortal}");
}
}
catch (Exception loginExcep)
{
string err = $"login issue {loginExcep.Message}{Environment.NewLine}{loginExcep.StackTrace}";
this.ModuleLogManager.LogError(err);
}
}In 2.6 I got exception and below is the detail log
INFO ||2020-11-12 05:05:47||Username:ProAddinTestUser||Current Login User ProAddinTestUser
INFO ||2020-11-12 05:05:47||Username:ProAddinTestUser||Config App initialized success
INFO ||2020-11-12 05:05:47||Username:ProAddinTestUser||Got registered portal True
INFO ||2020-11-12 05:05:47||Username:ProAddinTestUser||switch active portal to dummyportal.com.au
INFO ||2020-11-12 05:05:47||Username:ProAddinTestUser||Start sign in to active portal to dummyportal.com.au
ERROR ||2020-11-12 05:05:47||Username:ProAddinTestUser||login issue Error HRESULT E_FAIL has been returned from a call to a COM component.
at ArcGIS.Desktop.Internal.Framework.IAGOSignOnService.GetToken(String portalURL)
at ArcGIS.Desktop.Core.ArcGISPortal.SignIn()
at ProConfigurationManager.ForceLoginToDefinedPortal() in
I didn't get any login prompt and got that exception only, the designated portal is using IWA auth.
Any Idea?