cancel
Showing results for 
Search instead for 
Did you mean: 

Modify node users permissisons programatically

oviwonkenovi
Champ on-the-rise
Champ on-the-rise

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!!

1 ACCEPTED ANSWER

oviwonkenovi
Champ on-the-rise
Champ on-the-rise

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.`);
      }     
    );

View answer in original post

2 REPLIES 2

oviwonkenovi
Champ on-the-rise
Champ on-the-rise

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.`);
      }     
    );

EddieMay
World-Class Innovator
World-Class Innovator

Hi @oviwonkenovi 

Thanks for updating us with how you solved your issue. It's really helpful to other users when someone does this.

So, thanks again.Smiley Happy

ps - I'll also mark this as Solution Accepted. 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!