PassportIdentity.HaveConsent
PassportIdentity.HaveConsent
Returns whether a user has consent for purposes of Microsoft® Kids Passport authentication.
Syntax
public bool HaveConsent( bool bNeedFullConsent, bool bNeedBirthdate )
Parameters
- bNeedFullConsent
true to indicate full consent is required; otherwise, false.- bNeedBirthdate
true to indicate the user's birth date is required; otherwise, false.
Return values
true indicates the user is not subject to consent or consent has been granted. false indicates the user is subject to consent, does not have consent, and cannot continue.
Example
The following C# example uses the HaveConsent method to display a warning message to the user.
<%@ 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.aspx sruURL = sruURL; } else { //Set the sign-in URL - stay on this page sruURL = sthisURL; } //The LogoTag2 allows the user to sign in or sign out. Response.Write ("<DIV STYLE = 'position:absolute; right:50px'>" + oMgr.LogoTag2(sruURL,100,-1,null,1033,-1,null,-1,-1) + "</DIV>"); Response.Write ("For " + oMgr.GetProfileObject("FirstName") + "<br><br>"); if (oMgr.HaveConsent(true,false)) { Response.Write ("You have full consent."); //You can go anywhere from here. } else if (oMgr.HaveConsent(false,false)) { Response.Write ("You have limited consent."); //You can go to some locations from here. } else if (oMgr.HaveConsent(true,true)) { Response.Write ("You have consent and are under age."); //You can go to some locations from here. } else { Response.Write ("You are subject to consent, but do not have consent."); //Do not show links this user cannot use. } %> </HTML>.
Remarks
Consent is defined as permission granted by a parent to a particular Web site on behalf of a minor under 13 who is a resident of the United States or its territories or a minor under 14 who is a resident of Korea.
This method is generally relevant only to sites implementing and using Kids Passport. This method should be used in accompaniment to HasProfile or IsAuthenticated to verify that any user who arrives on the page with a valid profile truly has consent.
Consent must first be established for Microsoft® .NET Passport as a distinct entity, and then can be established on a site-by-site basis for each participating site. Kids Passport divides parental consent into two categories, as defined by the Children's Online Privacy Protection Act (COPPA):
- Limited consent
Consent to collect personal information from children and to share it with third parties "as necessary to operate Company's Web site."- Full consent
Consent to collect personal information from children and share that information with other sites or companies.Microsoft .NET Passport offers parents the ability to manage which of their child's information is shared with Kids Passport participating sites. This method determines whether a user has consent, based on the contents of the Consent cookie and/or the birth date as stored in the Profile cookie.
HaveConsent always returns true for an adults .NET Passport. If HaveConsent is called on a childs .NET Passport, the outcome is determined by several factors: If bNeedBirthdate is false, then the value returned by HaveConsent depends only on the level of consent specified by bNeedFullConsent.
If bNeedFullConsent is false, HaveConsent will return true if limited or full consent is granted. If bNeedFullConsent is true, HaveConsent will return true only if full consent is granted.
If bNeedBirthdate is true, an additional check is performed that will cause HaveConsent to return false if BDay_precision is 0 (no birth date specified) or 3 (legacy where only under 18 is specified). In this case, the Profile must still have the level of consent specified by bNeedFullConsent for HaveConsent to return true.
See Also
Passport PassportIdentity Object | PassportIdentity.HasProfile | PassportIdentity.IsAuthenticated