Share via


PassportIdentity.LogoTag2(string,int,int,string,int,int,string,int,int)

PassportIdentity.LogoTag2(string,int,int,string,int,int,string,int,int)

Returns an HTML fragment containing an image tag for a Microsoft® .NET Passport link. The image displays either the Sign In or Sign Out IMG source, as appropriate.

Important  This method takes advantage of the .NET Passport authentication capabilities that are built into Microsoft® Windows® XP. If you use this method to generate the Sign In button on a Web page, users who are using Microsoft® Internet Explorer 6 on Windows XP will enter their credentials into the .NET Passport sign-in user interface (UI) that is integrated into the operating system. As a result, any customized cobranding you supply will not be displayed. If you want to ensure that all users sign in using the cobranding-enabled Web UI, use the LogoTag method. For more information, see PassportIdentity.LogoTag.

Syntax

public string LogoTag2(   string strReturnUrl,   int iTimeWindow,   int iForceLogin,   string strCobrandedArgs,   int iLangID,   int iSecure,   string strNameSpace,   int iKPP,
   int iSecureLevel
)

Parameters

  • strReturnUrl
    The return URL to which to return the user upon a successful sign-in or sign-out. Sets the URL of the location to which the Login server should redirect users after they sign in or out. Pass a null reference to indicate that .NET Passport should use the default value specified in the application. The return URL must be fully qualified and point to a named file, not just a root. If fSecure is set to true, this strReturnUrl must be an HTTPS URL.
  • iTimeWindow
    Specifies the interval during which users must have last signed in to the calling domain. Pass -1 to indicate that .NET Passport should use the default value. The value entered for iTimeWindow must be -1, greater than or equal to 20, and less than 2678400 (between 20 seconds and 31 days). This value is used for sign-in only.
  • iForceLogin
    Determines how the iTimeWindow parameter gets used. If set to a value other than 0, the Login server will compare the iTimeWindow interval against the time since the user last manually signed in. If set to 0, then the Login server will compare iTimeWindow against the last time the Ticket was refreshed, either silently or manually.
  • strCobrandedArgs
    Specifies variables to be appended as query string variables to the URL of the participating site's cobranding template script page. Pass a null reference to indicate that .NET Passport should use the Cobrand Args value specified in the Passport Manager Administration utility.
  • iLangID
    Specifies the language to be used for the Sign-in page that is displayed to the user. Pass -1 to indicate that .NET Passport should use the default value specified in the Passport Manager Administration utility.
  • iSecure
    Declares whether this method is being called from an HTTPS (SSL) page. If iSecure is 0, then the appropriate Graphics Interchange File (GIF) image will also be served from the .NET Passport domain authority through HTTPS. If iSecure is set to 0, then the link image is served HTTP.
  • strNameSpace
    A namespace to which a user without a .NET Passport is directed to by the Login server where the user can click the Get a New Passport link that is displayed on the initial Sign-in page. Pass null to indicate that .NET Passport should use the default value.
  • iKPP
    Specifies data collection policies for the purpose of compliance with the parental consent requirements of children's privacy laws, such as the Children's Online Privacy Protection Act (COPPA). Pass -1 to indicate that .NET Passport should use the default value.
  • iSecureLevel
    An integer that declares the secure level with which the Sign-in page will be served. The value may be 0, 10, 100, or -1, which indicates that the default secure level value for the site should be used. For more information about the accepted values for iSecureLevel, see PassportIdentity.GetIsAuthenticated(int,int,int).

Return values

An HTML fragment containing an image tag for a .NET Passport link. If a valid Ticket was found, then the return value is a string for the Sign Out image source and HREF tag. If no Ticket was found, the return value is a string for the Sign In image source and HREF tag.

Example

The following C# example uses the LogoTag2 method to display the Sign In button in the right corner of the page. If the user signs out, it redirects the page to the default.aspx page. If the user signs in, it keeps the user on this page.

<%@ Page Language="C#"%>
<%@ Import Namespace = "System.Web.Security" %>
<HTML>
<HEAD><TITLE>Mysample - LoginUser - CS</TITLE></HEAD>
<Script language="C#" runat="server">
 string sServer;
 PassportIdentity oMgr;
 string sthisURL, sruURL;
 int iTimeWindow;
 int iForceLogin;
 string strCobrandedArgs;
 int iLangID;
 int iSecure;
 string strNameSpace;
 int iKPP;
 int iSecureLevel;

 protected void Page_Load(Object src, EventArgs e) {
  sServer = Request.ServerVariables["SERVER_NAME"];
  oMgr = (PassportIdentity)Context.User.Identity;
  sthisURL = "https://" + sServer + Request.ServerVariables["SCRIPT_NAME"];
  sruURL = "https://" + sServer + "/BriefCS/default.aspx";
 }
</Script>
<%
if (oMgr.IsAuthenticated) {
 //Set the sign-out URL - return to the default.aspx
 sruURL = sruURL;
}
else {
 //Set the sign-in URL - stay on this page
 sruURL = sthisURL;
}

//The parameters are used in the LogoTag2 method
iTimeWindow = 300;        //a time window of 300 seconds
iForceLogin = 1;          //1 to force a sign-in using the password
strCobrandedArgs = null;  //use default values
iLangID = 1033;           //EN/US
iSecure = 0;              //not a secure site
strNameSpace = null;      //no separate namespace
iKPP = -1;                //use default
iSecureLevel = -1;      //use default. This is not necessarily a secure site.

//The LogoTag2 allows the user to sign in or sign out.
Response.Write ("<DIV STYLE = 'position:absolute; right:50px'>" +
oMgr.LogoTag2(sruURL,iTimeWindow,iForceLogin,strCobrandedArgs,
iLangID,iSecure,strNameSpace,iKPP,iSecureLevel) + "</DIV>");

if (oMgr.GetIsAuthenticated(3600,false,false)) {
 //You are authenticated, do something for the authenticated user.
 Response.Write ("Hello " + oMgr.GetProfileObject("Firstname"));
 Response.Write ("<br>Your unique identifier (PUID) is; " + oMgr.HexPUID);
}
else {
 Response.Write ("You have not been authenticated within the last hour. Please sign in or exit.");
} // End if GetIsAuthenticated
%>
</HTML>

Remarks

The LogoTag2 image is the appropriate sign-in or sign-out image that contains a link to the .NET Passport sign-in or sign-out URL. The link image displays either Sign In if no valid Ticket cookie is detected, or Sign Out if a valid Ticket cookie is detected.

The LoginUser method logs the user as an authenticated .NET Passport client. This method initiates the sign-in process which requires the user to sign in using the e-mail address and password. If the user is already signed in, no additional sign-in is required. Upon sign-in, the user is redirected to the default return URL specified in the Passport Manager Administration utility.

If strReturnUrl is set to null, the return URL is set to the registry default. The strReturnUrl specifies where users return after signing out if the LogoTag2 link is a sign-out link, but can only do so if no default logout URL is specified in the site registration.

The iLangID is the integer representation of a standard locale ID (LCID). For example, U.S. English (EN/US, the default) is 1033. For a table of LCIDs, see Localization and .NET Passport Services.

In the preceding example, the LogoTag2 parameters are defined, and then the LogoTag2 method is called. Upon a satisfactory sign-in, the user's first name is displayed, if the user has allowed the first name to be shared when the .NET Passport Profile was edited. The user's .NET Passport Unique ID (PUID) is then displayed.

The LogoTag2 method returns the sign-out .gif if the user is signed in and the sign-in .gif if the user is signed out. In the preceding example, the .gif is displayed in the upper-right corner of the page.

Unlike the LoginUser method of the PassportIdentity object, LogoTag2 does not have an oExtraParams parameter to override the default Cobrand Instruction Text specified during site registration.

See Also

Passport PassportIdentity Object