Share via


PassportIdentity.Name

PassportIdentity.Name

Gets the name of the current user, which is the Microsoft® .NET Passport Unique ID (PUID).

Syntax

public string Name [get]

Property value

The name of the current user, which is the PUID.

Example

The following C# example gets and displays the Name and HexPUID properties for a user. The two values are identical.

<%@ Page Language="C#"%>
<HTML>
<HEAD><TITLE>Mysample - Exercise - CS</TITLE></HEAD>
<Script language="C#" runat="server">
 string sServer;
 string sthisURL;

 protected void Page_Load(Object src, EventArgs e) {
  sServer = Request.ServerVariables["SERVER_NAME"];
  sthisURL = "https://" + sServer + Request.ServerVariables["SCRIPT_NAME"];
 }
</Script>
<%
//Instantiate a PassportIdentity object.
PassportIdentity oMgr = (PassportIdentity)User.Identity;

//LogoTag2 allows the user to sign in or out.
Response.Write ("<DIV STYLE = 'position:absolute; right:50px'>" + oMgr.LogoTag2(sthisURL,3600,true,null,1033,false,null,-1,false) + "</DIV>");

if (oMgr.GetIsAuthenticated(3600,false,false)) {
 Response.Write("<br>Welcome. You are authenticated.");
 Response.Write("<br>Your name is: " + oMgr.Name);
 Response.Write("<br>Your HexPUID is: " + oMgr.HexPUID);
}
else {
 Response.Write("<br>You are not authenticated. Please click Sign In or exit the page.");
}
%>

Output for an authenticated user will be similar to the following:

Welcome. You are authenticated.
Your name is: 00033FFF803B543F
Your HexPUID is: 00033FFF803B543F 

Remarks

A read-only property. The property returns the name of the currently connected .NET Passport user as a hexadecimal string. This is identical to the approach of getting the MemberIDHigh and MemberIDLow attributes, converting them to hexadecimal values, and concatenating them together. The HexPUID property is identical to the Name property.

The Name property will be returned for any authenticated user. If you attempt to retrieve the Name property of a unauthenticated user, null is returned.

Participating sites can use the PUID to identify a user's record in their databases.

See Also

Passport PassportIdentity Object | PassportIdentity.HexPUID