Authorization Rules Noob question

Authorization Rules Noob question

Old forum URL: forums.lhotka.net/forums/t/2455.aspx


Savij posted on Thursday, March 01, 2007

Hello,

I have been using Rockys framework for a long time, but never needed the auth rules till now. I have a BusinessBase class that has the following code in it:

public string EnvironmentName

{

get
{
CanReadProperty(
true
);
return
_environmentName;
}

set
{
CanWriteProperty(
true
);

if (_environmentName != value)
{
_environmentName =
value
;
PropertyHasChanged();
}

}

}

...

protected override void AddAuthorizationRules()

{
AuthorizationRules.AllowRead(
"EnvironmentName", "TestReader");
AuthorizationRules.DenyWrite(
"EnvironmentName", "TestReader"
);
}

I have an ReadWriteAuthorization control on the form that consumes this BO.

Ok, finally for the questions:

  1. When I change the textbox that is bound to the property, it allows the change in the textbox. Even though it throws an exception, nothing happens. I also am unable to end the application as long as there is a change to the textbox. It just keeps firing CanWriteProperty in BusinessBase and throws an exception. I would expect that the control would be readonly = true since I am in the TestReader role. Can anyone explain this?
  2. How can I get the textbox to not allow input since I am specifically Denied or at least have the original value roll back upon the exception that gets thrown??

Maybe I don't understand the AuthRules system as well as I thought I did. Any help is GREATLY apreciated.

 

Thanks,

-Jeff

RockfordLhotka replied on Thursday, March 01, 2007

Look through Chapter 9 to see how the Csla.Windows.ReadWriteAuthorization control is used to automatically enable/disable controls on a form based on the authorization rules in your object.

And, of course, look at the PTWin sample app code that's described in the chapter.

Savij replied on Thursday, March 01, 2007

Rocky,

Tomorrow is another day. Maybe a fresh look at it again will help. I did read and use as reference the book (and PTracker). I may have just missed something. I'll post tomorrow either way.

Thanks for the heads up.

Jeff

Copyright (c) Marimer LLC