WindowsIdentity role caching in ASP.NET
I have verified that it is not the WindowsPrincipal, however it is certainly
not the case that every new request is getting a new token. Nor every new
session. These are the steps to reproduce:
1. Make a request that authenticates as a user who is NOT a member of the
role. IsInRole returns false and an appropriate error is thrown.
2. On the server, add that user to the role in the group editor.
3. Refresh the browser. IsInRole still returns false.
4. Close the browser and open a new browser instance, authenticating again.
IsInRole continues to return false.
5. Stop and start W3SVC, IsInRole now correctly returns true.
I have noticed that allowing enough time to pass (maybe 30 minutes) also
seems to correct the situation, I think this may be because the ASP.NET app
is being recycled, but I'm not sure about this. At any rate, I have done
some tests and determined that the token is cached for the lifetime of a
Logon session, and that Logon sessions for a particular user seem to persist
between requests and sessions.
|