METHOD

ClaimsIdentity.FindAll

Enumerates matching claims on one identity. Use an explicit predicate when exact type matching is required; check cardinality and trust rather than silently selecting the first claim.

Formal Syntax & Structure

csharp syntaxcsharp
identity.FindAll(c => c.Type == "tenant")

Working Example

Example Snippetcsharp
using System;using System.Security.Claims;using System.Linq;var identity = new ClaimsIdentity(new[]{new Claim("tenant","a")},"Synthetic");Console.WriteLine(identity.FindAll(c => c.Type == "tenant").Count()); // 1
C# & .NET Reference