cancel
Showing results for 
Search instead for 
Did you mean: 

Block permissions inheritance programatically

bledii_
Confirmed Champ
Confirmed Champ

Hello,

is it possible to block permission inheritance via API?

When we try by resetting the ACP it seems not to work, and still permissions are inherited.

Thank you

EDIT: my use case is the following:

i want to create a document (folder) inside a tree of other folders, but want only the creator and users from the admin group to have access on it

1 ACCEPTED ANSWER

bruce_Grant
Elite Collaborator
Elite Collaborator

Don't know about the API, but you could create a listener for various document creation events (DOCUMENT_CREATED, DOCUMENT_CREATED_BY_COPY, DOCUMENT_DUPLICATED, etc.) and then remove inheritance and set default ACL.

Something like...

DocumentRef docRef = docModel.getRef();
ACP acp = this.session.getACP(docRef);
						
// delete existing 'local' ACL 
acp.removeACL(ACL.LOCAL_ACL);

// block inheritance
acp.getOrCreateACL().add(new ACE(SecurityConstants.EVERYONE, SecurityConstants.EVERYTHING, false));

// and then create the local ACL entries you do want
ACL acl = acp.getOrCreateACL(ACL.LOCAL_ACL);
... and then create desired ACEs ...
acl.add(new ACE("testgroup","Read", true));
acp.addACL(acl);
this.session.setACP(docRef, acp, true);

View answer in original post

10 REPLIES 10

Florent_Guillau
World-Class Innovator
World-Class Innovator

@vieville Automation is a different matter, please ask a new question.