ckfinder 无法识别角色?

发布于 2024-08-31 08:03:12 字数 1860 浏览 7 评论 0原文

如果有人可以帮忙解决这个问题。

我正在尝试将 ckeditor 和 ckfinder 合并到 Asp.Net Mvc 1 项目中。到目前为止一切正常。我唯一无法正常工作的是 ckfinder 的访问控制。

据我了解,在文件 ckfinder/config.ascx 中,变量字符串 RoleSessionVar 用于分配要限制的角色。默认值是:

RoleSessionVar = "CKFinder_UserRole";

我的项目中有管理员、编辑者和贡献者树角色。因此,为了获取当前用户角色,我将其替换为:

    string currentRole= "";

    if(HttpContext.Current.User.IsInRole("Administrators"))
    {
        currentRole = "Administrators"; 
 }
    else
    {
        if (HttpContext.Current.User.IsInRole("Editors"))
            currentRole = "Editors";
        else
        {
            if (HttpContext.Current.User.IsInRole("Contributors"))
            {
                currentRole = "Contributors";
            }
        }
    }


    RoleSessionVar = currentRole;

为变量分配当前用户的正确角色。 config.ascx 文件中的下一部分是 ACL 设置。默认为:

 AccessControl acl = AccessControl.Add();
    acl.Role = "*";

acl.ResourceType = "*"; acl.Folder = "/";

    acl.FolderView = true;
    acl.FolderCreate = true;
    acl.FolderRename = true;
    acl.FolderDelete = true;

    acl.FileView = true;
    acl.FileUpload = true;
    acl.FileRename = true;
    acl.FileDelete = true; 

通过这些设置,ckfinder 不会出现任何问题,它会列出所有文件夹和文件,但每个人都具有完全权限。我想限制不同角色的删除权限。无论如何,作为一个测试,我尝试授予管理员角色

    AccessControl acl = AccessControl.Add();
    acl.Role = "Administrators";

acl.ResourceType = "*"; 的完全权限。 acl.Folder = "/";

    acl.FolderView = true;
    acl.FolderCreate = true;
    acl.FolderRename = true;
    acl.FolderDelete = true;

    acl.FileView = true;
    acl.FileUpload = true;
    acl.FileRename = true;
    acl.FileDelete = true; 

但即使 RoleSessionVar =“Administrators”,ckfinder 也不会显示任何文件夹或文件。

我将非常感谢您对解决此问题的任何帮助。

拜伦

if somebody could help with this please.

I am trying to incorporate ckeditor and ckfinder to an Asp.Net Mvc 1 project. SO far everything is working fine. The only thing I cann't get to work right is the Access Control for ckfinder.

For what I understand, in the file ckfinder/config.ascx, the variable string RoleSessionVar is used to assign the role to be restricted. The default value is:

RoleSessionVar = "CKFinder_UserRole";

I have tree roles in my project Administrators, Editors and Contributors. So in order to get my current user Role I replace it for:

    string currentRole= "";

    if(HttpContext.Current.User.IsInRole("Administrators"))
    {
        currentRole = "Administrators"; 
 }
    else
    {
        if (HttpContext.Current.User.IsInRole("Editors"))
            currentRole = "Editors";
        else
        {
            if (HttpContext.Current.User.IsInRole("Contributors"))
            {
                currentRole = "Contributors";
            }
        }
    }


    RoleSessionVar = currentRole;

The variable gets assigned with the correct Role for the current user. The next part in the config.ascx file are the ACL settings. The default one are:

 AccessControl acl = AccessControl.Add();
    acl.Role = "*";

acl.ResourceType = "*";
acl.Folder = "/";

    acl.FolderView = true;
    acl.FolderCreate = true;
    acl.FolderRename = true;
    acl.FolderDelete = true;

    acl.FileView = true;
    acl.FileUpload = true;
    acl.FileRename = true;
    acl.FileDelete = true; 

With these settings there are not any problems the ckfinder, it lists all the folders and files, but there with full permissions for everyone. I want to restrict deleting permissions to different Roles. Anyway just as a test I tried to give full permissions to Administrators' Role

    AccessControl acl = AccessControl.Add();
    acl.Role = "Administrators";

acl.ResourceType = "*";
acl.Folder = "/";

    acl.FolderView = true;
    acl.FolderCreate = true;
    acl.FolderRename = true;
    acl.FolderDelete = true;

    acl.FileView = true;
    acl.FileUpload = true;
    acl.FileRename = true;
    acl.FileDelete = true; 

But ckfinder will not show any folder or file even though RoleSessionVar = "Administrators".

I'll be very thankful for any ligh to the solution of this problem.

Byron

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〃温暖了心ぐ 2024-09-07 08:03:12

您需要执行

Session["RoleSessionVar"] = currentRole;

You need to do

Session["RoleSessionVar"] = currentRole;

只是一片海 2024-09-07 08:03:12

你应该尝试:

Session["CKFinder_UserRole"] = currentRole;

you should try:

Session["CKFinder_UserRole"] = currentRole;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文