System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll

    Extension methods on System.Security.Principal.IPrincipal

    IPrincipalExtensions

    public static class IPrincipalExtensions

    Inheritance
    object
    IPrincipalExtensions
    Examples
    Arguments
    X

    Methods

    Check if principal is in any role, case sensitive

    Remarks
    X

    Passing Enum for roles to match, will simply call .ToString() on the EnumKey

    • It ignores EnumValue attribute
    • For that, you would simply use ToValue() on your Enum as argument to the method

    public static bool IsInAnyRole(this IPrincipal principal, params object[] roles)

    X

    Object array as argument:

    enum AdminRoles { Admin, MasterAdmin };
    var roles = new object[] { AdminRoles.Admin, AdminRoles.MasterAdmin };
    var isInAnyRole = principal.IsInAnyRole(roles);

    Strings as argument

    var isInAnyRole = principal.IsInAnyRole("Admin", "Guest");

    Enum as arg

    var isInAnyRole = principal.IsInAnyRole(AdminRoles.Admin, AdminRoles.MasterAdmin);
    X
    Methods arguments
    Type Name Description
    IPrincipal principal
    object[] roles
    X
    Type Description
    bool

    True of false

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework