当前位置: 首页>>代码示例>>C#>>正文


C# ClaimsIdentity.FindAll方法代码示例

本文整理汇总了C#中System.Security.Claims.ClaimsIdentity.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# ClaimsIdentity.FindAll方法的具体用法?C# ClaimsIdentity.FindAll怎么用?C# ClaimsIdentity.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Claims.ClaimsIdentity的用法示例。


在下文中一共展示了ClaimsIdentity.FindAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetGroups

        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();
        }
开发者ID:EgyTechnology,项目名称:WebApp-GroupClaims-DotNet,代码行数:8,代码来源:ClaimHelper.cs

示例2: GetMemberGroups

        /// <summary>
        /// For access check user's group membership must be determined. 
        /// This method retrieves user's group membership from Azure AD Graph API if not present in the token.
        /// </summary>
        /// <param name="claimsIdentity">The <see cref="ClaimsIdenity" /> object that represents the 
        /// claims-based identity of the currently signed in user and contains thier claims.</param>
        /// <returns>A list of ObjectIDs representing the groups that the user is member of.</returns>
        public static async Task<List<string>> GetMemberGroups(ClaimsIdentity claimsIdentity)
        {
            //check for groups overage claim. If present query graph API for group membership
            if (claimsIdentity.FindFirst("_claim_names") != null
                && (Json.Decode(claimsIdentity.FindFirst("_claim_names").Value)).groups != null)
                return await GetGroupsFromGraphAPI(claimsIdentity);

            return claimsIdentity.FindAll("groups").Select(c => c.Value).ToList();
        }
开发者ID:tandis,项目名称:PnP,代码行数:16,代码来源:GraphUtil.cs

示例3: FindUserKey

 public static string FindUserKey(ClaimsIdentity claimsIdentity)
 {
     if (claimsIdentity == null)
     {
         throw new ArgumentNullException("claimsIdentity");
     }
     Claim nameIdentifierClaim = claimsIdentity.FindAll(ClaimTypes.NameIdentifier).SingleOrDefault();
     if (nameIdentifierClaim == null)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Claim type '{0}' was not found.", ClaimTypes.NameIdentifier));
     }
     return nameIdentifierClaim.Value;
 }
开发者ID:modulexcite,项目名称:StudentSuccessDashboard,代码行数:13,代码来源:EducationSecurityIdentity.cs

示例4: CreateProperties

        public static AuthenticationProperties CreateProperties(ClaimsIdentity identity)
        {
            var roleClaimValues = identity.FindAll(ClaimTypes.Role).Select(c => c.Value);

            var roles = string.Join(",", roleClaimValues);

            IDictionary<string, string> data = new Dictionary<string, string>
            {
                { "userName", identity.FindFirstValue(ClaimTypes.Name) },
                { "userRoles", roles }
            };

            return new AuthenticationProperties(data);
        }
开发者ID:rioka,项目名称:ASP.NET-MVC-5-Durandal,代码行数:14,代码来源:AuthenticationPropertiesConfig.cs

示例5: FindCaseInsensivity

		public void FindCaseInsensivity ()
		{
			var claim_type = new Claim("TYpe", "value");
			var id = new ClaimsIdentity (
				new[] { claim_type },
				"base_auth_type", "base_name_claim_type", null);

			var f1 = id.FindFirst ("tyPe");
			Assert.AreEqual ("value", f1.Value, "#1");

			var f2 = id.FindAll ("tyPE").First ();
			Assert.AreEqual ("value", f2.Value, "#2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:ClaimsIdentityTest.cs


注:本文中的System.Security.Claims.ClaimsIdentity.FindAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。