cancel
Showing results for 
Search instead for 
Did you mean: 

disable permission inheritance

nick_l
Champ in-the-making
Champ in-the-making
There are some topic about this issue. Currently, I am using Alfresco 4.2 community version.

So far I didn't find any API which can disable the permission inheritance. Typically, the root folder has the (GROUP_EVERYONE, consumer) permission, which I don't want its sub-folders to inherit. I can manually disable it from admin console, but failed to find any java API to do so.

I tried to removed the (GROUP_EVERYONE, consumer) permission from root folder in admin console. Then trying to login as a non-admin user using following code, but it gives me "org.alfresco.repo.security.permissions.AccessDeniedException - 01209024 Access Denied.  You do not have the appropriate permissions to perform this operation."

Any suggestions?

—-code—-
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();

parameter.put(SessionParameter.USER, userName);
parameter.put(SessionParameter.PASSWORD, password);
parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true" );

parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/api/cmis");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

List<Repository> repositories = new ArrayList<Repository>();
repositories = sessionFactory.getRepositories(parameter);

// create session with the first (and only) repository
Repository repository = repositories.get(0);
parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());

Session session = sessionFactory.createSession(parameter);

—–code end——
5 REPLIES 5

lista
Star Contributor
Star Contributor
How do you mean you haven't found any API supporting this?
You can do this with JS or with Java, you shouldn't have any problems.

http://wiki.alfresco.com/wiki/4.0_JavaScript_API#Permission_and_Security_API

nick_l
Champ in-the-making
Champ in-the-making
I am using the web service api only.

jpotts
World-Class Innovator
World-Class Innovator
Currently there is no way to break inheritance using the CMIS API. You must use another approach, such as writing a custom web script that leverages the JavaScript or Java foundation API.

Jeff

nick_l
Champ in-the-making
Champ in-the-making
I found that in java code, accessControlService.setInheritPermission(predicate, boolean) can break the inheritance.
But it looks like being supported by Alfresco

muralidharand
Star Contributor
Star Contributor
Hi Nick,
I used the below code to break the inherit permission for the tag nodes.
In your case, first identify the node, then stop the permission inheritance by setting , node.setInheritsPermissions(false);


var results = search.xpathSearch("/cm:taggable/cm:mytag");

for(var i=0;i<results.length;i++)
{
   var node  = results;         
   node.setInheritsPermissions(false);   
   node.removePermission("Collaborator","GROUP_EVERYONE");
   node.setPermission("Collaborator", "GROUP_MyCustomGroup");   
   node.save();
}


Hope this helps you.