Authorization rule with an additional boolean parameter

Authorization rule with an additional boolean parameter

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


lazaroms posted on Thursday, January 17, 2013

Is it possible to create an authorization rule having an additional boolean parameter and the rule result will also depend on the boolean parameter?

The value of the boolean parameter could change during the life cycle of the instance.

My question is because when the AddObjectAuthorizationRules() loads the authorization rules the boolean parameter will have a value and that value could change during the life cycle of the instance.

 

Thanks for your help.

 

JonnyBee replied on Thursday, January 17, 2013

The only way would be to create an AuthorizationRule that accepts a lambda expression with statements that use the bool parameter. 

You can also read a value from the actual object (when provided) or read values from f.ex ApplicationContext or your own context within the rules Execute method. 

lazaroms replied on Thursday, January 17, 2013

Hi JonnyBee:

I was thinking in using the AuthorizationContext to access the property Target and then get the value from the property.

Like in the sample in the book:

protected override void Execute(Csla.Rules.AuthorizationContext context)

{

var target = context.Target as ProductEdit;

.....

Can I do that with an interface too?

JonnyBee replied on Thursday, January 17, 2013

Yes

lazaroms replied on Thursday, January 17, 2013

Thanks JonyBee.

Copyright (c) Marimer LLC