ClaimsIdentity.HasClaim 方法

定义

确定该声明标识是否拥有与指定条件相匹配的声明。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.

HasClaim(String, String)

确定该声明标识是否具备指定声明类型和值。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

参数

type
String

要匹配的声明类型。The type of the claim to match.

value
String

要匹配的声明的值。The value of the claim to match.

返回

Boolean

如果找到匹配项,则为 true;否则为 falsetrue if a match is found; otherwise, false.

例外

typevaluenulltype or value is null.

注解

不检查 IssuerOriginalIssuer 属性。Does not check the Issuer or OriginalIssuer properties. 使用序号、对值区分大小写进行比较;类型上区分大小写。The comparison is made using Ordinal, case sensitive on value; case in-sensitive on type.

适用于

HasClaim(Predicate<Claim>)

确定该声明标识是否拥有与指定条件相匹配的声明。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

参数

match
Predicate<Claim>

执行匹配逻辑的函数。The function that performs the matching logic.

返回

Boolean

如果存在匹配的声明,则为 true;否则为 falsetrue if a matching claim exists; otherwise, false.

例外

matchnullmatch is null.

适用于