コード例 #1
0
        public static void ClearPermissionsForRole(string role)
        {
            GetRolePermissions();
            GetRoleCategoryPermissions();

            foreach (RoleCategoryPermissions rcp in roleCategoryPermissions)
            {
                if (rcp.RoleName.ToLower() == role.ToLower())
                {
                    RoleCategoryPermissions.Destroy(rcp.Id);
                }
            }

            foreach (RolePermissions rp in rolePermissions)
            {
                if (rp.RoleName.ToLower() == role.ToLower())
                {
                    RolePermissions.Destroy(rp.Id);
                }
            }
        }
コード例 #2
0
ファイル: GraffitiUsers.cs プロジェクト: harder/GraffitiCMS
        public static void DeleteRole(string roleName)
        {
            // Remove users from role
            List <IGraffitiUser> roleUsers = GraffitiUsers.GetUsers(roleName);

            if (roleUsers != null && roleUsers.Count > 0)
            {
                foreach (IGraffitiUser user in roleUsers)
                {
                    GraffitiUsers.RemoveUserFromRole(user.Name, roleName);
                }
            }

            RolePermissionsCollection         rp  = RolePermissionManager.GetRolePermissions();
            RoleCategoryPermissionsCollection rpc = RolePermissionManager.GetRoleCategoryPermissions();

            foreach (RolePermissions rperm in rp)
            {
                if (String.Compare(rperm.RoleName, roleName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    RolePermissions.Destroy(RolePermissions.Columns.RoleName, rperm.RoleName);
                    break;
                }
            }

            foreach (RoleCategoryPermissions rcatperm in rpc)
            {
                if (String.Compare(rcatperm.RoleName, roleName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    RoleCategoryPermissions.Destroy(RolePermissions.Columns.RoleName, rcatperm.RoleName);
                    break;
                }
            }

            RolePermissionManager.MarkDirty();

            // Remove role from other membership databases
            controller.DeleteRole(roleName);
        }