ClaimsIdentity.HasClaim Method
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.
Determines whether the claims identity possesses a claim that matches specified conditions.
HasClaim(String, String) |
Determines whether this claims identity has a claim with the specified claim type and value. |
HasClaim(Predicate<Claim>) |
Determines whether this claims identity has a claim that is matched by the specified predicate. |
- Source:
- ClaimsIdentity.cs
- Source:
- ClaimsIdentity.cs
- Source:
- ClaimsIdentity.cs
Determines whether this claims identity has a claim with the specified claim type and value.
public:
virtual bool HasClaim(System::String ^ type, System::String ^ value);
public virtual bool HasClaim (string type, string value);
abstract member HasClaim : string * string -> bool
override this.HasClaim : string * string -> bool
Public Overridable Function HasClaim (type As String, value As String) As Boolean
Parameters
- type
- String
The type of the claim to match.
- value
- String
The value of the claim to match.
Returns
true
if a match is found; otherwise, false
.
Exceptions
type
or value
is null
.
Remarks
Does not check the Issuer or OriginalIssuer properties. The comparison is made using Ordinal, case sensitive on value; case in-sensitive on type.
Applies to
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |
- Source:
- ClaimsIdentity.cs
- Source:
- ClaimsIdentity.cs
- Source:
- ClaimsIdentity.cs
Determines whether this claims identity has a claim that is matched by the specified predicate.
public:
virtual bool HasClaim(Predicate<System::Security::Claims::Claim ^> ^ match);
public virtual bool HasClaim (Predicate<System.Security.Claims.Claim> match);
abstract member HasClaim : Predicate<System.Security.Claims.Claim> -> bool
override this.HasClaim : Predicate<System.Security.Claims.Claim> -> bool
Public Overridable Function HasClaim (match As Predicate(Of Claim)) As Boolean
Parameters
Returns
true
if a matching claim exists; otherwise, false
.
Exceptions
match
is null
.
Applies to
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: