Claim Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a claim that is associated with an entity.
public ref class Claim
public class Claim
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")]
public class Claim
type Claim = class
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.xmlsoap.org/ws/2005/05/identity")>]
type Claim = class
Public Class Claim
- Inheritance
-
Claim
- Attributes
// 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
The Identity Model is a claims-based authorization system. Claims describe the capabilities associated with some entity in the system, often a user of that system. The set of claims associated with a given entity can be thought of as a key. The particular claims define the shape of that key; much like a physical key is used to open a lock in a door. In this way, claims are used to gain access to resources. Access to a given protected resource is determined by comparing the claims required to access that resource with the claims associated with the entity that attempts access.
A claim is the expression of a right with respect to a particular value. A right could be read, write, or possess. A value could be a database, a file, a mailbox, or a property. Claims also have a claim type. The combination of claim type and right provides the mechanism for capabilities being specified with respect to the value. For example, a claim of type file
with the right read
over the value biography.doc
indicates that the entity with such a claim has read access to the file biography.doc. A claim of type name with the right PossessProperty over the value Martin
indicates that the entity with the claim possesses a Name
property with the value Martin
.
Although various claim types and rights are defined as part of Identity Model, the system is extensible. The various systems building on top of the Identity Model infrastructure can define claim types and rights as required.
Claim(String, Object, String) |
Initializes a new instance of the Claim class with the specified type, resource, and right. |
Claim |
Gets the type of the claim. |
Default |
Gets an object that can compare two Claim objects for equality. |
Resource |
Gets the resource with which this Claim object is associated. |
Right |
A string representation of a uniform resource identifier (URI) that specifies the right associated with this Claim object. Pre-defined rights are available as static properties of the Rights class. |
System |
A pre-defined claim that represents the system entity. |
Create |
Creates a Claim object that represents a deny-only specified security identifier (SID). |
Create |
Creates a Claim object that represents the specified Domain Name System (DNS) name. |
Create |
Creates a Claim object that represents the specified hash value. |
Create |
Creates a Claim object that represents the specified email address. |
Create |
Creates a Claim object that represents the specified name. |
Create |
Creates a Claim object that represents the specified RSA key. |
Create |
Creates a Claim object that represents the specified Service Principal Name (SPN). |
Create |
Creates a Claim object that represents the specified thumbprint. |
Create |
Creates a Claim object that represents the specified Universal Principal Name (UPN). |
Create |
Creates a Claim object that represents the specified Uniform Resource Locator (URL). |
Create |
Creates a Claim object that represents the specified security identifier (SID). |
CreateX500Distinguished |
Creates a Claim object that represents the specified X.500 distinguished name. |
Equals(Object) |
Determines whether the specified object represents the same claim as the current Claim object. |
Get |
Returns a hash code for the current claim. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string representation of this Claim object. |
Produto | Versões |
---|---|
.NET | 8 (package-provided) |
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: