9.2.5. Mapping Groups to different contexts
Sometimes may be useful to map a specific group to a specific context or DN.
The following configuration maps the group with path /QA Group to ou=QA,ou=Groups,dc=jboss,dc=org
mapping(Group.class) .baseDN(embeddedServer.getGroupDnSuffix()) .objectClasses(GROUP_OF_NAMES) .attribute("name", CN, true) .readOnlyAttribute("createdDate", CREATE_TIMESTAMP) .parentMembershipAttributeName("member") .parentMapping("QA Group", "ou=QA,ou=Groups,dc=jboss,dc=org")
With this configuration you can have groups with the same name, but with different paths.
IdentityManager identityManager = getIdentityManager(); Group managers = new SimpleGroup("managers"); identityManager.add(managers); // group's path is /manager Group qaGroup = identityManager.getGroup("QA Group"); Group managersQA = new SimpleGroup("managers", qaGroup); // the QA Group is mapped to a different DN. Group qaManagerGroup = identityManager.add(managersQA); // group's path is /QA Group/managers