Skip to main content
15-Moonstone
March 18, 2021
Solved

how to set RUNTIMEPERMISSION for specific service?

  • March 18, 2021
  • 1 reply
  • 953 views

Hi, I need to set run time permission for specific service(eg. ChangePassword() ) to particular users.

I tried using AddRunTimePermission() but I am getting invalid service name error.

 

Users[testUser].AddRunTimePermission({
allow: true /* BOOLEAN */ ,
principal: testUser/* STRING */ ,
resource: "ChangePassword" /* STRING */ ,
type: "ServiceExecute" /* STRING */ ,
principalType: "User" /* STRING */
});

 

err : 36JavaException: java.lang.Exception: Invalid Permission Type : [ServiceExecute]

Best answer by sabharees

Hi All,

the correct code for enabling permission to particular code : 

 

 

Users[username].AddRunTimePermission({
allow: true /* BOOLEAN */ ,
principal: username /* STRING */ ,
resource: "your service name 1, your service name 2" /* STRING */ ,
type: "permission type" /* STRING */ ,
principalType: "User" /* STRING */
});

 

Got answers by myself, hope this will be helpful for others too... 

1 reply

sabharees15-MoonstoneAuthorAnswer
15-Moonstone
March 18, 2021

Hi All,

the correct code for enabling permission to particular code : 

 

 

Users[username].AddRunTimePermission({
allow: true /* BOOLEAN */ ,
principal: username /* STRING */ ,
resource: "your service name 1, your service name 2" /* STRING */ ,
type: "permission type" /* STRING */ ,
principalType: "User" /* STRING */
});

 

Got answers by myself, hope this will be helpful for others too...