Load AuthorizationRules from Database for CSLA 3.8.4

Load AuthorizationRules from Database for CSLA 3.8.4

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


NickyLarson posted on Monday, May 14, 2012

Hello everyone.

 

I would like to ask to someone who knows how to load AddAuthorizationRules from a table of customes roles in a database.

I still use CSLA 3.8.4 i a realy need to load the AuthorizationRules from a database. I a newbie and I don´t know how to do it, i google in the CSLA Forum but no luke.

Can someone give me an example please.

 

Thanks in advance.

NickyLarson

 

 

JonnyBee replied on Tuesday, May 15, 2012

I can think of two alternatives:

1: Get roles from database and add as parameter to Authz rules, using the built-in Csla authz rules:
In your BO AddAuthorizationRules you should use a CommandObject or ReadOnly object to load the rule info from the database and then add Authz rules with roles from database unsing the built-in roles based authz rules.

2. Create a generic Authz rule that uses a cache of roles from database (load on app startup?)

You must avoid frequent data access - so prefer on application startup or when adding type authz rules (executed just once per type).

See also some older posts:

http://forums.lhotka.net/forums/p/3433/17077.aspx#17077
http://forums.lhotka.net/forums/p/1981/10399.aspx#10399

NickyLarson replied on Thursday, May 17, 2012

Dear JonnyBee,

 

Thansk you for yours help.

I´ve done the first solution you have point to me and it´s working well, It was not so dificullt at all.

Thanks you again.

 

Best Regards.

NickyLarson

Copyright (c) Marimer LLC