spring-bootcamundabpmnbusiness-process-management

Check membership user in group or tenant in camunda with Java API


How can we get boolean result with Java API if a user is actually membership in some group or tenant in camunda. This is for exception handling and logic to not save duplicate users on groups and tenants. I know we neew userService but I not found that method.


Solution

  • Not really sure, but probably something like this should work:

    private final IdentityService identityService;
    
    private boolean isUserAMemberOfTenant(String userId, String tenantId) {
        return identityService.createUserQuery().userId(userId).memberOfTenant(tenantId).count() > 0;
    }
    
    private boolean isUserAMemberOfGroup(String userId, String groupId) {
        return identityService.createUserQuery().userId(userId).memberOfGroup(groupId).count() > 0;
    }