Find a group by group name with Groovy
I currently use this Groovy script to get the user of a group. Is there any way to simplify this and query a group using the group name directly instead of the full path to the group?
long groupId = identityAPI.getGroupByPath("/amce/hr/mygroup").id SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 1) builder.filter(UserSearchDescriptor.GROUP_ID, groupId) long userId = identityAPI.searchUsers(builder.done())result.get(0).id
1 answer
Hi,
A group name is not a unique identifier, since you can have several groups with the same name, for example, the group name is "europe" for both paths:
- "/acme/sales/europe"
- "/acme/hr/europe"
So you can use the path or the ID (identityAPI.getGroup(long groupId)) to identify a Group, but you can't use the Name.
HTH,
Marielle