Share via


PassportIdentity.IsAuthenticated

PassportIdentity.IsAuthenticated

Gets a value indicating whether the user is authenticated against a Microsoft® .NET Passport authority.

Syntax

public bool IsAuthenticated [get]

Property value

true if the user has a valid, unexpired .NET Passport Ticket cookie in the caller's domain or has a fresh Ticket on the query string; otherwise, false.

Example

The following C# example checks the IsAuthenticated property and displays a message to the user based upon the user's authentication.

<%@ 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.IsAuthenticated) {
 Response.Write("<br>Welcome. You are authenticated.");
}
else {
 Response.Write("<br>You are not authenticated. Please click Sign In or exit the page.");
}
%>

Remarks

A read-only property. The IsAuthenticated property is similar to the GetIsAuthenticated method. Unlike the GetIsAuthenticated method in which the iTimeWindow parameter can be used to specify the time interval from the last sign-in to the calling domain, there is no iTimeWindow value associated with the IsAuthenticated property. Instead the IsAuthenticated property uses the site-wide values specified in the Passport Manager Administration utility to determine a user's authentication status.

The IsAuthenticated property will be returned for any user.

See Also

Passport PassportIdentity Object | PassportIdentity.GetIsAuthenticated | PassportIdentity.TicketAge