コード例 #1
0
        public static bool HasPermission(string username, Common.AdminPermission[] AllowedPermissions)
        {
            try
            {
                var role = SecurityQuery.GetRoleByUsername(username);

                //Return true if the user is a Super Admin
                if (role.Permissions.Any(r => r.Name.ToLower() == Common.AdminPermission.SuperAdminPermission.ToString().ToLower()))
                    return true;

                foreach (var permission in AllowedPermissions)
                {
                    if (role.Permissions.Any(r => r.Name.ToLower() == permission.ToString().ToLower()))
                        return true;
                }

                return false;
            }
            catch (Exception ex)
            {
                LogManager.LogException(ex);
                return false;
            }
        }
コード例 #2
0
 public PermissionCategoryAttribute(Common.PermissionCategory category)
 {
     Category = category.ToString();
 }