PassportIdentity.CryptIsValid
PassportIdentity.CryptIsValid
Determines whether the key used for encryption and decryption is valid and whether the PassportIdentity object is correctly created and configured for encryption.
Syntax
public static bool CryptIsValid()
Return values
true if the key used for encryption and decryption is valid and if the PassportIdentity object is in a valid state for encryption; otherwise, false.
Example
The following C# example displays the value of the CryptIsValid method. If the key is validated, the user can proceed. If the key is invalid, the user is told to reconfigure the system.
<%@ 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 = "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>"); //Get and print the GetFromNetworkServer if (oMgr.GetIsAuthenticated(3600,true,false)){ Response.Write ("You are authenticated."); if (PassportIdentity.CryptIsValid()){ Response.Write("<br>The key is valid. Proceed."); } else { Response.Write("<br>The key is invalid. Reconfigure."); } } else { Response.Write ("You are not authenticated. Please click Sign in or exit."); } %>
Remarks
When the Microsoft .NET Passport Software Development Kit (SDK) is first installed, this method will return false until encryption keys are installed.
See Also
Passport PassportIdentity Object | PassportIdentity.CryptPutSite | PassportIdentity.CryptPutHost