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.
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
|
|
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.
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>
<%@ Page language = "VB" AutoEventWireup = "true" %>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Web.Security" %>
<%@ Import Namespace = "System.Runtime.InteropServices" %>
<script runat = "server">
Private Sub Page_Load ( sender As Object, e As System.EventArgs )
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 Not TypeOf ( Me.Context.User.Identity ) Is PassportIdentity Then
' If this page isn't set to use Passport authentication, quit now.
Me.Response.Write ( "Error: Passport authentication failed. " & _
"Make sure that the Passport SDK is installed and your " & _
"Web.config file is configured correctly." )
Return
End If
' 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.
Dim identity As PassportIdentity = Me.Context.User.Identity
' 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 ) ) Then
Me.Response.Write ( "Welcome to the site.<br><br>" )
' Print the Passport sign in button on the screen.
Me.Response.Write ( identity.LogoTag2 ( ) )
' Make sure the user has core profile information before trying to access it.
If ( identity.HasProfile ( "core" ) ) Then
Me.Response.Write ( "<b>You have been authenticated as " & _
"Passport identity:" & identity.Name & "</b></p>" )
End If
' Determine whether the user has a ticket.
ElseIf identity.HasTicket Then
' 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 ( Nothing, -1, True, Nothing, -1, Nothing, -1, True, Nothing )
' If the user does not already have a ticket, ask the user to sign in.
Else
Me.Response.Write ( "Please sign in using the link below.<br><br>" )
' Print the Passport sign in button on the screen.
Me.Response.Write ( identity.LogoTag2 ( ) )
End If
Catch comError As System.Runtime.InteropServices.COMException
Me.Response.Write ( "An error occured while working with the " & _
"Passport SDK. The following result was returned: " & comError.ErrorCode )
End Try
End Sub
</script> |
|
C# |
VB |
PassportAuthenticationModule Class PassportPrincipal Class
|
|