Share via


PassportIdentity.CryptPutSite

PassportIdentity.CryptPutSite

Sets the key being used for Microsoft® .NET Passport encryption and decryption by referring to the site-name label assigned to that key when the key was first installed.

Syntax

public static int CryptPutSite( string strSite )

Parameters

  • strSite
    The site label.

Return values

An integer result code. Returns 0 upon successful completion of the method.

Example

The following C# example sets the keys for the alternate site, site #22610.

<%@ Page Language="C#"%>
<%@ Import Namespace = "System.Web.Security" %>
<HTML>
<HEAD><TITLE>Mysample - Exercise - CS</TITLE></HEAD>
<Script language="C#" runat="server">
 string sServer;
 PassportIdentity oMgr;
 string sthisURL, sruURL;

 protected void Page_Load(Object src, EventArgs e) {
  sServer = Request.ServerVariables["SERVER_NAME"];
  oMgr = (PassportIdentity)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.asp
 sruURL = sruURL;
}
else {
 //Set the sign-in URL - stay on this page
 sruURL = sthisURL;
}

Response.Write ("<DIV STYLE = 'position:absolute; right:50px'>" + oMgr.LogoTag2(sruURL,3600,true,null,1033,false,null,-1,false) + "</DIV>");

if (oMgr.GetIsAuthenticated(3600,false,false)) {
 //User has been authenticated within the last hour. Load the alternate key.
 //If the alternate key is not loaded, the site will
 //be GetCurrentConfig("SiteID").
 PassportIdentity.CryptPutSite("22610");
}
else {
 Response.Write ("<br>You have not been authenticated within the last hour. Please sign in or exit.");
} // End If GetIsAuthenticated
%>
</HTML>

Remarks

The site name should match the site name used for configuration settings in the Passport Manager Administration utility. This method should be used only if your site has multiple keys installed because there are multiple sites being served by common PassportIdentity installations.

To determine the site being used by the current PassportIdentity object, use the GetCurrentConfig("SiteID") method.

This method allows the use of a different set of keys based on a site name.

Setting keys for PassportIdentity object has no effect on the keys used for Ticket and Profile decryption by the PassportIdentity object. The PassportIdentity object loads the correct key for the current request either by determining host name through objects (through the built-in OnStartPage method) or through the structures passed to equivalent PassportIdentity ISAPI-targeted application programming interfaces (APIs).

See Also

Passport PassportIdentity Object | PassportIdentity.CryptPutHost | PassportIdentity.CryptIsValid