AI OnAI Off
As a workaround, can't you refresh the object in your event handler? Call CacheHandler.RemoveCachedObject in a way similar to what EntitySecurityHandler.SetAccessRights does, and then re-load the entity instead of using the instance you get with the eventargs.
Im working on getting EPiServer Find to index the community entities but im having problems with reindexing when access rights is changed. When a group is added to the access rights i would like that to be added to the index right away.
I have tried to add an eventhandler to EntitySecurityHandler.Instance.AccessRightsSet and EntitySecurityHandler.Instance.AccessRightsRemoved but it seems that the changes that was made is not there at that point.
My code looks something like this:
I did a bit of decompiling and dug around in EPiServers code it seems that the AccessRightsSet event is triggered after the update of the accessrights but before the database cache is invalidated and the entity that is sent to the eventhandler is the exact same as before the change in access rights.
EntitySecurityHandler:
EntitySecurityFactory:
Anyone got any ideas on how to get around this?