System.Web.Security.RolePrincipal.GetRoles C# (CSharp) Method

GetRoles() public method

public GetRoles ( ) : string[]
return string[]
		public string [] GetRoles ()
		{
			if (!_identity.IsAuthenticated)
				return new string[0];

			if (!IsRoleListCached || Expired) {
				_cachedArray = Provider.GetRolesForUser (_identity.Name);
				_cachedRoles = new HybridDictionary (true);

				foreach (string r in _cachedArray)
					_cachedRoles.Add(r, r);

				_listChanged = true;
			}

			return _cachedArray;
		}
		

Usage Example

        protected override IClaimsIdentity GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope)
        {
            if (null == principal)
            {
                throw new ArgumentNullException("principal");
            }

            var outputIdentity = new ClaimsIdentity();
            var roles = new RolePrincipal(principal.Identity);

            outputIdentity.Claims.Add(new Claim(ClaimTypes.Name, principal.Identity.Name));
            outputIdentity.Claims.Add(new Claim(ClaimTypes.Role, roles.GetRoles().First()));

            return outputIdentity;
        }
All Usage Examples Of System.Web.Security.RolePrincipal::GetRoles