Modify node users permissisons programatically

cancel
Showing results for 
Search instead for 
Did you mean: 
oviwonkenovi
Active Member

Modify node users permissisons programatically

Jump to solution

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 Solution

Accepted Solutions
oviwonkenovi
Active Member

Re: Modify node users permissisons programatically

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

 

View solution in original post

2 Replies
oviwonkenovi
Active Member

Re: Modify node users permissisons programatically

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

 

EddieMay
Alfresco Employee

Re: Modify node users permissisons programatically

Jump to solution

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!