So far I’ve seen several custom implementations of ASP.NET Role Providers, and all of them comply to a base class requirenment that the Role-checking is done based on string username. (For example IsUserInRole(string username)). Is this requirenment for Role Provider based on the fact that this string username will be a uniqe key for user entity?
My user class uses GUID Id as a uniqe identifier of the user instance.
P.S. I do understand that I need to use thie GUID Id when setting authentication cookies. Just want to make sure that I understand the motivation behind user name role associations.
Most likely because it’s very easy to get the username from the IPrincipal. So you can easily do
IsUserInRole(User.Identity.Name)More importantly, the FormsAuthentication system has to be able to rely on the IPrincipal to do validation at the Authorization level, and the only information that available is the username.