Authorization rules

Authorization rules

Old forum URL:

Adalton4 posted on Wednesday, October 13, 2010


I have a problem concerning the Authorization rules rules.


My setup is CSLA 4.01/Silverlight/MVVM


I followed the general way to handle this as per the demo's provided with the videos around Silverlight and MVVM. Basically, i set up the binding and make it do its job via a propertstatus object.


I have a use case where i have an object with an IsSystem property which states that if it is set, then the object can only be edited by a "Developer" profile.

So the way to go, i thought, was to make an override of CanWriteProperty as follows:


public override bool CanWriteProperty(Csla.Core.IPropertyInfo property)


    if(ReadProperty(IsSystemProperty) == 1 && !Csla.ApplicationContext.User.IsInrole("Developer")) return false;

    return base.CanWriteProperty(property);



This works, but only for the first time its used. I tracked this down to the fact that the authorization rules are cached. So, obviously, i'm not going the right direction.


Can anybody point in the correct way to resolve this?

JonnyBee replied on Wednesday, October 13, 2010

You must override CanWriteProperty like this:

    public override bool CanWriteProperty(Csla.Core.IPropertyInfo property)
      if(ReadProperty(IsSystemProperty) == 1 && !Csla.ApplicationContext.User.IsInrole("Developer")) return false;

      // must override so that authorization rules are not cached
      return BusinessRules.HasPermission(AuthorizationActions.WriteProperty, property);

base.CanWriteProperty(..) - is the method that does the caching.

Adalton4 replied on Wednesday, October 13, 2010

Yes indeed, it now returns the correct response, but it doenst alter my UI, it must be something related to my other post



Copyright (c) Marimer LLC