cancel
Showing results for 
Search instead for 
Did you mean: 

Determine roles assigned to a given user

burriad
Champ in-the-making
Champ in-the-making
Once again, I struggle with the permissions in alfresco: I'd like to find, on a particular node, whether a user is assigned a given role. (I'm only interested in statically assigned roles, since I want to dynamically add new ones based on the configured ones)

Is this programmatically possible and if yes, how?

I've been trying my luck with the following code:

boolean result = permissionService.hasPermission(nodeRef, permString);
Unfortunately, this is going in an endless loop, since the code is part of a dynamic authority and hasPermission adds dynamical authorities as well…
2 REPLIES 2

burriad
Champ in-the-making
Champ in-the-making
Once again, I answer myself:

   NodePermissionEntry nodePermissions = permissionsDaoComponent.getPermissions(nodeRef);
   List<? extends PermissionEntry> permEntries = nodePermissions.getPermissionEntries();
      
      Set<String> auths = authorityService.getAuthorities();
       auths.add(userName);
      for (PermissionEntry permEntry : permEntries) {
                if (permEntry.getPermissionReference().equals(basePermission) &&
               auths.contains(permEntry.getAuthority()) &&
               permEntry.getAccessStatus() == AccessStatus.ALLOWED) {
            return AccessStatus.ALLOWED;
         }
      }

The best pointer was once again not the documentation, which is either sparse or dated, but the database scheme. Here the tables and a short description, which helped me to understand what is going on behind the scene:
  • alf_permission: the roles and permissions

  • alf_authority: the groups and users

  • alf_access_control_list: one entry per node; contains also information about inheritance of permissions

  • alf_access_control_entry: the entry mathes permissions (roles) and authorities (groups and users)

  • alf_acl_member: this is the crucial part, as it maps the granted permissions to the actual nodes. Going backward from this table, I was able to deduce the correct API call…

binu
Champ in-the-making
Champ in-the-making
Hi,

I am using Alfresco Version 2.1 and using it for almost 2 years now.   Can anyone guide me a way to see the list of all spaces and documents in Alfresco and see the permissions for each.

Thanks

Binu Manickkam Pillai.