EnterpriseResource.GetSelf 方法
取得目前登入的使用者。
命名空間: Microsoft.ProjectServer.Client
組件: Microsoft.ProjectServer.Client (在 Microsoft.ProjectServer.Client.dll 中)
語法
'宣告
<RemoteAttribute> _
Public Shared Function GetSelf ( _
Context As ClientRuntimeContext _
) As EnterpriseResource
'用途
Dim Context As ClientRuntimeContext
Dim returnValue As EnterpriseResource
returnValue = EnterpriseResource.GetSelf(Context)
[RemoteAttribute]
public static EnterpriseResource GetSelf(
ClientRuntimeContext Context
)
參數
Context
類型:Microsoft.SharePoint.Client.ClientRuntimeContextClientRuntimeContext物件。
傳回值
類型:Microsoft.ProjectServer.Client.EnterpriseResource
EnterpriseResource目前登入。
範例
下列範例會取得應用程式使用者的名稱。
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);
}
}
}