L
Lyndon Hills
Hi,
I'm hoping that someone might enlighten me as to how the Roles.IsUserInRole
functionality works.
I have my custom role provider set up and working, but realised that the
caching wasn't working. When my c# code hit the line Roles.IsUserInRole I saw
the identity property of my role principal being accessed and then, despite
the roles being cached, the code goes off to establish if the user has the
role from the role store.
If I use Context.User.IsInRole the same thing happens but the role
membership is established in the role principal from the cached roles.
This is a web page where there is no impersonation -
Context.Request.LogonUserIdentity.Name = the machine\IUSR account.
Context.user.Identity.name = the login id supplied (via forms).
Thread.CurrentPrincipal.Identity.Name is also the forms supplied user.
Would I be right in thinking that Roles.IsUserInRole is looking for the
roles of the context.LogonUserIdentity? Is there any way I persuade it to use
Context.user.Identity.Name - without doing impersonation?
Roles.IsUserInRole(Thread.CurrentPrincipal.Identity.Name, "TestRole")
and
Roles.IsUserInRole(Context.User.Identity.Name, "TestRole")
also don't work, in that they don't use my cached roles they go back to the
store, they do provide the correct result once that's done.
This is part of a solution intended to handle windows/domain users, domain
users not using windows/IE (primarily Apple) and non-domain users stored in
ADAM.
While it would be nice to be able to use the built in Roles functionality, I
can live without it by using Context.User.IsInRole. I would like to know
what I'm doing wrong in any case, or to properly understand why it doesn't
work.
Thanks for any assistance or explanation.
Lyndon Hills
I'm hoping that someone might enlighten me as to how the Roles.IsUserInRole
functionality works.
I have my custom role provider set up and working, but realised that the
caching wasn't working. When my c# code hit the line Roles.IsUserInRole I saw
the identity property of my role principal being accessed and then, despite
the roles being cached, the code goes off to establish if the user has the
role from the role store.
If I use Context.User.IsInRole the same thing happens but the role
membership is established in the role principal from the cached roles.
This is a web page where there is no impersonation -
Context.Request.LogonUserIdentity.Name = the machine\IUSR account.
Context.user.Identity.name = the login id supplied (via forms).
Thread.CurrentPrincipal.Identity.Name is also the forms supplied user.
Would I be right in thinking that Roles.IsUserInRole is looking for the
roles of the context.LogonUserIdentity? Is there any way I persuade it to use
Context.user.Identity.Name - without doing impersonation?
Roles.IsUserInRole(Thread.CurrentPrincipal.Identity.Name, "TestRole")
and
Roles.IsUserInRole(Context.User.Identity.Name, "TestRole")
also don't work, in that they don't use my cached roles they go back to the
store, they do provide the correct result once that's done.
This is part of a solution intended to handle windows/domain users, domain
users not using windows/IE (primarily Apple) and non-domain users stored in
ADAM.
While it would be nice to be able to use the built in Roles functionality, I
can live without it by using Context.User.IsInRole. I would like to know
what I'm doing wrong in any case, or to properly understand why it doesn't
work.
Thanks for any assistance or explanation.
Lyndon Hills