- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Liferay 6.1,我想更改各个组织的权限,以便这些组织可以由 UserX 与不属于该组织 OrgA 的 RoleX。
特别是:
Control Panel->Users and Organizations
中查看和更新表格我想编程。
到目前为止我尝试了什么:
创建了 RoleX 并赋予其以下权限:
OrgA,范围 4(个人):
ActionKeys.VIEW, ActionKeys.UPDATE, ActionKeys.ASSIGN_USER_ROLES,ActionKeys.DELETE、ActionKeys.MANAGE_USERS
OrgA 小组,范围 4:
ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES,
ActionKeys.CONFIGURE_PORTLETS, ActionKeys.DELETE,
ActionKeys.MANAGE_ANNOUNCEMENTS, ActionKeys.MANAGE_LAYOUTS,
ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.VIEW_MEMBERS
拥有 RoleX 的用户可以访问 Users and Organizations
控制面板中的表单,但他们只能看到他们自己的组织,而不是 OrgA。
如何授予查看和管理 OrgA 的权限?
谢谢
最佳答案
最后,我能够使用 Hook 插件为 RoleX 修改 Resource Permissions
并修改 init users_admin portlet jsp 文件。
主要问题是 Liferay 没有使用 ResourcePermissions 来启用用户所属组织之外的组织管理。
特别是在 portal-trunk/portal-web/docroot/html/portlet/users_admin/init.jsp
中,只有几行代码启用它仅适用于公司管理员角色:
else if (permissionChecker.isCompanyAdmin()) {
filterManageableGroups = false;
filterManageableOrganizations = false;
filterManageableUserGroups = false;
}
所以我在 init.jsp 中添加了以下行(您可以在 Hook 中使用 init-ext.jsp),以便也为 RoleX 启用它:
if (MyUtils.isRoleX()) {
filterManageableGroups = false;
filterManageableOrganizations = false;
filterManageableUserGroups = false;
}
以这种方式,数据库查询不会过滤组织、用户和组。
第二步是定义添加、更新、管理等权限。用户和组织以及访问控制面板中的 portlet。
使用启动操作 Hook 和 ResourcePermisssionLocalService
API 非常简单:
private static final String[] ORGANIZATION_ENTRY_ACTION_IDS = new String[] {
ActionKeys.VIEW, ActionKeys.UPDATE, ActionKeys.ASSIGN_USER_ROLES,
ActionKeys.DELETE, ActionKeys.MANAGE_USERS };
private static final String[] ORGANIZATION_CUSTOM_FIELDS_ENTRY_ACTION_IDS = new String[] {
ActionKeys.VIEW, ActionKeys.UPDATE };
public static final String[] ORGANIZATION_MODEL_ACTION_IDS = new String[] {
ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES,
ActionKeys.DELETE, ActionKeys.MANAGE_ANNOUNCEMENTS,
ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.MANAGE_USERS,
ActionKeys.MANAGE_SUBORGANIZATIONS };
public static final String[] ORGANIZATION_GROUP_ENTRY_ACTION_IDS = new String[] {
ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES,
ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.VIEW_MEMBERS };
private static final String[] PORTAL_ACTION_IDS = new String[] {
ActionKeys.ADD_USER, ActionKeys.ADD_ORGANIZATION,
ActionKeys.VIEW_CONTROL_PANEL };
private static final String[] USERS_ORG_ADMIN_ACTION_IDS = new String[] { ActionKeys.ACCESS_IN_CONTROL_PANEL };
...遗漏...
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
Organization.class.getName(),
ResourceConstants.SCOPE_GROUP_TEMPLATE, "0", CiUtils
.getRoleX().getPrimaryKey(),
ORGANIZATION_MODEL_ACTION_IDS);
// ORGANIZATION MODEL COMPANY PERMISSIONS
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
Organization.class.getName(), ResourceConstants.SCOPE_COMPANY,
Long.toString(companyId),
CiUtils.getRoleX().getPrimaryKey(),
ORGANIZATION_MODEL_ACTION_IDS);
// PORTAL (portlet 90) PERMISSIONS
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
"90", ResourceConstants.SCOPE_COMPANY,
Long.toString(companyId),
CiUtils.getRoleX().getPrimaryKey(),
PORTAL_ACTION_IDS);
// USER_ORG_ADMINS PORTLET (125) PERMISSIONS
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId,
"125", ResourceConstants.SCOPE_COMPANY,
Long.toString(companyId),
CiUtils.getRoleX().getPrimaryKey(),
USERS_ORG_ADMIN_ACTION_IDS);
对于每个组织:
ResourcePermissionLocalServiceUtil.setResourcePermissions(organization.getCompanyId(),
Organization.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long .toString(organization.getPrimaryKey()),
MyUtils.getRoleX().getPrimaryKey(),
ORGANIZATION_ENTRY_ACTION_IDS);
long groupId = organization.getGroupId();
ResourcePermissionLocalServiceUtil.setResourcePermissions(
organization.getCompanyId(),Group.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,Long.toString(groupId),
MyUtils.getRoleX().getPrimaryKey(),
ORGANIZATION_GROUP_ENTRY_ACTION_IDS);
希望这可以帮助其他人。
关于java - 如何为不属于该组织的用户授予角色的组织管理权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13351364/
如何授予 VSTS (TFVC) 用户从分支创建新分支的权限?我已经授予他对 ParentBranch 的“管理分支”和“合并”权限。 当他尝试从“ParentBranch”创建一个名为“ChildB
我在我的 oracle 过程中使用 dbms_crypto.encrypt 函数来加密密码。我已连接到 oracle 为: connect sqlplus as sysdba 然后授予权限: gran
如何在不连接到每一台计算机的情况下将我的 android 设备的 adb 访问权限授予我的所有计算机并按允许? 最佳答案 通过 adb 连接到设备时,每台计算机都会将代码写入 android 设备,以
我有一个 package A ,它在另一个 package B 中使用了一些变量和过程在 相同的架构 .现在想搬家package A到 新架构 .我应该授予 new schema 哪些权限用于使用 p
我需要获取数百个 MS Access DB 的元数据,因此我需要自动化元数据收集过程。 我想查询描述的内容 here ,但在查询数据库之前,我需要对 MSysObjects 进行读取 Access 表
我有一个 JApplet,我想授予它读写打印等权限。该小程序仅从本地文件系统加载 我已经阅读了java教程的控制小程序部分,并成功创建了一个策略文件,授予权限并指定代码库 http://docs.or
我正在使用 phpmyadmin 来调整用户的权限。 我删除了用户“root”的所有访问权限。现在我看不到表格了。 我尝试用另一个用户登录,但它不允许我。 此时我有什么选择? 第 1 步。 //Sto
Mysql 服务器允许从本地主机访问匿名用户。我也想将此权限扩展到其他机器...即,使用没有任何密码的匿名用户从机器 B 的 mysql 客户端访问在机器 A 中运行的 mysql_server。 我
为所有想要连接的新用户授予 MySQL 数据库访问权限的命令是什么? 考虑这个陈述: CREATE USER 'java'@'localhost' IDENTIFIED BY 'password';
我在尝试通过 t 为 mysql 用户授予数据库权限时遇到了一个问题。我认为这是因为数据库名称中的特殊字符。 这个正在工作: /usr/bin/mysql -uroot -pXz5eaCqwvsT0p
我可以在 GRANT 语句中使用静态数据库名称授予权限。 GRANT SELECT,INSERT ON database_name.table_name TO 'username'@'localhos
授予 Facebook 应用查看我的赞的权限是否允许该应用的所有其他用户也看到我的赞? 或者同一应用的其他用户能否看到我的点赞取决于我的点赞隐私设置? 例如,假设我只允许好友看到我的赞。这是否意味着该
我在这里敲了几个小时的脑袋。 我正在向数据库添加用户和密码,同时尝试授予权限。 GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TA
我正在尝试在 Flask 中创建一个自定义错误页面,我想让错误处理程序访问生成导致错误的 API 调用的请求,以便它返回的错误页面可以更改,具体取决于情况。例如,假设有两个端点: (1) @app.r
我已经编写了一个简短的快速代码来向查找器添加一个按钮,该按钮通过系统 touch 调用在当前目录中创建一个新的空白文件。该扩展可以很好地获取当前目录(通过 FIFinderSyncController
当我运行 hdf namenode -format 时,它想要删除目录 /home/hadoop/hadooptmpdata/dfs/name/current 但它没有权限执行此操作。如何授予它权限?
我正在用 C# 编写一个应用程序(对于我的一个 friend 来说,这是非常基础的),但是我有一个 StreamWriter 对象,它在 C: 中创建一个本地文件。我必须以管理员身份运行,它工作正常,
我已经安装了 Centos5,安装了 Web 服务器并设置了虚拟主机。主机几乎是这样设置的: > adduser user1 > mkdir -p /home/user1/public_html/do
我正从 MySQL 迁移到 PostgreSQL,但在用户权限方面遇到了瓶颈。我习惯于使用以下命令为用户分配对数据库所有表的所有权限: # MySQL grant all privileges on
我试图为特定用户授予对 UNC 路径的 NTFS 权限,但我看到了不同的行为,具体取决于 UNC 路径。下面是我用来授予权限的代码(来自 MSDN)以及每种情况下的结果, static void Gi
我是一名优秀的程序员,十分优秀!