ClaimsPrincipal.HasClaim 方法

定义

确定与此声明主体相关联的任何声明标识是否包含与指定条件匹配的声明。Determines whether any of the claims identities associated with this claims principal contains a claim that matches specified conditions.

重载

HasClaim(Predicate<Claim>)

确定与此声明主体相关联的任何声明标识是否包含由指定的谓词匹配的声明。Determines whether any of the claims identities associated with this claims principal contains a claim that is matched by the specified predicate.

HasClaim(String, String)

确定与此声明主体相关联的任何声明标识是否包含具有指定声明类型和值的声明。Determines whether any of the claims identities associated with this claims principal contains a claim with the specified claim type and value.

HasClaim(Predicate<Claim>)

确定与此声明主体相关联的任何声明标识是否包含由指定的谓词匹配的声明。Determines whether any of the claims identities associated with this claims principal contains 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.

注解

每个 ClaimsIdentity 调用。Each ClaimsIdentity is called.

请参阅See also

ClaimsIdentity.HasClaim(String, String).ClaimsIdentity.HasClaim(String, String).

适用于

HasClaim(String, String)

确定与此声明主体相关联的任何声明标识是否包含具有指定声明类型和值的声明。Determines whether any of the claims identities associated with this claims principal contains 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 matching claim exists; 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.

适用于