cancel
Showing results for 
Search instead for 
Did you mean: 

How to get User's group using java api

baallee
Champ in-the-making
Champ in-the-making
hello i want custom ui ,when use login hide/show some thing depend on user's group,please tell me how to do it and where has sample code in Alfresco?
Thanks!
3 REPLIES 3

dhalupa
Champ on-the-rise
Champ on-the-rise
Use the following snippet
serviceRegistry.getAuthorityService().getAuthoritiesForUser(userName)

kind regards,

Denis

maratische
Champ in-the-making
Champ in-the-making
for Admin user it works, but I got this error for not Admin user:
Caused by: org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied. You do not have the appropriate permissions to perform this operation.

why?

dhalupa
Champ on-the-rise
Champ on-the-rise
Isn't it obvious? Smiley Happy Because you do not have permission to execute that method. Run the invocation of that method as admin user

AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Set<String>>() {
   public Set<String> doWork() throws Exception {
      return serviceRegistry.getAuthorityService().getAuthoritiesForUser("someUser");
   }
}, "admin");

Kind regards,

Denis