liferay 按角色启用组织或社区

发布于 2024-10-28 01:15:14 字数 322 浏览 4 评论 0原文

我正在开发一个新的 liferay 实现。我的所有用户都在外部系统中,并且使用了外部环境。通过我自己的身份验证系统进行身份验证。我还将角色存储在同一个系统中。我已经能够成功地将这些传递给 liferay,以便我的所有用户角色都可以在 liferay 中使用。

我想创建一个与角色关联的组织或社区。例如,如果我在外部系统中有一个名为“myusers”的角色,我想将该角色与 liferay 中的组织或社区联系起来。然后,当用户以该角色登录 liferay 时,他们将能够成为该组织或社区的一部分。这在liferay中可能吗?我知道这有点倒退到 liferay 中向用户添加角色,然后将用户添加到社区或组织的正常流程。

I am working on a new liferay implementation. I have all of my users in an external system, and have used the external env. to authenticate through my own authentication system. I also store roles in this same system. I have been able to successfully pass these to liferay so that all of my users roles are available in liferay.

I would like to create an organization or community that is associated with a role. For example if I have a role called 'myusers' in my external system, I would like to tie that role to an organization or community in liferay. Then when a user logged in to liferay with that role, they would be able to be part of that organization or community. Is this possible in liferay? I know it's kind of backwards to the normal flow in liferay of adding roles to users and then adding user to a community or organization.

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

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

发布评论

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

评论(2

野却迷人 2024-11-04 01:15:14

您可以修改以下代码来检查用户是否属于某个角色,然后将其添加到适当的组织。

要将用户添加到所有组织:

public final static void addAllOrganizationstoUser(long userId) throws SystemException, PortalException {
    // gets all organizations
    List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(ALL_POS, ALL_POS);
    long[] users = new long[]{userId};
    // register user to orgs
    for (Organization organization : organizations) {
      UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(), users);
    }
}

You can modify the below code to check if the user belongs to a role and then add him to the appropriate organization.

To add a user to all Organizations:

public final static void addAllOrganizationstoUser(long userId) throws SystemException, PortalException {
    // gets all organizations
    List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(ALL_POS, ALL_POS);
    long[] users = new long[]{userId};
    // register user to orgs
    for (Organization organization : organizations) {
      UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(), users);
    }
}
谁的新欢旧爱 2024-11-04 01:15:14

我最终做的是使用 liferay 内置的 Expando 功能。通过这样做,我允许输入应映射到该组织的角色列表。这使我能够在用户登录时查看他们的角色,并确定他们应该成为哪些组织的成员。然后,我根据 Expando 属性中定义的角色以及分配给用户的角色,以编程方式在组织中添加/删除用户。

What I ended up doing was using the expando functionality built into liferay. Doing this I allow for entering a list of roles that should map to that organization. This allows me to look at the roles of my users when they login and determine what organizations they should be a member of. I then programatically add/remove the users from the organizations based upon the roles defined in the expando attribute and the roles assigned to the user.

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