System.Security.Claims.ClaimsIdentity.FindAll C# (CSharp) Method

FindAll() public method

Retrieves a IEnumerable{Claim} where each Claim.Type equals type.
Comparison is: StringComparison.OrdinalIgnoreCase.<
if 'type' is null.
public FindAll ( string type ) : IEnumerable
type string The type of the claim to match.
return IEnumerable
        public virtual IEnumerable<Claim> FindAll(string type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            Contract.EndContractBlock();

            foreach (Claim claim in Claims)
            {
                if (claim != null)
                {
                    if (string.Equals(claim.Type, type, StringComparison.OrdinalIgnoreCase))
                    {
                        yield return claim;
                    }
                }
            }
        }

Same methods

ClaimsIdentity::FindAll ( Predicate match ) : IEnumerable
ClaimsIdentity::FindAll ( System match ) : System.Collections.Generic.IEnumerable
ClaimsIdentity::FindAll ( string type ) : System.Collections.Generic.IEnumerable

Usage Example

コード例 #1
0
        public static async Task<List<string>> GetGroups(ClaimsIdentity claimsId)
        {
            if (claimsId.FindFirst("_claim_names") != null
                && (Json.Decode(claimsId.FindFirst("_claim_names").Value)).groups != null)
                return await GetGroupsFromGraphAPI(claimsId);

            return claimsId.FindAll("groups").Select(c => c.Value).ToList();
        }
All Usage Examples Of System.Security.Claims.ClaimsIdentity::FindAll