views:

451

answers:

1

When I run Roles.GetRolesForUser("username") the roles are returned correctly, however if I add a user into a role in AD, the result does not show up until I log the user out of their system, and have them log back in.

Is there any way to make the system re-check each time?

A: 

If you're using the built-in role provider, there is a setting in the web.config to change this: cacheRolesInCookie. I believe it's true by default.

This will of course require a database lookup every time a role lookup happens (if you're using the db of course), so that may not be a good idea. Otherwise, I think you'll have to write your own provider, which is quite easy. Just create a new class that inherits from RoleProvider, and provide your own implementations. You could handle the caching (or not) in your implementation.

If you want to see the inner workings of the built-in role providers, download Reflector. It's a great tool.

EDIT

Sorry, I re-read and noticed that you're using AD. So, you should be fine with just that change to the provider setup in the web.config.

ScottE