コード例 #1
0
    public static bool IsSysAdmin(this ControllerBase controller)
    {
        bool bIsSysAdmin = false;

        try
        {
            //Check if the requesting user has the System Administrator privilege...
            bIsSysAdmin = new ActualUser(controller.ControllerContext.HttpContext.User.Identity.Name).IsSysAdmin;
        }
        catch { }
        return(bIsSysAdmin);
    }
コード例 #2
0
    public static bool HasPermission(this ControllerBase controller, string permission)
    {
        bool bFound = false;

        try
        {
            //Check if the requesting user has the specified application permission...
            bFound = new ActualUser(controller.ControllerContext.HttpContext.User.Identity.Name).HasPermission(permission);
        }
        catch { }
        return(bFound);
    }
コード例 #3
0
    public static bool HasRole(this ControllerBase controller, string Role)
    {
        bool bFound = false;

        try
        {
            //Verifica que un usuario tenga un rol dado
            bFound = new ActualUser(controller.ControllerContext.HttpContext.User.Identity.Name).HasRole(Role);
        }
        catch { }
        return(bFound);
    }
コード例 #4
0
    public static bool HasRoles(this ControllerBase controller, string Roles)
    {
        bool bFound = false;

        try
        {
            // Verifica que el usuario tiene alguno de los Roles dados.
            //Los Roles deber estar separados por ; (ie "Sales Manager;Sales Operator"
            bFound = new ActualUser(controller.ControllerContext.HttpContext.User.Identity.Name).HasRoles(Roles);
        }
        catch { }
        return(bFound);
    }