473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WindowsAuthentication_Authenticate Customer Roles and Impersonation

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
3 1557
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
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
Thoughts anyone?

Jan 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2541
by: Anil Krishnamurthy | last post by:
We have an ASP.NET application that uses COM objects through Interop. The web application requires access to network and database resources and hence, needs to impersonate a domain account. The...
4
2178
by: Chris Gatto | last post by:
Hi, I'm having what should be a minor problem but has turned into a 2 day slug fest with ASP.Net. I am simply attempting to authenticate my asp.net application users against users in an AD...
3
1910
by: Sharat Koya | last post by:
Please can you help with a problem I am having. My web config is set to... <authorization><deny users="?"/> <authentication mode="Forms"> <forms name=".COOKIE" loginUrl="login.aspx"...
5
2126
by: hansiman | last post by:
Following http://aspnet.4guysfromrolla.com/articles/082703-1.aspx I've set up roles authentication for my web application. User's roles are registered by: HttpContext.Current.User = _ New...
0
1025
by: Erland Sommarskog | last post by:
My article on dynamic SQL, "The Curse and Blessings of Dynamic SQL" is frequently referred to in these newsgroups. I like to announce that I have rewritten this article thoroughly. I started off...
9
4264
by: Mike Hofer | last post by:
BACKGROUND: We've designed a Website for a client that will be deployed across multiple physical locations. The site will be hosted from a corporate NOC, and administered by the IT group there. ...
0
1135
by: Nick | last post by:
I am working on a web based application in which all "roles" are stored in the database. When a user logs in their roles are then transferred to a comma delemited string, saved to a cookie, etc......
3
1270
by: John Chapman | last post by:
Hello, I am trying to use an Access database as the provider for the ASP.NET Membership for the users, roles, and profiles. I have looked at many tutorials available online, and I could not...
0
2675
by: sidhuasp | last post by:
Hi everyone I am using a mainmenu witeh sitemap provider with folowing sitemap <siteMapNode> <siteMapNode url="" title="Master Data" description="Enter Master data" roles ="Admin,PM"> ...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.