I'm working with ADF and I would like to change a Node permisions to disable heritage and set permisión to a especific group and user. In ADF there are various elements to allow the user to handle permisions. However I would like to make this programatically as i will set always same permissions and y would like to make it automatically.
I have been taking a look to the PermisionService. But i haven't found a way to remove all permisions and se just the ones I like. Does anybody has or knows where i can find a sample code for setting programatically the permissions of a node.
thanks!!
Solved! Go to Solution.
Pretty easy, simply use nodeApiService.updateNode with update body like this
const update = { permissions: { isInheritanceEnabled: false, locallySet: [ { authorityId: 'user1', name: 'Collaborator', accessStatus: 'ALLOWED', }, { authorityId: 'GROUP_group1', name: 'Read', accessStatus: 'ALLOWED', }, ], }, }; this.nodeApiService.updateNode(nodeId, update).subscribe( (updatedNode) => (console.log("done")), (err) => { console.log(`Error Setting node permissions ${err}`); this.onFailed(`Error Updating Permissions.`); } );
Pretty easy, simply use nodeApiService.updateNode with update body like this
const update = { permissions: { isInheritanceEnabled: false, locallySet: [ { authorityId: 'user1', name: 'Collaborator', accessStatus: 'ALLOWED', }, { authorityId: 'GROUP_group1', name: 'Read', accessStatus: 'ALLOWED', }, ], }, }; this.nodeApiService.updateNode(nodeId, update).subscribe( (updatedNode) => (console.log("done")), (err) => { console.log(`Error Setting node permissions ${err}`); this.onFailed(`Error Updating Permissions.`); } );
Thanks for updating us with how you solved your issue. It's really helpful to other users when someone does this.
So, thanks again.
ps - I'll also mark this as Solution Accepted.
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.