By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

WindowsAuthentication_Authenticate Customer Roles and Impersonation

P: n/a
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

Jan 2 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Deville" wrote:
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

Jan 2 '06 #2

P: n/a
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.

Peter Bromberg [C# MVP] wrote:
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Deville" wrote:
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


Jan 2 '06 #3

P: n/a
Thoughts anyone?

Jan 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.