07-09-2020 09:12 AM
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!!
08-31-2020 10:16 AM
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.`); } );
08-31-2020 10:16 AM
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.`); } );
09-10-2020 12:19 PM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.