PassportIdentity 類別

定義

警告

This type is obsolete. The Passport authentication product is no longer supported and has been superseded by Live ID.

提供 PassportAuthenticationModule 所使用的類別。 它提供應用程式存取 Ticket(String) 方法的方式。 此類別無法獲得繼承。 這個類別已被取代。

public ref class PassportIdentity sealed : System::Security::Principal::IIdentity
public ref class PassportIdentity sealed : IDisposable, System::Security::Principal::IIdentity
public sealed class PassportIdentity : System.Security.Principal.IIdentity
public sealed class PassportIdentity : 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
type PassportIdentity = class
    interface IIdentity
    interface IDisposable
[<System.Obsolete("This type is obsolete. The Passport authentication product is no longer supported and has been superseded by Live ID.")>]
type PassportIdentity = class
    interface IIdentity
    interface IDisposable
Public NotInheritable Class PassportIdentity
Implements IIdentity
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>

備註

這個類別已被取代,不再受到支援。 Microsoft Passport 網路已由 Windows Live ID 取代。

建構函式

PassportIdentity()

初始化 PassportIdentity 類別的新執行個體。 這個類別已被取代。

屬性

AuthenticationType

取得用來識別使用者的驗證類型。 這個類別已被取代。

Error

取得值,表示與目前 Passport 票證關聯的錯誤狀態。 這個類別已被取代。

GetFromNetworkServer

取得 Passport 伺服器連接和查詢字串的資訊。 這個類別已被取代。

HasSavedPassword

取得是否已儲存 Passport 成員密碼的相關資訊。 這個類別已被取代。

HasTicket

取得值,表示查詢字串是否包含 Passport 票證來當做 Cookie。 這個類別已被取代。

HexPUID

以十六進位格式,取得目前已驗證之使用者的 Passport 唯一識別項 (PUID)。 這個類別已被取代。

IsAuthenticated

取得值,表示是否以 Passport 授權來驗證使用者。 這個類別已被取代。

Item[String]

取得 Passport 設定檔屬性。 這個類別已被取代。

Name

取得目前使用者的名稱。 這個類別已被取代。

TicketAge

取得自從上次票證發行或更新之後的時間 (以秒為單位)。 這個類別已被取代。

TimeSinceSignIn

取得成員自登入 Passport 登入伺服器以來經過的時間 (以秒為單位)。 這個類別已被取代。

方法

AuthUrl()

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

AuthUrl(String)

傳回包含成員的登入伺服器 URL 的字串,以及在查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

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

傳回成員的驗證伺服器 URL。 這個類別已被取代。

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

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

AuthUrl2()

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

AuthUrl2(String)

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

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

傳回包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

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

擷取包含成員的登入伺服器 URL 的字串,以及查詢字串中傳送到登入伺服器的選擇性資訊。 這個類別已被取代。

Compress(String)

壓縮資料。 這個類別已被取代。

CryptIsValid()

取得旗標狀態,表示 Passport Manager 是否處於加密的有效狀態。 這個類別已被取代。

CryptPutHost(String)

設定要用於 Passport 加密和解密的金鑰。 這個類別已被取代。

CryptPutSite(String)

當第一次安裝金鑰時,藉由參考指派給該金鑰的網站名稱標籤,來設定用於 Passport 加密和解密的金鑰。 這個類別已被取代。

Decompress(String)

解壓縮由 Compress(String) 方法壓縮的資料。 這個類別已被取代。

Decrypt(String)

使用目前網站的 Passport 參與者金鑰來解密資料。 這個類別已被取代。

Encrypt(String)

使用目前網站的 Passport 參與者金鑰來加密資料。 這個類別已被取代。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Finalize()

允許這個 Passport 識別在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。

GetCurrentConfig(String)

取得 HKLM\SW\Microsoft\Passport 登錄區下之登錄機碼的內容。 這個類別已被取代。

GetDomainAttribute(String, Int32, String)

藉由查詢所要求之網域屬性的 Passport Manager,來提供 Passport 網域的資訊。 這個類別已被取代。

GetDomainFromMemberName(String)

傳回成員名稱字串的 Passport 網域。 這個類別已被取代。

GetHashCode()

做為預設雜湊函式。

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

表示使用者是否由負責 Passport 驗證的中央網站來驗證。 這個類別已被取代。

GetIsAuthenticated(Int32, Int32, Int32)

表示使用者是否由 Passport 授權認證。 這個類別已被取代。

GetLoginChallenge()

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

GetLoginChallenge(String)

藉由將適當的標頭輸出到 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

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

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

GetOption(String)

取得特定 Passport 登入選項。 這個類別已被取代。

GetProfileObject(String)

傳回指定設定檔屬性的 Passport 設定檔資訊。 這個類別已被取代。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
HasFlag(Int32)

表示指定的旗標是否在這個使用者的設定檔中設定。 這個類別已被取代。

HasProfile(String)

表示指定的設定檔屬性是否存在於這個使用者的設定檔。 這個類別已被取代。

HaveConsent(Boolean, Boolean)

表示這個使用者的設定檔中是否授與完全同意。 這個類別已被取代。

LoginUser()

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

LoginUser(String)

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

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

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

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

藉由產生 302 重新導向 URL 或啟始 Passport 感知用戶端驗證交換,來登入使用者。 這個類別已被取代。

LogoTag()

傳回包含 Passport 連結之影像標記的 HTML 片段。 這個類別已被取代。

LogoTag(String)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

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

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

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

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

LogoTag2()

傳回包含 Passport 連結之影像標記的 HTML 片段。 這個類別已被取代。

LogoTag2(String)

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

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

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

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

傳回包含 Passport 連結之 HTML <img> 標記的 HTML 片段。 這個類別已被取代。

LogoutURL()

傳回 Passport 登出 URL 字串。 這個類別已被取代。

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

使用指定參數傳回 Passport 登出 URL 字串。 這個類別已被取代。

MemberwiseClone()

建立目前 Object 的淺層複製。

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

設定特定 Passport 登入選項。 這個類別已被取代。

SignOut(String)

從目前工作階段登出指定的 Passport 成員。 這個類別已被取代。

Ticket(String)

取得 Passport 驗證票證之特定屬性的相關資訊。 這個類別已被取代。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IDisposable.Dispose()

釋放 PassportIdentity 類別所使用的所有資源。 這個類別已被取代。

適用於