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

获取指示查询字符串是否包括作为 cookie 的 Passport 票证。 此类已弃用。

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 管理器是否处于可用于加密的有效状态的标志的状态。 此类已弃用。

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 管理器查询所请求的域特性来提供 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 类使用的所有资源。 此类已弃用。

适用于