Claim 類別

定義

表示與實體關聯的宣告。

public ref class Claim
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")]
public class Claim
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")>]
type Claim = class
Public Class Claim
繼承
Claim
屬性

範例

// Run this method from within a method protected by the PrincipalPermissionAttribute
// to see the security context data, including the primary identity.
public void WriteServiceSecurityContextData(string fileName)
{
    using (StreamWriter sw = new StreamWriter(fileName))
    {
        // Write the primary identity and Windows identity. The primary identity is derived from the
        // the credentials used to authenticate the user. The Windows identity may be a null string.
        sw.WriteLine("PrimaryIdentity: {0}", ServiceSecurityContext.Current.PrimaryIdentity.Name);
        sw.WriteLine("WindowsIdentity: {0}", ServiceSecurityContext.Current.WindowsIdentity.Name);
        sw.WriteLine();
        // Write the claimsets in the authorization context. By default, there is only one claimset
        // provided by the system.
        foreach (ClaimSet claimset in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
        {
            foreach (Claim claim in claimset)
            {
                // Write out each claim type, claim value, and the right. There are two
                // possible values for the right: "identity" and "possessproperty".
                sw.WriteLine("Claim Type = {0}", claim.ClaimType);
                sw.WriteLine("\t Resource = {0}", claim.Resource.ToString());
                sw.WriteLine("\t Right = {0}", claim.Right);
            }
        }
    }
}
' Run this method from within a method protected by the PrincipalPermissionAttribute
' to see the security context data, including the primary identity.
Public Sub WriteServiceSecurityContextData(ByVal fileName As String)
    Dim sw As New StreamWriter(fileName)
    Try
        ' Write the primary identity and Windows identity. The primary identity is derived from the
        ' the credentials used to authenticate the user. The Windows identity may be a null string.
        sw.WriteLine("PrimaryIdentity: {0}", ServiceSecurityContext.Current.PrimaryIdentity.Name)
        sw.WriteLine("WindowsIdentity: {0}", ServiceSecurityContext.Current.WindowsIdentity.Name)
        sw.WriteLine()
        ' Write the claimsets in the authorization context. By default, there is only one claimset
        ' provided by the system. 
        Dim claimset As ClaimSet
        For Each claimset In ServiceSecurityContext.Current.AuthorizationContext.ClaimSets
            Dim claim As Claim
            For Each claim In claimset
                ' Write out each claim type, claim value, and the right. There are two
                ' possible values for the right: "identity" and "possessproperty". 
                sw.WriteLine("Claim Type = {0}", claim.ClaimType)
                sw.WriteLine(vbTab + " Resource = {0}", claim.Resource.ToString())
                sw.WriteLine(vbTab + " Right = {0}", claim.Right)
            Next claim
        Next claimset
    Finally
        sw.Dispose()
    End Try

End Sub

備註

身分識別模型為宣告架構的授權系統。 宣告會描述與系統中某些實體關聯的功能,這類實體通常是指該系統的使用者。 與特定實體關聯的一組宣告可以視為金鑰。 這些特定宣告會定義該金鑰的形狀,就像是用來開啟門鎖的實體鑰匙。 如此一來,宣告就可用來取得資源的存取權。 判定特定受保護資源之存取權的方式,就是比較存取該資源時所需要的宣告以及與嘗試進行存取之實體關聯的宣告。

宣告就是權限對於特定值的運算式。 權限可以是讀取、寫入或擁有權限, 值可以是資料庫、檔案、信箱或屬性。 宣告也具有宣告類型, 宣告類型和權限共同提供的機制適用於使用值進行指定的各項功能。 例如,具有值許可權readbiography.doc的型file別宣告表示具有這類宣告的實體具有檔案的讀取許可權 biography.doc。具有值許可權PossessPropertyMartin之類型名稱的宣告,表示具有宣告的實體擁有Name具有 值Martin的屬性。

雖然各種宣告類型和權限都是定義為身分識別模型的一部分,但是系統仍具備擴充性。 以身分識別模型基礎架構為基礎的各種系統可以視需要定義宣告類型和權限。

建構函式

Claim(String, Object, String)

使用指定的類型、資源和權限初始化 Claim 類別的新執行個體。

屬性

ClaimType

取得宣告類型。

DefaultComparer

取得可以比較兩個 Claim 物件是否相等的物件。

Resource

取得與這個 Claim 物件關聯的資源。

Right

統一資源識別元 (URI) 的字串表示,指定與這個 Claim 物件關聯的權限。 預先定義的權限可做為 Rights 類別的靜態屬性。

System

表示系統實體的預先定義宣告。

方法

CreateDenyOnlyWindowsSidClaim(SecurityIdentifier)

建立 Claim 物件,這個物件表示 deny-only 指定安全識別項 (SID)。

CreateDnsClaim(String)

建立 Claim 物件,這個物件表示指定的網域名稱系統 (DNS) 名稱。

CreateHashClaim(Byte[])

建立 Claim 物件,這個物件表示指定的雜湊值。

CreateMailAddressClaim(MailAddress)

建立 Claim 物件,這個物件表示指定的電子郵件地址。

CreateNameClaim(String)

建立 Claim 物件,這個物件表示指定的名稱。

CreateRsaClaim(RSA)

建立 Claim 物件,這個物件表示指定的 RSA 金鑰。

CreateSpnClaim(String)

建立 Claim 物件,這個物件表示指定的服務主要名稱 (SPN)。

CreateThumbprintClaim(Byte[])

建立 Claim 物件,這個物件表示指定的指紋。

CreateUpnClaim(String)

建立 Claim 物件,這個物件表示指定的通用主要名稱 (UPN)。

CreateUriClaim(Uri)

建立 Claim 物件,這個物件表示指定的統一資源定位器 (URL)。

CreateWindowsSidClaim(SecurityIdentifier)

建立 Claim 物件,這個物件表示指定的安全識別項 (SID)。

CreateX500DistinguishedNameClaim(X500DistinguishedName)

建立 Claim 物件,這個物件表示指定的 X.500 辨別名稱。

Equals(Object)

判斷指定的物件是否表示與目前 Claim 物件相同的宣告。

GetHashCode()

傳回目前宣告的雜湊程式碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回這個 Claim 物件的字串表示。

適用於