WindowsPrincipal.Identity 属性

定义

获取当前用户的标识。

public:
 virtual property System::Security::Principal::IIdentity ^ Identity { System::Security::Principal::IIdentity ^ get(); };
public override System.Security.Principal.IIdentity Identity { get; }
public virtual System.Security.Principal.IIdentity Identity { get; }
member this.Identity : System.Security.Principal.IIdentity
Public Overrides ReadOnly Property Identity As IIdentity
Public Overridable ReadOnly Property Identity As IIdentity

属性值

当前主体的 WindowsIdentity 对象。

实现

示例

以下示例使用 Identity 对象的 属性 WindowsPrincipal 检索用户的名称。

WindowsPrincipal^ wp = gcnew WindowsPrincipal( WindowsIdentity::GetCurrent() );
String^ username = wp->Identity->Name;
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
string username = wp.Identity.Name;
Dim wp As New WindowsPrincipal(WindowsIdentity.GetCurrent())
Dim username As String = wp.Identity.Name

适用于