Επεξεργασία

Κοινή χρήση μέσω


ClaimsIdentity Constructors

Definition

Initializes a new instance of the ClaimsIdentity class.

Overloads

ClaimsIdentity()

Initializes a new instance of the ClaimsIdentity class with an empty claims collection.

ClaimsIdentity(IIdentity, IEnumerable<Claim>, String, String, String)

Initializes a new instance of the ClaimsIdentity class from the specified IIdentity using the specified claims, authentication type, name claim type, and role claim type.

ClaimsIdentity(IEnumerable<Claim>, String, String, String)

Initializes a new instance of the ClaimsIdentity class with the specified claims, authentication type, name claim type, and role claim type.

ClaimsIdentity(String, String, String)

Initializes a new instance of the ClaimsIdentity class with the specified authentication type, name claim type, and role claim type.

ClaimsIdentity(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the ClaimsIdentity class from a serialized stream created by using ISerializable.

ClaimsIdentity(IEnumerable<Claim>, String)

Initializes a new instance of the ClaimsIdentity class with the specified claims and authentication type.

ClaimsIdentity(IIdentity, IEnumerable<Claim>)

Initializes a new instance of the ClaimsIdentity class using the specified claims and the specified IIdentity.

ClaimsIdentity(IIdentity)

Initializes a new instance of the ClaimsIdentity class using the name and authentication type from the specified IIdentity.

ClaimsIdentity(ClaimsIdentity)

Initializes a new instance of the ClaimsIdentity class from an existing ClaimsIdentity instance.

ClaimsIdentity(SerializationInfo)
Obsolete.

Initializes a new instance of the ClaimsIdentity class from a serialized stream created by using ISerializable.

ClaimsIdentity(BinaryReader)

Initializes an instance of ClaimsIdentity with the specified BinaryReader.

ClaimsIdentity(IEnumerable<Claim>)

Initializes a new instance of the ClaimsIdentity class using an enumerated collection of Claim objects.

ClaimsIdentity(String)

Initializes a new instance of the ClaimsIdentity class with an empty claims collection and the specified authentication type.

ClaimsIdentity()

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class with an empty claims collection.

public:
 ClaimsIdentity();
public ClaimsIdentity ();
Public Sub New ()

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType null.
BootstrapContext null.
Claims A empty collection.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType DefaultNameClaimType.
RoleClaimType DefaultRoleClaimType.

Applies to

ClaimsIdentity(IIdentity, IEnumerable<Claim>, String, String, String)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class from the specified IIdentity using the specified claims, authentication type, name claim type, and role claim type.

public:
 ClaimsIdentity(System::Security::Principal::IIdentity ^ identity, System::Collections::Generic::IEnumerable<System::Security::Claims::Claim ^> ^ claims, System::String ^ authenticationType, System::String ^ nameType, System::String ^ roleType);
public ClaimsIdentity (System.Security.Principal.IIdentity identity, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims, string authenticationType, string nameType, string roleType);
public ClaimsIdentity (System.Security.Principal.IIdentity? identity, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>? claims, string? authenticationType, string? nameType, string? roleType);
new System.Security.Claims.ClaimsIdentity : System.Security.Principal.IIdentity * seq<System.Security.Claims.Claim> * string * string * string -> System.Security.Claims.ClaimsIdentity
Public Sub New (identity As IIdentity, claims As IEnumerable(Of Claim), authenticationType As String, nameType As String, roleType As String)

Parameters

identity
IIdentity

The identity from which to base the new claims identity.

claims
IEnumerable<Claim>

The claims with which to populate the new claims identity.

authenticationType
String

The type of authentication used.

nameType
String

The claim type to use for name claims.

roleType
String

The claim type to use for role claims.

Exceptions

identity is a ClaimsIdentity and Actor results in a circular reference back to this.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor If identity is assignable from ClaimsIdentity, the value of the identity.Actor property; otherwise, null.
AuthenticationType The authenticationType parameter. If the authenticationType parameter is null or an empty string, the value of the identity.AuthenticationType (IIdentity.AuthenticationType) property is used.
BootstrapContext If identity is assignable from ClaimsIdentity, the value of the identity.BootStrapContext property; otherwise, null.
Claims Initialized from the claims parameter. If identity is assignable from ClaimsIdentity, the claims from identity are added to the new instance before those specified by the claims parameter.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label If identity is assignable from ClaimsIdentity, the value of the identity.Label property; otherwise, null.
Name If identity is not assignable from ClaimsIdentity, is not null, and has an IIdentity.Name property that is not null; a name claim is added to the new instance using the value of the IIdentity.Name property. Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType The value of the nameType parameter. However, if the value of the nameType parameter is null or an empty string and identity is assignable from ClaimsIdentity, the value of the identity.NameClaimType property is used; otherwise, DefaultNameClaimType is used.
RoleClaimType The value of the roleClaimType parameter. However, if the value of the roleClaimType parameter is null or an empty string and identity is assignable from ClaimsIdentity, the value of the identity.RoleClaimType property is used; otherwise, DefaultRoleClaimType is used.

Applies to

ClaimsIdentity(IEnumerable<Claim>, String, String, String)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class with the specified claims, authentication type, name claim type, and role claim type.

public:
 ClaimsIdentity(System::Collections::Generic::IEnumerable<System::Security::Claims::Claim ^> ^ claims, System::String ^ authenticationType, System::String ^ nameType, System::String ^ roleType);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims, string authenticationType, string nameType, string roleType);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>? claims, string? authenticationType, string? nameType, string? roleType);
new System.Security.Claims.ClaimsIdentity : seq<System.Security.Claims.Claim> * string * string * string -> System.Security.Claims.ClaimsIdentity
Public Sub New (claims As IEnumerable(Of Claim), authenticationType As String, nameType As String, roleType As String)

Parameters

claims
IEnumerable<Claim>

The claims with which to populate the claims identity.

authenticationType
String

The type of authentication used.

nameType
String

The claim type to use for name claims.

roleType
String

The claim type to use for role claims.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType The value of the authenticationType parameter. If the authenticationType parameter is null or an empty string, the property is set to null.
BootstrapContext null.
Claims Initialized from the claims parameter.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType The value of the nameType parameter. However, if the nameType parameter is null or an empty string, the property is set to DefaultNameClaimType.
RoleClaimType The value of the roleClaimType parameter. However, if the roleClaimType parameter is null or an empty string, the property is set to DefaultRoleClaimType.

Applies to

ClaimsIdentity(String, String, String)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class with the specified authentication type, name claim type, and role claim type.

public:
 ClaimsIdentity(System::String ^ authenticationType, System::String ^ nameType, System::String ^ roleType);
public ClaimsIdentity (string authenticationType, string nameType, string roleType);
public ClaimsIdentity (string? authenticationType, string? nameType, string? roleType);
new System.Security.Claims.ClaimsIdentity : string * string * string -> System.Security.Claims.ClaimsIdentity
Public Sub New (authenticationType As String, nameType As String, roleType As String)

Parameters

authenticationType
String

The type of authentication used.

nameType
String

The claim type to use for name claims.

roleType
String

The claim type to use for role claims.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType The value of the authenticationType parameter. If the authenticationType parameter is null or an empty string, the property is set to null.
BootstrapContext null.
Claims An empty collection.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType The value of the nameType parameter. If the nameType parameter is null or an empty string, the property is set to DefaultNameClaimType.
RoleClaimType The value of the roleType parameter. If the roleType parameter is null or an empty string, the property is set to DefaultRoleClaimType.

Applies to

ClaimsIdentity(SerializationInfo, StreamingContext)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the ClaimsIdentity class from a serialized stream created by using ISerializable.

protected:
 ClaimsIdentity(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsIdentity
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsIdentity
[<System.Security.SecurityCritical>]
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsIdentity
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

The serialized data.

context
StreamingContext

The context for serialization.

Attributes

Exceptions

info is null.

Applies to

ClaimsIdentity(IEnumerable<Claim>, String)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class with the specified claims and authentication type.

public:
 ClaimsIdentity(System::Collections::Generic::IEnumerable<System::Security::Claims::Claim ^> ^ claims, System::String ^ authenticationType);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims, string authenticationType);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>? claims, string? authenticationType);
new System.Security.Claims.ClaimsIdentity : seq<System.Security.Claims.Claim> * string -> System.Security.Claims.ClaimsIdentity
Public Sub New (claims As IEnumerable(Of Claim), authenticationType As String)

Parameters

claims
IEnumerable<Claim>

The claims with which to populate the claims identity.

authenticationType
String

The type of authentication used.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType The value of the authenticationType parameter. If the authenticationType parameter is null or an empty string, the property is set to null.
BootstrapContext null.
Claims Initialized from the claims parameter.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType DefaultNameClaimType.
RoleClaimType DefaultRoleClaimType.

Applies to

ClaimsIdentity(IIdentity, IEnumerable<Claim>)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class using the specified claims and the specified IIdentity.

public:
 ClaimsIdentity(System::Security::Principal::IIdentity ^ identity, System::Collections::Generic::IEnumerable<System::Security::Claims::Claim ^> ^ claims);
public ClaimsIdentity (System.Security.Principal.IIdentity identity, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims);
public ClaimsIdentity (System.Security.Principal.IIdentity? identity, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>? claims);
new System.Security.Claims.ClaimsIdentity : System.Security.Principal.IIdentity * seq<System.Security.Claims.Claim> -> System.Security.Claims.ClaimsIdentity
Public Sub New (identity As IIdentity, claims As IEnumerable(Of Claim))

Parameters

identity
IIdentity

The identity from which to base the new claims identity.

claims
IEnumerable<Claim>

The claims with which to populate the claims identity.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor If identity is assignable from ClaimsIdentity, the value of the identity.Actor property; otherwise, null.
AuthenticationType The authenticationType parameter. If the authenticationType parameter is null or an empty string, the value of the identity.AuthenticationType (IIdentity.AuthenticationType) property is used.
BootstrapContext If identity is assignable from ClaimsIdentity, the value of the identity.BootStrapContext property; otherwise, null.
Claims Initialized from the claims parameter. If identity is assignable from ClaimsIdentity, the claims from identity are added to the new instance before those specified by the claims parameter.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label If identity is assignable from ClaimsIdentity, the value of the identity.Label property; otherwise, null.
Name If identity is not assignable from ClaimsIdentity, is not null, and has an IIdentity.Name property that is not null; a name claim is added to the new instance using the value of the IIdentity.Name property. Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType If identity is assignable from ClaimsIdentity, the value of the identity.NameClaimType property is used; otherwise, DefaultNameClaimType is used.
RoleClaimType If identity is assignable from ClaimsIdentity, the value of the identity.RoleClaimType property is used; otherwise, DefaultRoleClaimType is used.

Applies to

ClaimsIdentity(IIdentity)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class using the name and authentication type from the specified IIdentity.

public:
 ClaimsIdentity(System::Security::Principal::IIdentity ^ identity);
public ClaimsIdentity (System.Security.Principal.IIdentity identity);
public ClaimsIdentity (System.Security.Principal.IIdentity? identity);
new System.Security.Claims.ClaimsIdentity : System.Security.Principal.IIdentity -> System.Security.Claims.ClaimsIdentity
Public Sub New (identity As IIdentity)

Parameters

identity
IIdentity

The identity from which to base the new claims identity.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor If identity is assignable from ClaimsIdentity, the value of the identity.Actor property; otherwise, null.
AuthenticationType The value of the identity.AuthenticationType (IIdentity.AuthenticationType) property is used.
BootstrapContext If identity is assignable from ClaimsIdentity, the value of the identity.BootStrapContext property; otherwise, null.
Claims If identity is assignable from ClaimsIdentity, the claims from identity are added to the new instance; otherwise, an empty collection.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label If identity is assignable from ClaimsIdentity, the value of the identity.Label property; otherwise, null.
Name If identity is not assignable from ClaimsIdentity, is not null, and has an IIdentity.Name property that is not null; a name claim is added to the new instance using the value of the IIdentity.Name property. Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType If identity is assignable from ClaimsIdentity, the value of the identity.NameClaimType property is used; otherwise, DefaultNameClaimType is used.
RoleClaimType If identity is assignable from ClaimsIdentity, the value of the identity.RoleClaimType property is used; otherwise, DefaultRoleClaimType is used.

Applies to

ClaimsIdentity(ClaimsIdentity)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class from an existing ClaimsIdentity instance.

protected:
 ClaimsIdentity(System::Security::Claims::ClaimsIdentity ^ other);
protected ClaimsIdentity (System.Security.Claims.ClaimsIdentity other);
new System.Security.Claims.ClaimsIdentity : System.Security.Claims.ClaimsIdentity -> System.Security.Claims.ClaimsIdentity
Protected Sub New (other As ClaimsIdentity)

Parameters

other
ClaimsIdentity

The ClaimsIdentity to copy.

Exceptions

other is null.

Remarks

The following table shows the property value assignments for an instance of the ClaimsIdentity class from the ClaimsIdentity provided to the constructor.

Property Value
Actor If the value of the other.Actor property isn't null, the other.Actor ClaimsIdentity is cloned and assigned; otherwise, null.
AuthenticationType The value of the other.AuthenticationType property.
BootstrapContext The value of the other.BootstrapContext property.
Claims The List<Claim> of claims, if any, in the other.Claims property.
Label The value of the other.Label property.
NameClaimType The value of the other.NameClaimType property.
RoleClaimType The value of the other.RoleClaimType property.
CustomSerializationData If other.CustomSerializationData isn't null, other.CustomSerializationData is cloned and assigned; otherwise, null.

Applies to

ClaimsIdentity(SerializationInfo)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the ClaimsIdentity class from a serialized stream created by using ISerializable.

protected:
 ClaimsIdentity(System::Runtime::Serialization::SerializationInfo ^ info);
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info);
[System.Security.SecurityCritical]
protected ClaimsIdentity (System.Runtime.Serialization.SerializationInfo info);
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo -> System.Security.Claims.ClaimsIdentity
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo -> System.Security.Claims.ClaimsIdentity
[<System.Security.SecurityCritical>]
new System.Security.Claims.ClaimsIdentity : System.Runtime.Serialization.SerializationInfo -> System.Security.Claims.ClaimsIdentity
Protected Sub New (info As SerializationInfo)

Parameters

info
SerializationInfo

The serialized data.

Attributes

Exceptions

info is null.

Applies to

ClaimsIdentity(BinaryReader)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes an instance of ClaimsIdentity with the specified BinaryReader.

public:
 ClaimsIdentity(System::IO::BinaryReader ^ reader);
public ClaimsIdentity (System.IO.BinaryReader reader);
new System.Security.Claims.ClaimsIdentity : System.IO.BinaryReader -> System.Security.Claims.ClaimsIdentity
Public Sub New (reader As BinaryReader)

Parameters

reader
BinaryReader

A BinaryReader pointing to a ClaimsIdentity.

Exceptions

reader is null.

Remarks

Normally, the reader is constructed from the bytes returned from WriteTo.

Applies to

ClaimsIdentity(IEnumerable<Claim>)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class using an enumerated collection of Claim objects.

public:
 ClaimsIdentity(System::Collections::Generic::IEnumerable<System::Security::Claims::Claim ^> ^ claims);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> claims);
public ClaimsIdentity (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>? claims);
new System.Security.Claims.ClaimsIdentity : seq<System.Security.Claims.Claim> -> System.Security.Claims.ClaimsIdentity
Public Sub New (claims As IEnumerable(Of Claim))

Parameters

claims
IEnumerable<Claim>

The claims with which to populate the claims identity.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType null.
BootstrapContext null.
Claims Initialized from the claims parameter.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType DefaultNameClaimType.
RoleClaimType DefaultRoleClaimType.

Applies to

ClaimsIdentity(String)

Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs
Source:
ClaimsIdentity.cs

Initializes a new instance of the ClaimsIdentity class with an empty claims collection and the specified authentication type.

public:
 ClaimsIdentity(System::String ^ authenticationType);
public ClaimsIdentity (string authenticationType);
public ClaimsIdentity (string? authenticationType);
new System.Security.Claims.ClaimsIdentity : string -> System.Security.Claims.ClaimsIdentity
Public Sub New (authenticationType As String)

Parameters

authenticationType
String

The type of authentication used.

Remarks

The following table shows initial property values for an instance of the ClaimsIdentity class.

Property Value
Actor null.
AuthenticationType The value of the authenticationType parameter. If the authenticationType parameter is null or an empty string, the property is set to null.
BootstrapContext null.
Claims An empty collection.
IsAuthenticated Note: When accessed, the value of the IsAuthenticated property is returned based on the value of the AuthenticationType property.
Label null.
Name Note: When accessed, the value of the Name property is returned based on the NameClaimType and the Claims collection.
NameClaimType DefaultNameClaimType.
RoleClaimType DefaultRoleClaimType.

Applies to