asp.net.ph

PassportIdentity Class

System.Web.Security Namespace


Provides a class to be used by PassportAuthenticationModule. It provides a way for an application to access the Ticket method. This class cannot be inherited.

PassportIdentity Class Members

Collapse   Constructors

Visibility Constructor Parameters
public PassportIdentity ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public AuthenticationType String [ Get ]
public Error Int32 [ Get ]
public GetFromNetworkServer Boolean [ Get ]
public HasSavedPassword Boolean [ Get ]
public HasTicket Boolean [ Get ]
public HexPUID String [ Get ]
public IsAuthenticated Boolean [ Get ]
public Item ( String strProfileName ) String [ Get ]
public Name String [ Get ]
public TicketAge Int32 [ Get ]
public TimeSinceSignIn Int32 [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public AuthUrl ( String strReturnUrl , Int32 iTimeWindow , Int32 iForceLogin , String strCoBrandedArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth ) String
public AuthUrl ( String strReturnUrl , Int32 iTimeWindow , Boolean fForceLogin , String strCoBrandedArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Boolean bUseSecureAuth ) String
public AuthUrl ( String strReturnUrl ) String
public AuthUrl ( ) String
public AuthUrl2 ( ) String
public AuthUrl2 ( String strReturnUrl ) String
public AuthUrl2 ( String strReturnUrl , Int32 iTimeWindow , Int32 iForceLogin , String strCoBrandedArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth ) String
public AuthUrl2 ( String strReturnUrl , Int32 iTimeWindow , Boolean fForceLogin , String strCoBrandedArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Boolean bUseSecureAuth ) String
public static Compress ( String strData ) String
public static CryptIsValid ( ) Boolean
public static CryptPutHost ( String strHost ) Int32
public static CryptPutSite ( String strSite ) Int32
public static Decompress ( String strData ) String
public static Decrypt ( String strData ) String
public static Encrypt ( String strData ) String
protected Finalize ( ) Void
public GetCurrentConfig ( String strAttribute ) Object
public GetDomainAttribute ( String strAttribute , Int32 iLCID , String strDomain ) String
public GetDomainFromMemberName ( String strMemberName ) String
public GetIsAuthenticated ( Int32 iTimeWindow , Boolean bForceLogin , Boolean bCheckSecure ) Boolean
public GetIsAuthenticated ( Int32 iTimeWindow , Int32 iForceLogin , Int32 iCheckSecure ) Boolean
public GetLoginChallenge ( ) String
public GetLoginChallenge ( String szRetURL , Int32 iTimeWindow , Int32 fForceLogin , String szCOBrandArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth , Object oExtraParams ) String
public GetLoginChallenge ( String strReturnUrl ) String
public GetOption ( String strOpt ) Object
public GetProfileObject ( String strProfileName ) Object
public HasFlag ( Int32 iFlagMask ) Boolean
public HasProfile ( String strProfile ) Boolean
public HaveConsent ( Boolean bNeedFullConsent , Boolean bNeedBirthdate ) Boolean
public LoginUser ( String strReturnUrl ) Int32
public LoginUser ( ) Int32
public LoginUser ( String szRetURL , Int32 iTimeWindow , Boolean fForceLogin , String szCOBrandArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Boolean fUseSecureAuth , Object oExtraParams ) Int32
public LoginUser ( String szRetURL , Int32 iTimeWindow , Int32 fForceLogin , String szCOBrandArgs , Int32 iLangID , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth , Object oExtraParams ) Int32
public LogoTag ( ) String
public LogoTag ( String strReturnUrl , Int32 iTimeWindow , Int32 iForceLogin , String strCoBrandedArgs , Int32 iLangID , Int32 iSecure , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth ) String
public LogoTag ( String strReturnUrl , Int32 iTimeWindow , Boolean fForceLogin , String strCoBrandedArgs , Int32 iLangID , Boolean fSecure , String strNameSpace , Int32 iKPP , Boolean bUseSecureAuth ) String
public LogoTag ( String strReturnUrl ) String
public LogoTag2 ( ) String
public LogoTag2 ( String strReturnUrl ) String
public LogoTag2 ( String strReturnUrl , Int32 iTimeWindow , Int32 iForceLogin , String strCoBrandedArgs , Int32 iLangID , Int32 iSecure , String strNameSpace , Int32 iKPP , Int32 iUseSecureAuth ) String
public LogoTag2 ( String strReturnUrl , Int32 iTimeWindow , Boolean fForceLogin , String strCoBrandedArgs , Int32 iLangID , Boolean fSecure , String strNameSpace , Int32 iKPP , Boolean bUseSecureAuth ) String
public LogoutURL ( String szReturnURL , String szCOBrandArgs , Int32 iLangID , String strDomain , Int32 iUseSecureAuth ) String
public LogoutURL ( ) String
public SetOption ( String strOpt , Object vOpt ) Void
public static SignOut ( String strSignOutDotGifFileName ) Void
public Ticket ( String strAttribute ) Object

Remarks

You must install the Passport SDK in order to use the .NET Passport classes and methods. Passport SDK version 1.4 is supported but not recommended. Passport SDK version 2.0 is both supported and recommended. The Passport SDK is available for download at http://www.microsoft.com/net/downloads.asp .

For more information on Passport authentication, see The Passport Authentication Provider.

NOTE: In some methods of this class, the corresponding Passport method has optional parameters. Whenever a Passport method has optional integer or Boolean parameters, you can pass "-1" to indicate that Passport should use the default value. Whenever a Passport method has optional string parameters, you can pass a null reference ( Nothing in Visual Basic ) to indicate that Passport should use the default value. It is noted in the parameter description when a parameter can accept one of these default values.

NOTE: In Windows XP, only Passport SDK version 2.0 is supported.

Example

This example demonstrates implementing the soft sign-in authentication approach. In order for the example to work, the following requirements must be met. You can find details on these requirements in the Passport SDK documentation.

  • You must modify the Web.config file associated with this page so that authentication mode is set to "Passport"..
  • You must have the Passport SDK installed.
  • You must have a Passport Site ID for the site where your page resides.
  • If your Site ID is in the PREP environment, you will also need a PREP Passport. You must have installed the encryption key you received after registering your site and receiving a site ID.
  • You must have the Passport Manager object settings correctly configured for your site.

<%@ Page language = "c#" AutoEventWireup = "true" %>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Web.Security" %>
<%@ Import Namespace = "System.Runtime.InteropServices" %>

<script runat = "server">
   private void Page_Load ( object sender, System.EventArgs e ) {
      try {
         // Determine whether Passport is the type of authentication this page is set to use.
         // Authentication information is set in the Web.config file.
         if ( ! ( this.Context.User.Identity is PassportIdentity ) ) {
            // If this page isn't set to use Passport authentication, quit now.
            this.Response.Write ( "Error: Passport authentication failed. " + 
               "Make sure that the Passport SDK is installed " +
               "and your Web.config file is configured correctly." );
            return;
         }

         // Expire the page to avoid the browser's cache.
         Response.Cache.SetCacheability ( HttpCacheability.NoCache ); 

         // Get a version of the Identity value that is cast as type PassportIdentity. 
         PassportIdentity identity = ( this.Context.User.Identity as PassportIdentity );	

         // Determine whether the user is already signed in with a valid and current ticket.
         // Passing -1 for the parameter values indicates the default values will be used.
         if ( identity.GetIsAuthenticated ( -1, -1, -1 ) ) {
            this.Response.Write ( "Welcome to the site.<br><br>" );
            // Print the Passport sign in button on the screen.
            this.Response.Write ( identity.LogoTag2 ( ) );
            // Make sure the user has core profile information before trying to access it.
            if ( identity.HasProfile ( "core" ) ) {
               this.Response.Write ( "<b>You have been authenticated as " + 
                  "Passport identity:" + identity.Name + "</b></p>" );
            }
         }
         // Determine whether the user has a ticket.
         else if ( identity.HasTicket ) {
            // If the user has a ticket but wasn't authenticated,
            // that means the ticket is stale, so the login needs to be refreshed.
            // Passing true as the fForceLogin parameter value indicates that silent refresh will be accepted.
            identity.LoginUser ( null, -1, true, null, -1, null, -1, true, null );
         }
         // If the user does not already have a ticket, ask the user to sign in.
         else {
            this.Response.Write ( "Please sign in using the link below.<br><br>" );
            // Print the Passport sign in button on the screen.
            this.Response.Write ( identity.LogoTag2 ( ) );
         }
      }
      catch ( System.Runtime.InteropServices.COMException comError ) {
         this.Response.Write ( "An error occured while working with the " +
            "Passport SDK. The following result was returned: " + comError.ErrorCode );
      }
   }
</script>
  C# VB

See Also

PassportAuthenticationModule Class   PassportPrincipal Class Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph