Using netsqlazman as roleprovider and caching

Topics: NetSqlAzMan Core
May 17, 2011 at 5:46 PM
Edited May 17, 2011 at 5:49 PM

I plan to use netsqlazman as a RoleProvider in a .net web app.

Is there a interval of time after which the role <-> users/groups mappings expire?

Let's say we have the following scenario: User UA has role RA, UA logs in, then using the netsqlazman console I (as administrator) assign UA role RB, when does this role assignment become effective within the application? Does the user have to log off and then log back in? It doesn't seem to work.

As a side note, in the final version will assign NT groups to roles and the mappings will be pretty static.  I am also interested to find out, if, in such scenarios, removing a user from a group will reflect immediately in the roles mapping that will be assigned to that user.

 

Thanks

May 17, 2011 at 8:06 PM

This seems to do the trick:

NetSqlAzMan.Providers.NetSqlAzManRoleProvider provider = ((NetSqlAzMan.Providers.NetSqlAzManRoleProvider)Roles.Provider);
provider.InvalidateCache(true);

Coordinator
May 18, 2011 at 6:32 PM

Yes.

Exactly.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com

Oct 29, 2013 at 4:14 PM
Hi Andrea,

I tried to implement the cacheRefreshInterval inside of the providers section but It looks that this is not implemented in the NetSqlAzMan.

take a look of this:

http://msdn.microsoft.com/en-us/library/vstudio/ms164662(v=vs.100).aspx

It will be nice if we can use the cacheRefreshInterval="number" in the role provider instance.

Thanks in Advance.
Coordinator
Oct 30, 2013 at 9:07 AM
Edited Oct 30, 2013 at 9:07 AM
Hi,
the cacheRefreshInterval is an "AuthorizationStoreRoleProvider" property exclusive.
It cannot be implemented in any custom provider.

Look at the cacheRefreshInterval Property description in your URL:

"Specifies the number of minutes between forced updates of the cached policy store data and Applies to the AuthorizationStoreRoleProvider only."

Regards,
Andrea.
Oct 30, 2013 at 2:27 PM
Hi Andrea,
Thanks a lot for your prompt response and for this wonderful NetSQLAzMan product.

I was looking that the NetSqlAzManRoleProvider class inherit from the System.Web.Security.RoleProvider in the same way that the AuthorizationStoreRoleProvider class inherit also from the System.Web.Security.RoleProvider but this class implement the property CacheRefreshInterval.

I’m not sure but maybe it is a good Idea to implement this property and have a Timer that uses this property, something like this:
// Validate the property CacheRefreshInterval on the Initialize method.
   if (!string.IsNullOrEmpty(config["CacheRefreshInterval"]))
            {
                int i = 0;
                bool failure = int.TryParse(config["CacheRefreshInterval"], out i);
 
                this.CacheRefreshInterval = i;
            }
            config.Remove("CacheRefreshInterval");

if (this.CacheRefreshInterval > 0)
{
// Create a timer.
        aTimer = new System.Timers.Timer();

// Hook up the Elapsed event for the timer.
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

// Set the Interval.
        aTimer.Interval = (this.CacheRefreshInterval * 1000);
        aTimer.Enabled = true;

// Specify what you want to happen when the Elapsed event is raised. 
    private void OnTimedEvent(object source, ElapsedEventArgs e)
    {
        This.InvalidateCache(true);
    }
}
Thank You.

Best Regards.