Sensenet : Node permission getting older value after updated permissions

83 views Asked by At

I have change node permission by updating 'SecurityEntries' and 'SecurityCustomeEntries' tables using direct database call (not through API). I have found that it is fetching older value from API, even database table's values has been updated successfully. I need latest updated value from API. How can I get it?

Update Query For Deny AddNew permission

Update SecurityEntries set PermissionValue7 = '2' AND PermissionValue15 = '2' where DefinedOnNodeId = 'XXXX' AND PrincipalId='XXXXX';

Check 'AddNew' Permission after update above query (which is returning true)

node.Security.HasPermission((IUser)emailUserObj, PermissionType.AddNew);

The above HasPermission method of API is returning older value.

I observed one more thing that once I have create any other new node then it the it is ('HasPermission' method) showing latest value of permissions for above node.

Is there any caching or something else?

1

There are 1 answers

2
Miklós Tóth On

Yes, sensenet caches permission values to speed up permission evaluation. It would be very slow if we looked into the db every time a permission check is needed. This is one of the reasons why it is not advisable to modify permissions directly in the database. Another reason is it may break something if you make an incompatible change :).

Please do it through our API, either using the server-side c# permission API (referencing the main Services package) or the client side c# api (using the .Net client).

Changing permissions, creating content or restarting the site resets this cache, this is why you see changes after you create something.