EnterpriseResource.GetSelf method

Gets the currently logged-on user.

Namespace:  Microsoft.ProjectServer.Client
Assembly:  Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)

Syntax

'Declaration
<RemoteAttribute> _
Public Shared Function GetSelf ( _
    Context As ClientRuntimeContext _
) As EnterpriseResource
'Usage
Dim Context As ClientRuntimeContext
Dim returnValue As EnterpriseResource

returnValue = EnterpriseResource.GetSelf(Context)
[RemoteAttribute]
public static EnterpriseResource GetSelf(
    ClientRuntimeContext Context
)

Parameters

Return value

Type: Microsoft.ProjectServer.Client.EnterpriseResource
The EnterpriseResource who is currently logged on.

Examples

The following example gets the name of the application user.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;

namespace WhoAmI
{
    class Program
    {
        private const string pwaPath = "https://ServerName/pwa/"; // Change the path for your Project Web App.
        private static ProjectContext projContext;
       
        static void Main(string[] args)
        {
            projContext = new ProjectContext(pwaPath);

            // Load the application user, who must be an enterprise resource.
            EnterpriseResource self = EnterpriseResource.GetSelf(projContext);
            projContext.Load(self);
            projContext.ExecuteQuery();

            Console.WriteLine("I am: {0}", self.Name);

            Console.Write("\nPress any key to exit: ");
            Console.ReadKey(false);
        }
    }
}

See also

Reference

EnterpriseResource class

EnterpriseResource members

Microsoft.ProjectServer.Client namespace