WindowsAuthentication_Authenticate Customer Roles and Impersonation

J

Jeff Deville

I'd like to create customer roles for my ASP.Net application, but I am
also using impersonation. For the purposes of this issue, say I have
the simple code below for my custom roles.:

Overrides Sub Init()
_ht = New Hashtable
_ht.Add("mycomputer/me", New String() {"ViewAll",
"ViewPublished"})
End Sub


Sub WindowsAuthentication_Authenticate(ByVal s As Object, ByVal e As
WindowsAuthenticationEventArgs)
e.User = New GenericPrincipal(e.Identity, _ht("mycomputer/me"))
End Sub

The problem is that I don't have access to the custom roles in my page
code. I've read that this has something to do w/ impersonation
happening after the WindowsAuthentication_Authenticate method is
called. The problem is that the User object seems to be read only
after this, so in what method can I assign these custom roles?

Thanks
-j
 
G

Guest

Jeff,
At first blush it appears you are attempting to have your cake and eat it
too. The whole concept of authentication is to create a custom Identity based
on the user's credentials, no? In this case you are forcing it to be
"mycomputer/me"... no matter who it is.

Peter
 
J

jd1978

Hi Peter, Thank you for the reply. You're quite right of course, I
created this code in a overly-simplistic manner to try to isolate the
source of error to the custom role assignment. While it appears that
the roles are assigned successfully in the
WindowsAuthentication_Authenticate method, these roles are not
available from the page. (Once this problem is complete, I'll be
supplying the roles from a database, and using the user's identity as
the index into the data)

Thanks Peter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top