Click or drag to resize

PortalUser Class

Represents a registered user of the portal. Personal details of the user, such as email and groups, are returned only to the user or the administrator of the user's organization. A user is not visible to any other users (except their organization's administrator) if their access setting is set to 'private'.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.PortalPortalUser

Namespace:  Esri.ArcGISRuntime.Portal
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class PortalUser

The PortalUser type exposes the following members.

Properties
  NameDescription
Public propertyAccess
Gets the access level for the user : private, organization or public. If Private , the users descriptive information will not be available and the user name will not be searchable. If Organization, only members of the organization can search for the user and the user's content.
Public propertyCreated
Gets the date and time the user was created.
Public propertyCulture
Gets the default culture for the user.
Public propertyEmail
Gets the email of the user.
Public propertyFavoritesGroupId
Gets the user's favorites group that is created automatically for each user.
Public propertyCode exampleFullName
Gets the full name of the user.
Public propertyGroups
Gets the collection of groups the user belongs to.
Public propertyModified
Gets the date and time the user was last modified.
Public propertyOrganizationId
Gets the id of the organization the user belongs to.
Public propertyPortal
Gets the ArcGIS portal.
Public propertyPrivileges
Gets the fine-grained portal privileges possessed by this user.
Public propertyRole
Gets the user's role in the organization : administrator, publisher or user.
Public propertyTags
Gets the words or short phrases that describe the user.
Public propertyThumbnailUri
Gets the URI of the thumbnail image used for the user.
Public propertyUnits Obsolete.
Gets the user defined units for measurement.
Public propertyUnitSystem
Gets the user defined unit system for measurement.
Public propertyUserDescription
Gets the description or profile of the user.
Public propertyCode exampleUserName
Gets the name of the user.
Top
Methods
  NameDescription
Public methodAddPortalItemAsync(PortalItem)
Adds an item without content asynchronously. This operation is available only to authenticated users.
Public methodAddPortalItemAsync(PortalItem, PortalItemContentParameters)
Adds an item with content asynchronously. This operation is available only to authenticated users.
Public methodAddPortalItemAsync(PortalItem, PortalItemContentParameters, PortalFolder)
Adds an item with or without content asynchronously. This operation is available only to authenticated users.
Public methodAddPortalItemAsync(PortalItem, PortalItemContentParameters, PortalFolder, CancellationToken)
Adds an item with or without content asynchronously. This operation is available only to authenticated users.
Public methodAddToFavoritesAsync(PortalItem)
Adds the given item to the user's favorites group.
Public methodAddToFavoritesAsync(PortalItem, CancellationToken)
Adds the given item to the user's favorites group.
Public methodStatic memberCreateAsync(ArcGISPortal, String)
Initializes a new instance of the PortalUser class from the specified username.
Public methodStatic memberCreateAsync(ArcGISPortal, String, CancellationToken)
Initializes a new instance of the PortalUser class from the specified username.
Public methodCreateFolderAsync(String)
Creates a new folder with the given title in this user's root folder (nested folders are not supported).
Public methodCreateFolderAsync(String, CancellationToken)
Creates a new folder with the given title in this user's root folder (nested folders are not supported).
Public methodDeleteFolderAsync(PortalFolder)
Deletes the specified folder from the portal. The folder must belong to this user. Deleting a folder also deletes all items that it contains.
Public methodDeleteFolderAsync(PortalFolder, CancellationToken)
Deletes the specified folder from the portal. The folder must belong to this user. Deleting a folder also deletes all items that it contains.
Public methodDeletePortalItemAsync(PortalItem)
Deletes a specified portal item asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodDeletePortalItemAsync(PortalItem, CancellationToken)
Deletes a specified portal item asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodCode exampleGetContentAsync
Gets the folders and items that are stored at the user's root folder.
Public methodCode exampleGetContentAsync(String)
Gets portal items stored in the specified folder belonging to this user.
Public methodGetContentAsync(CancellationToken)
Gets the folders and items that are stored at the user's root folder.
Public methodGetContentAsync(String, CancellationToken)
Gets portal items stored in the specified folder belonging to this user.
Public methodGetFavoritesStatusAsync(PortalItem)
Determines whether the given item is in the user's favorites group.
Public methodGetFavoritesStatusAsync(PortalItem, CancellationToken)
Determines whether the given item is in the user's favorites group.
Public methodGetThumbnailDataAsync
Get the thumbnail image data for this portal user.
Public methodGetThumbnailDataAsync(CancellationToken)
Get the thumbnail image data for this portal user.
Public methodMovePortalItemAsync(PortalItem, PortalFolder)
Moves the given portal item to the specified folder asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodMovePortalItemAsync(PortalItem, PortalFolder, CancellationToken)
Moves the given portal item to the specified folder asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodMovePortalItemsAsync(IEnumerablePortalItem, PortalFolder)
Moves the given portal items to the specified folder asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodMovePortalItemsAsync(IEnumerablePortalItem, PortalFolder, CancellationToken)
Moves the given portal items to the specified folder asynchronously. Available to the item's owner and the administrator of the organization to which the owner belongs.
Public methodRemoveFromFavoritesAsync(PortalItem)
Removes the given item from the user's favorites group.
Public methodRemoveFromFavoritesAsync(PortalItem, CancellationToken)
Removes the given item from the user's favorites group.
Top
Examples

WPF

Example Name: CertificateAuthenticationWithPki

Access secured portals using a certificate.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Portal;
using Esri.ArcGISRuntime.Security;
using System;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.CertificateAuthenticationWithPKI
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Certificate authentication with PKI",
        category: "Security",
        description: "Access secured portals using a certificate.",
        instructions: "> **NOTE**: You must provide your own ArcGIS Portal with PKI authentication configured.",
        tags: new[] { "PKI", "X509", "authentication", "certificate", "login", "passwordless", "smartcard", "store" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData()]
    public partial class CertificateAuthenticationWithPKI
    {
        private string _serverUrl = "";

        public CertificateAuthenticationWithPKI()
        {
            InitializeComponent();
        }

        private async Task<Credential> CreateCertCredential(CredentialRequestInfo info)
        {
            // Handle challenges for a secured resource by prompting for a client certificate.
            Credential credential = null;

            try
            {
                // Create an X509 store for reading certificates for the current user.
                var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

                // Open the store in read-only mode.
                store.Open(OpenFlags.ReadOnly);

                // Get a list of certificates that are currently valid.
                X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, true);

                // Prompt the user to select a certificate using the built-in certificate selection UI.
                var selection = X509Certificate2UI.SelectFromCollection(certificates, "Select Certificate",
                    "Select the certificate to use for authentication.", X509SelectionFlag.SingleSelection);

                // Make sure the user chose a certificate.
                if (selection.Count > 0)
                {
                    // Create a new CertificateCredential using the chosen certificate.
                    credential = new Esri.ArcGISRuntime.Security.CertificateCredential(selection[0])
                    {
                        ServiceUri = new Uri(_serverUrl)
                    };
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            // Return the CertificateCredential for the secured portal.
            return credential;
        }

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Store the server url for later reference.
                _serverUrl = PortalUrlTextbox.Text;

                // Configure the challenge handler.
                AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateCertCredential);

                // Create the portal.
                ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(_serverUrl));

                // Update the UI with the logged in user.
                LoggedInUserName.Text = portal.User.FullName;
            }
            catch (HttpRequestException ex)
            {
                if (ex.Message.Contains("404"))
                {
                    MessageBox.Show("404: Not Found");
                }
                else if (ex.Message.Contains("403"))
                {
                    MessageBox.Show("403: Not authorized; did you use the right certificate?");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    MessageBox.Show("Couldn't authenticate. See debug output for details.");
                }
            }
            catch (UriFormatException)
            {
                MessageBox.Show("Couldn't authenticate. Enter a valid URL first.");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                MessageBox.Show("Couldn't authenticate. See debug output for details.");
            }
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.CertificateAuthenticationWithPKI.CertificateAuthenticationWithPKI"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="Enter the URL to a Portal that you have a certificate for:"
                       Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" />
            <TextBlock Text="User: "
                       Margin="5"
                       Grid.Row="3" Grid.Column="0" />
            <TextBlock x:Name="LoggedInUserName" Text="Not logged in"
                       Margin="5"
                       Grid.Row="3" Grid.Column="1" />
            <TextBox x:Name="PortalUrlTextbox" Text="https://portal.yourcompany.com/gis/"
                     Margin="5"
                     Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" />
            <Button Content="Choose certificate" 
                    Margin="5"
                    Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
                    Click="Button_Click" />
        </Grid>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
CertificateAuthenticationWithPkiAccess secured portals using a certificate.
IntegratedWindowsAuthConnect to an IWA secured Portal and search for maps.
SearchPortalMapsFind webmap portal items by using a search term.