CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Authorization rules not running for new object

    rated by 0 users
    Answered (Not Verified) This post has 0 verified answers | 6 Replies | 1 Follower

    Not Ranked
    4 Posts
    jmuller posted on Thu, Feb 14 2013 2:34 PM

    When I create a new instance of a business object, the authorization rules do not run.  I have a custom authorization rule that changes access to a property based on the state of another property.  This rule runs as expected when fetching an existing object and editing it, but it seems like the authorization rules are ignored when checking business rules for new objects.  Is there a way to get the authorization rules to run for new objects?

    All Replies

    Top 10 Contributor
    2,279 Posts
    Answered (Not Verified) JonnyBee replied on Fri, Feb 15 2013 12:56 AM
    Suggested by JonnyBee

    Property level authorization rules is cached by default.

    Depending on which version of CSLA you are using you must either

    • overload the CacheResult method to return false or
    • set CacheResult property to false

    to tell the BO to NOT cache the result of the AuthorizationRule. .

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    4 Posts

    Thanks for the response.  I actually ran into that same issue when I initially wrote the custom authorization rules.  I made sure that CacheResult returns false.  This works as expected for editing existing objects.  Unfortunately, the custom authorization rules do not run at all for new objects.

    Top 10 Contributor
    2,279 Posts

    Hi,

    Authorization rules do not run similar to business rules. Instance level AuthorizationRules is checked within the CanReadProperty/CanWriteProperty/CanExecuteMethod methods of the business object to determine if user is allowed to do the AuthorizationAction.

    AuthorizationRules do not run as such when you call BusinessRules.CheckRules.

    Can you show some sample code from your rules/business object?  

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    4 Posts

    Thanks for your quick response.  I created a code sample that has only the relevant properties and authorization rules, but I don't feel comfortable posting it in a public forum (because of the type of project).  Is there a way to send you a private message with the code?

    Top 10 Contributor
    2,279 Posts

    Send private mail to jonny.bekkum(a)gmail.com 

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    4 Posts

    Thanks, will do.

    Page 1 of 1 (7 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems