ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortalManager Class
Members Example

In This Topic
    ArcGISPortalManager Class
    In This Topic
    Manages the collection of portals currently defined for Pro. Portals can be added to and removed from the ArcGISPortalManager. The list of portals is shown on the Portals backstage tab.
    Object Model
    ArcGISPortalManager ClassArcGISPortal ClassArcGISPortalManager ClassArcGISPortal ClassArcGISPortal ClassArcGISPortal Class
    Syntax
    public class ArcGISPortalManager 
    Public Class ArcGISPortalManager 
    Remarks
    ArcGISPortalManager is a singleton. It is accessed via its Current property.
    Out of the box you will always have a portal entry defined for arcgis.com (ArcGIS Online). This portal entry cannot be deleted.
    Example
    ArcGISPortalManager: Get the Current Active Portal
    var active_portal = ArcGISPortalManager.Current.GetActivePortal();
    string uri = active_portal.PortalUri.ToString();
    
    ArcGISPortalManager: Get a list of all your Portals
    var portals = ArcGISPortalManager.Current.GetPortals();
    //Make a list of all the Uris
    var portalUris = portals.Select(p => p.PortalUri.ToString()).ToList();
    
    ArcGISPortalManager: Add a portal to the list of portals
    var portalUri = new Uri("http://myportal.esri.com/portal/", UriKind.Absolute);
    ArcGISPortalManager.Current.AddPortal(portalUri);
    
    ArcGISPortalManager: Get a portal and Sign In, Set it Active
    //Find the portal to sign in with using its Uri...
    var portal = ArcGISPortalManager.Current.GetPortal(new Uri(uri, UriKind.Absolute));
    if (!portal.IsSignedOn())
    {
      //Calling "SignIn" will trigger the OAuth popup if your credentials are
      //not cached (eg from a previous sign in in the session)
      if (portal.SignIn().success)
      {
        //Set this portal as my active portal
        ArcGISPortalManager.Current.SetActivePortal(portal);
      }
    }
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Core.ArcGISPortalManager

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also