PassportIdentity 類別

定義

警告

此 API 現已淘汰。

提供 PassportAuthenticationModule 所使用的類別。Provides a class to be used by PassportAuthenticationModule. 它提供應用程式存取 Ticket(String) 方法的方式。It provides a way for an application to access the Ticket(String) method. 這個類別無法被繼承。This class cannot be inherited. 這個類別已被取代。This class is deprecated.

public ref class PassportIdentity sealed : IDisposable, System::Security::Principal::IIdentity
[System.Obsolete("This type is obsolete. The Passport authentication product is no longer supported and has been superseded by Live ID.")]
public sealed class PassportIdentity : IDisposable, System.Security.Principal.IIdentity
type PassportIdentity = class
    interface IIdentity
    interface IDisposable
Public NotInheritable Class PassportIdentity
Implements IDisposable, IIdentity
繼承
PassportIdentity
屬性
實作

範例

<!-- 
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.

1. You must modify the Web.config file associated with this page so that 
authentication mode is set to "Passport".
2. You must have the Passport SDK installed.
3. 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.
4. You must have installed the encryption key you received after registering 
your site and receiving a site ID.
5. You must have the Passport Manager object settings correctly configured for 
your site.
-->

<!-- 
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.

1. You must modify the Web.config file associated with this page so that 
authentication mode is set to "Passport".
2. You must have the Passport SDK installed.
3. 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.
4. You must have installed the encryption key you received after registering your 
site and receiving a site ID.
5. 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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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.SetNoStore(); 


            // Get a version of the Identity value that is cast as type
            // PassportIdentity. 
//<Snippet4>
//<Snippet5>
//<Snippet6>
            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());
//</Snippet6>
                // 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>");
                }
            }
//</Snippet5>            
    
            // 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);
            }
//</Snippet4>

            // 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 occurred while working with the " +
                "Passport SDK.");
        }
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>ASP.NET Example</title>
</head>
    <body>
        <form id="form1" runat="server">
        </form>
    </body>
</html>
<%@ Page language="VB" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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.SetNoStore()
            
            ' Get a version of the Identity value that is cast as type
            ' PassportIdentity. 
'<Snippet4>
'<Snippet5>
'<Snippet6>
            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())
'</Snippet6>
                ' 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
'</Snippet5>            
    
            ' 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)
'</Snippet4>

            ' 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 occurred while working with the " & _
                "Passport SDK. The following result was returned: " & _
                comError.ErrorCode)
        End Try
    End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>ASP.NET Example</title>
</head>

    <body>
        <form id="form1" runat="server">
        </form>
    </body>
</html>

備註

這個類別已被取代, 不再受到支援。This class has been deprecated and is no longer supported. Microsoft Passport 的網路已由 Windows Live ID 取代。Microsoft Passport Network has been replaced by Windows Live ID. 如需如何使用 Windows Live ID 在 Web 應用程式中驗證使用者的詳細資訊, 請參閱Windows LIVE ID SDKFor more information about how to use Windows Live ID to authenticate users in a Web application, see Windows Live ID SDK.

建構函式

PassportIdentity()

初始化 PassportIdentity 類別的新執行個體。Initializes a new instance of the PassportIdentity class. 這個類別已被取代。This class is deprecated.

屬性

AuthenticationType

取得用來識別使用者的驗證類型。Gets the type of authentication used to identify the user. 這個類別已被取代。This class is deprecated.

Error

取得值,表示與目前 Passport 票證關聯的錯誤狀態。Gets a value indicating the error state associated with the current Passport ticket. 這個類別已被取代。This class is deprecated.

GetFromNetworkServer

取得 Passport 伺服器連接和查詢字串的資訊。Gets information on a Passport server connection and query string. 這個類別已被取代。This class is deprecated.

HasSavedPassword

取得是否已儲存 Passport 成員密碼的相關資訊。Gets information on whether the Passport member's password was saved. 這個類別已被取代。This class is deprecated.

HasTicket

取得值,表示查詢字串是否包含 Passport 票證來當做 Cookie。Gets a value indicating whether the query string includes a Passport ticket as a cookie. 這個類別已被取代。This class is deprecated.

HexPUID

以十六進位格式,取得目前已驗證之使用者的 Passport 唯一識別項 (PUID)。Gets the Passport Unique Identifier (PUID) for the currently authenticated user, in hexadecimal form. 這個類別已被取代。This class is deprecated.

IsAuthenticated

取得值,表示是否以 Passport 授權來驗證使用者。Gets a value indicating whether the user is authenticated against a Passport authority. 這個類別已被取代。This class is deprecated.

Item[String]

取得 Passport 設定檔屬性。Gets Passport profile attributes. 這個類別已被取代。This class is deprecated.

Name

取得目前使用者的名稱。Gets the name of the current user. 這個類別已被取代。This class is deprecated.

TicketAge

取得自從上次票證發行或更新之後的時間 (以秒為單位)。Gets the time, in seconds, since the last ticket was issued or refreshed. 這個類別已被取代。This class is deprecated.

TimeSinceSignIn

取得成員自登入 Passport 登入伺服器以來經過的時間 (以秒為單位)。Gets the time, in seconds, since a member's logon to the Passport logon server. 這個類別已被取代。This class is deprecated.

方法

AuthUrl()

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, as well as with optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl(String)

傳回包含成員的登入伺服器 URL 的字串,以及在查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, along with optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl(String, Int32, Boolean, String, Int32, String, Int32, Boolean)

傳回成員的驗證伺服器 URL。Returns the authentication server URL for a member. 這個類別已被取代。This class is deprecated.

AuthUrl(String, Int32, Int32, String, Int32, String, Int32, Int32)

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, along with the optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl2()

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, as well as optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl2(String)

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, as well as optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl2(String, Int32, Boolean, String, Int32, String, Int32, Boolean)

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Returns a string containing the Login server URL for a member, as well as the optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

AuthUrl2(String, Int32, Int32, String, Int32, String, Int32, Int32)

擷取包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。Retrieves a string containing the Login server URL for a member, as well as the optional information sent to the Login server in the query string. 這個類別已被取代。This class is deprecated.

Compress(String)

壓縮資料。Compresses data. 這個類別已被取代。This class is deprecated.

CryptIsValid()

取得旗標狀態,表示 Passport Manager 是否處於加密的有效狀態。Gets the state of a flag indicating if the Passport Manager is in a valid state for encryption. 這個類別已被取代。This class is deprecated.

CryptPutHost(String)

設定要用於 Passport 加密和解密的金鑰。Sets the key being used for Passport encryption and decryption. 這個類別已被取代。This class is deprecated.

CryptPutSite(String)

當第一次安裝金鑰時,藉由參考指派給該金鑰的網站名稱標籤,來設定用於 Passport 加密和解密的金鑰。Sets the key being used for Passport encryption and decryption by referring to the site-name label assigned to that key when the key was first installed. 這個類別已被取代。This class is deprecated.

Decompress(String)

解壓縮由 Compress(String) 方法壓縮的資料。Decompresses data that has been compressed by the Compress(String) method. 這個類別已被取代。This class is deprecated.

Decrypt(String)

使用目前網站的 Passport 參與者金鑰來解密資料。Decrypts data using the Passport participant key for the current site. 這個類別已被取代。This class is deprecated.

Encrypt(String)

使用目前網站的 Passport 參與者金鑰來加密資料。Encrypts data using the Passport participant key for the current site. 這個類別已被取代。This class is deprecated.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

允許這個 Passport 識別在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。Allows this passport identity to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetCurrentConfig(String)

取得 HKLM\SW\Microsoft\Passport 登錄區下之登錄機碼的內容。Gets the contents of a registry key under the HKLM\SW\Microsoft\Passport hive. 這個類別已被取代。This class is deprecated.

GetDomainAttribute(String, Int32, String)

藉由查詢所要求之網域屬性的 Passport Manager,來提供 Passport 網域的資訊。Provides information for a Passport domain by querying the Passport manager for the requested domain attribute. 這個類別已被取代。This class is deprecated.

GetDomainFromMemberName(String)

傳回成員名稱字串的 Passport 網域。Returns the Passport domain from the member name string. 這個類別已被取代。This class is deprecated.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetIsAuthenticated(Int32, Boolean, Boolean)

表示使用者是否由負責 Passport 驗證的中央網站來驗證。Indicates whether the user is authenticated by a central site responsible for Passport authentication. 這個類別已被取代。This class is deprecated.

GetIsAuthenticated(Int32, Int32, Int32)

表示使用者是否由 Passport 授權認證。Indicates whether the user is authenticated by a Passport authority. 這個類別已被取代。This class is deprecated.

GetLoginChallenge()

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

GetLoginChallenge(String)

藉由將適當的標頭輸出到 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on by outputting the appropriate headers to either a 302 redirect URL or the initiation of a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

GetLoginChallenge(String, Int32, Int32, String, Int32, String, Int32, Int32, Object)

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

GetOption(String)

取得特定 Passport 登入選項。Gets a specific Passport logon option. 這個類別已被取代。This class is deprecated.

GetProfileObject(String)

傳回指定設定檔屬性的 Passport 設定檔資訊。Returns Passport profile information for the specified profile attribute. 這個類別已被取代。This class is deprecated.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
HasFlag(Int32)

表示指定的旗標是否在這個使用者的設定檔中設定。Indicates whether a given flag is set in this user's profile. 這個類別已被取代。This class is deprecated.

HasProfile(String)

表示指定的設定檔屬性是否存在於這個使用者的設定檔。Indicates whether a given profile attribute exists in this user's profile. 這個類別已被取代。This class is deprecated.

HaveConsent(Boolean, Boolean)

表示這個使用者的設定檔中是否授與完全同意。Indicates whether full consent is granted in this user's profile. 這個類別已被取代。This class is deprecated.

LoginUser()

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

LoginUser(String)

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

LoginUser(String, Int32, Boolean, String, Int32, String, Int32, Boolean, Object)

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or by initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

LoginUser(String, Int32, Int32, String, Int32, String, Int32, Int32, Object)

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。Logs the user on, either by generating a 302 redirect URL or initiating a Passport-aware client authentication exchange. 這個類別已被取代。This class is deprecated.

LogoTag()

傳回包含 Passport 連結之影像標記的 HTML 片段。Returns an HTML fragment containing an image tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag(String)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag(String, Int32, Boolean, String, Int32, Boolean, String, Int32, Boolean)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag(String, Int32, Int32, String, Int32, Int32, String, Int32, Int32)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag2()

傳回包含 Passport 連結之影像標記的 HTML 片段。Returns an HTML fragment containing an image tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag2(String)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag2(String, Int32, Boolean, String, Int32, Boolean, String, Int32, Boolean)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoTag2(String, Int32, Int32, String, Int32, Int32, String, Int32, Int32)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。Returns an HTML fragment containing an HTML <img> tag for a Passport link. 這個類別已被取代。This class is deprecated.

LogoutURL()

傳回 Passport 登出 URL 字串。Returns the Passport logout URL string. 這個類別已被取代。This class is deprecated.

LogoutURL(String, String, Int32, String, Int32)

使用指定參數傳回 Passport 登出 URL 字串。Returns the Passport logout URL string using the specified parameters. 這個類別已被取代。This class is deprecated.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
SetOption(String, Object)

設定特定 Passport 登入選項。Sets a specific Passport logon option. 這個類別已被取代。This class is deprecated.

SignOut(String)

從目前工作階段登出指定的 Passport 成員。Logs off the given Passport member from the current session. 這個類別已被取代。This class is deprecated.

Ticket(String)

取得 Passport 驗證票證之特定屬性的相關資訊。Gets information on a specific attribute of the Passport authentication ticket. 這個類別已被取代。This class is deprecated.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

IDisposable.Dispose()

釋放 PassportIdentity 類別所使用的所有資源。Releases all resources used by the PassportIdentity class. 這個類別已被取代。This class is deprecated.

適用於