There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Make storage cache thread safe, make role provider use storage cache.
Attached are my changes to make the above happen.
Also included in the role provider is my previously published cached dbuser support.
Sorry it took so long to get this update to you, I had been procrastinating because I would have to separate out my other 'db attributes' feature from this change. Was actually pretty easy though. :-)
Using storagecache is now threadsafe, just use it like you did before.
Using the new attached roleprovider - it uses a storagecache now. Internally, it also caches the dbUser. This makes websites so much faster. Final result is zero database calls around security when browsing your website. Use it just as you did before, but there
are a couple of extra methods I exposed. You can access these methods via something like this;
NetSqlAzManRoleProvider myNetRoleProvider = (NetSqlAzManRoleProvider)System.Web.Security.Roles.Provider; //this just gets the default provider. If you have multiple you can use Roles.Provider["ProviderName"].
Once you have the provider and have cast it, you can call the new methods on it.
myNetRoleProvider.InvalidateCache() -- This causes the cache in the provider to be rebuilt. While it is being rebuilt, it continues to use the one it already has. When the rebuilding is done, it switches to the new one. Since all the roles are cached now, this
is necessary to 'refresh' permissions.
myNetRoleProvider.CheckAccess(operation, [dbUserNameWindowsIdentity], [operationsonly]) -- This function is overloaded with the bracketed parameters shown. In your application, if you need to check a particular access (operation/task/role), you can use this
Finally, there is a region called 'SpecificToMyProject' - please remove this from what you commit to the repository. This is just where I use attributes to determine additional security features and would not apply to most people.
I have attached a patch to apply against the source. It only changes the NetSqlAzManRoleProvider.cs and StorageCache.cs