Edit

Share via


ClaimsPrincipal Constructors

Definition

Initializes a new instance of the ClaimsPrincipal class.

Overloads

ClaimsPrincipal()

Initializes a new instance of the ClaimsPrincipal class.

ClaimsPrincipal(IEnumerable<ClaimsIdentity>)

Initializes a new instance of the ClaimsPrincipal class using the specified claims identities.

ClaimsPrincipal(BinaryReader)

Initializes an instance of ClaimsPrincipal with the specified BinaryReader.

ClaimsPrincipal(IIdentity)

Initializes a new instance of the ClaimsPrincipal class from the specified identity.

ClaimsPrincipal(IPrincipal)

Initializes a new instance of the ClaimsPrincipal class from the specified principal.

ClaimsPrincipal(SerializationInfo, StreamingContext)
Obsolete.

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

ClaimsPrincipal()

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Initializes a new instance of the ClaimsPrincipal class.

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

Remarks

No identities are associated with the new instance. (The Identities collection is empty).

Applies to

ClaimsPrincipal(IEnumerable<ClaimsIdentity>)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Initializes a new instance of the ClaimsPrincipal class using the specified claims identities.

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

Parameters

identities
IEnumerable<ClaimsIdentity>

The identities from which to initialize the new claims principal.

Exceptions

identities is null.

Remarks

The Identities collection is initialized with the specified identities.

Applies to

ClaimsPrincipal(BinaryReader)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Initializes an instance of ClaimsPrincipal with the specified BinaryReader.

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

Parameters

reader
BinaryReader

A BinaryReader pointing to a ClaimsPrincipal.

Exceptions

reader is null.

Remarks

Normally, the BinaryReader is constructed using the bytes from WriteTo and initialized in the same way as the BinaryWriter.

Applies to

ClaimsPrincipal(IIdentity)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Initializes a new instance of the ClaimsPrincipal class from the specified identity.

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

Parameters

identity
IIdentity

The identity from which to initialize the new claims principal.

Exceptions

identity is null.

Remarks

If the specified identity is assignable from ClaimsIdentity, it is used to initialize the Identities collection. Otherwise, a ClaimsIdentity is created using the specified identity and is used to initialize the collection.

Applies to

ClaimsPrincipal(IPrincipal)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs

Initializes a new instance of the ClaimsPrincipal class from the specified principal.

public:
 ClaimsPrincipal(System::Security::Principal::IPrincipal ^ principal);
public ClaimsPrincipal (System.Security.Principal.IPrincipal principal);
new System.Security.Claims.ClaimsPrincipal : System.Security.Principal.IPrincipal -> System.Security.Claims.ClaimsPrincipal
Public Sub New (principal As IPrincipal)

Parameters

principal
IPrincipal

The principal from which to initialize the new claims principal.

Exceptions

principal is null.

Remarks

If the specified principal is assignable from ClaimsPrincipal, all of its identities are added to the Identities collection. If the specified principal is not assignable from ClaimsPrincipal, a new ClaimsIdentity is created from the IIdentity in its IPrincipal.Identity property and added to the Identities collection.

Applies to

ClaimsPrincipal(SerializationInfo, StreamingContext)

Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.cs
Source:
ClaimsPrincipal.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 ClaimsPrincipal class from a serialized stream created by using ISerializable.

protected:
 ClaimsPrincipal(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ClaimsPrincipal (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 ClaimsPrincipal (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
protected ClaimsPrincipal (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Claims.ClaimsPrincipal : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsPrincipal
[<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.ClaimsPrincipal : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsPrincipal
[<System.Security.SecurityCritical>]
new System.Security.Claims.ClaimsPrincipal : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Claims.ClaimsPrincipal
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