PassportIdentity.PassportIdentity
PassportIdentity.PassportIdentity
Initializes a new instance of the PassportIdentity class.
Syntax
public PassportIdentity()
Example
The following C# example displays a message to the user, depending on the authentication status of the user. The example creates the PassportIdentity object.
<%@ Page Language="C#"%> <%@ Import Namespace = "System.Web.Security" %> <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 = Page.Request.Url.ToString(); } </Script> <% //Instantiate a PassportIdentity object. //The first line casts the object to a PassportIdentity. The //second line creates a new PassportIdentity object. //Use either of the following two lines to create the object. PassportIdentity oMgr = (PassportIdentity)User.Identity; //PassportIdentity oMgr = new PassportIdentity(); //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,true,false)) { //Provide a welcome message, with the user's name, for an authenticated user. //Display the AuthenticationType for the authenticated user. Response.Write ("<br>Welcome " + oMgr.GetProfileObject("Firstname") + ". You are authenticated."); } else { //Provide a message to an unauthenticated user. Response.Write ("You are not authenticated. Please click Sign in or exit."); } %>
Remarks
This method is the constructor for the PassportIdentity class. Use either of the means shown in the preceding example to create the object. The first line (PassportIdentity oMgr = (PassportIdentity)User.Identity) casts an Identity object to a PassportIdentity object. The second line (PassportIdentity oMgr = new PassportIdentity()) creates a new PassportIdentity object.
See Also