NetSqlAzMan Role Provider and Cache

Jul 14, 2010 at 3:51 PM

Hi Andrea, do you know how long the roles are cached in the role provider? I have tried different ways to invalidate the cache but it only seems to work by changing the webconfig. Any direction on this would be greatly appreciated.

Issue: When making a change to the NetSQLAzMan store via the MMC Snap-In. The change is not reflected on the web site until the worker process is restarted.

Thanks.

 

 

Coordinator
Jul 14, 2010 at 5:51 PM

Hi,

NetSqlAzMan role provider is based on StorageCache class. So cache must be manually invalidated using:

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

provider.InvalidateCache(bool waitForCacheBuiltCompletition);

This is the reason because all changes made via MMC Snap-In are not reflected from the role provider.

Regards,

Andrea.

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

Jul 19, 2010 at 8:58 PM
Hi, thanks for the explanation it really did help! Now I have run across a different problem when I go to deploy the application I get the following error:
Line 72: <roleManager enabled="true" defaultProvider="NetSqlAzManRoleProvider">
Line 73: <providers>
Line 74: <add name="NetSqlAzManRoleProvider" type="NetSqlAzMan.Providers.NetSqlAzManRoleProvider" connectionStringName="AzManCon"
Line 75: storeName="Auditornet" applicationName="Total Comp" userLookupType="DB" defaultDomain="" />
Line 76: </providers>
Any help would be appreciated.
Thanks.


>>> "aferende" <notifications@codeplex.com> 7/14/2010 10:51 AM >>>

From: aferende

Hi,

NetSqlAzMan role provider is based on StorageCache class. So cache must be manually invalidated using:

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

provider.InvalidateCache(bool waitForCacheBuiltCompletition);

This is the reason because all changes made via MMC Snap-In are not reflected from the role provider.

Regards,

Andrea.

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

Coordinator
Jul 19, 2010 at 10:26 PM

Have you an “AzMan” connection string into the <ConnectionString>…</ConnectionString> settings !?

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

Aug 3, 2010 at 3:39 PM
Hi Andrea, I am using the Role Provider to manage all my roles in our applications. We have one store/application with the roles for multiple web sites. One web site controls granting access and we use the Roles.AddUsersToRoles(string[], string[]) method which should be calling InvalidateCache. However, after we add a user to a role it seems like the storage is not being invalidated. Am I missing something?
Thanks.

>>> "aferende" <notifications@codeplex.com> 7/14/2010 10:51 AM >>>

From: aferende

Hi,

NetSqlAzMan role provider is based on StorageCache class. So cache must be manually invalidated using:

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

provider.InvalidateCache(bool waitForCacheBuiltCompletition);

This is the reason because all changes made via MMC Snap-In are not reflected from the role provider.

Regards,

Andrea.

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

Coordinator
Aug 3, 2010 at 3:52 PM

Hi,

you must manually invalidate the cache:

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

provider.InvalidateCache(true);

this because you can invoke several times provider.AddUsersToRole … before invalidating the cache.

For more info see the “How Do I ?” Video Tutorial, Lesson 6 (NetSqlAzManRoleProvider). (available at NetSqlAzMan web site - download section)

Regards,

Andrea.

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

Aug 3, 2010 at 3:58 PM
If I manually call invalidate cache from Application A it does nothing for Application B which uses the same store and application in netsqlazman correct? So, I need to call invalidate cache from Application A and then B?

>>> "aferende" <notifications@codeplex.com> 8/3/2010 8:52 AM >>>

From: aferende

Hi,

you must manually invalidate the cache:

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

provider.InvalidateCache(true);

this because you can invoke several times provider.AddUsersToRole … before invalidating the cache.

For more info see the “How Do I ?” Video Tutorial, Lesson 6 (NetSqlAzManRoleProvider). (available at NetSqlAzMan web site - download section)

Regards,

Andrea.

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

Coordinator
Aug 3, 2010 at 4:14 PM

Yes.

Aug 4, 2010 at 2:59 PM
OK thanks.
This is what I did and it worked. In each web application I created a web service with a method called invalidatecache. When access is granted the user is added via Roles.AddUsersToRoles and a call to corresponding applications web method is executed to invalidate the cache.
[WebMethod]
public void InvalidateCache
{

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

provider.InvalidateCache(true);

}



>>> "aferende" <notifications@codeplex.com> 8/3/2010 9:14 AM >>>

From: aferende

Yes.

Coordinator
Aug 5, 2010 at 11:20 AM

Nice job.