Determine whether Enterprise Portal or AGOL

421
3
Jump to solution
10-13-2020 04:09 AM
Vidar
by
Occasional Contributor II

Is there a sure fire way to discern whether the users logged in portal is enterprise or AGOL?

I thought about a string test against portalInfo.OrganizationId == "0123456789ABCDEF"

which I believe is always Enterprise - but could this value ever change and as a result break my test?

Or there is portalInfo.PortalName which returns "ArcGIS Enterprise" - but could this be changed too?

Anyway if there is someone who knows more than me, I'm all ears

Simon.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can use either the hostname, name, or the IsPortal flag (true if not AGOL) from PortalInfo:

using this snippet:

protected override async void OnClick()
{
  try
  {
    var portal = ArcGISPortalManager.Current.GetActivePortal();
    //Force login
    if (!portal.IsSignedOn())
    {
      portal.SignIn();
    }
    //If the sign in failed, this will be the default view of the portal
    var portalInfo = await portal.GetPortalInfoAsync();
    MessageBox.Show($@"hostname: {portalInfo.PortalHostName} name: {portalInfo.PortalName} isportal: {portalInfo.IsPortal}");
  }
  catch (Exception ex)
	{
    MessageBox.Show($@"Error: {ex}");
	}
}

View solution in original post

0 Kudos
3 Replies
Vidar
by
Occasional Contributor II

Hi, Can someone from ESRI just give me an idea where to go with this - it would be much appreciated.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can use either the hostname, name, or the IsPortal flag (true if not AGOL) from PortalInfo:

using this snippet:

protected override async void OnClick()
{
  try
  {
    var portal = ArcGISPortalManager.Current.GetActivePortal();
    //Force login
    if (!portal.IsSignedOn())
    {
      portal.SignIn();
    }
    //If the sign in failed, this will be the default view of the portal
    var portalInfo = await portal.GetPortalInfoAsync();
    MessageBox.Show($@"hostname: {portalInfo.PortalHostName} name: {portalInfo.PortalName} isportal: {portalInfo.IsPortal}");
  }
  catch (Exception ex)
	{
    MessageBox.Show($@"Error: {ex}");
	}
}
0 Kudos
Vidar
by
Occasional Contributor II

Thanks Wolf!

0 Kudos