共用方式為


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

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

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,   bool fForceLogin,   string strCobrandedArgs,   int iLangID,   bool fSecure,   string strNameSpace,   int iKPP,
   bool bUseSecureAuth)

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.
  • fForceLogin
    Determines how the iTimeWindow parameter is used. If set to true, the Login server will compare iTimeWindow interval against the time since the user last manually signed in. If set to false, 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.
  • fSecure
    Declares whether this method is being called from an HTTPS (SSL) page. If fSecure is true, then the appropriate Graphics Interchange Format (GIF) image will also be served from the .NET Passport domain authority through HTTPS. If fSecure is false, then the link image is served HTTP.
  • strNameSpace
    A namespace to which a user without a .NET Passport is directed 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.
  • bUseSecureAuth
    A Boolean value that declares the secure level with which the Sign-in page will be served. false is the equivalent of secure level 0. true is the equivalent of secure level 10. For more information about the meaning of these secure level values, 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.

<%@ 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;
 bool fForceLogin;
 string strCobrandedArgs;
 int iLangID;
 bool fSecure;
 string strNameSpace;
 int iKPP;
 bool bUseSecureAuth;

 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
fForceLogin = false;        //true to force a sign-in using the password
strCobrandedArgs = null;    //use default values
iLangID = 1033;             //EN/US
fSecure = false;            //not a secure site
strNameSpace = null;        //no separate namespace
iKPP = -1;                  //use default
bUseSecureAuth = false;      //use default. This is not necessarily a secure site.

//LogoTag2 allows the user to sign in or sign out.
Response.Write ("<DIV STYLE = 'position:absolute; right:50px'>" +
  oMgr.LogoTag2(sruURL,iTimeWindow,fForceLogin,strCobrandedArgs,
  iLangID,fSecure,strNameSpace,iKPP,bUseSecureAuth)  + "</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

If strReturnUrl is set to null, the registry default is used and shown in the Passport Manager Administration utility. The strReturnUrl specifies where users return after signing out.

If szCoBrandArgs is set to null, the registry default is used and shown in the Passport Manager Administration utility.

If iLangID is set to null, the registry default is used and shown in the Passport Manager Administration utility. The ILangID is the integer representation of a standard locale ID (LCID). For example, U.S. English (EN/US) is 1033. For a table of the LCIDs, see Localization and .NET Passport Services.

In the preceding example, the LogoTag2 parameters are defined, and then the LogoTag2 method is called. Upon successful 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