473,943 Members | 29,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RoleProvider Capturing Authentication Events


I have a Role Provider with a subdirectory protected via the web.config.
Forms authentication is used.
If a person who is not in the role tries to access a page in the directory,
the browser is redirected to the forms authentication logon page.

Is there a way to prevent this behavior?
I would prefer to just show the user an access denied page and maybe some
help text.

Maybe some events fire in the provider model or the global.asax?

Mar 1 '07 #1
6 1377
Hello Chuck,

From your description, in your ASP.NET forms authentication secured web
application, you want to make those users (that will be redirected to the
login page) see different pages depend on whether they're unauthenticated
or doesn't have sufficient permission(role ), correct?

If this is the case, I think the simplest and most convenient means is to
customize your login page and check the HttpContext.Cur rent.User.Ident ity
to see whether it is authenticated. Because if a user is redirect to login
page due to unauthenticated , the Identity should be unauthenticated too,
while if the user is redirected due to unsufficient permission, it should
already has an authenticated identtiy. e.g.

=====in login page code=========== ===
protected void Page_Load(objec t sender, EventArgs e)
{

if (Context.User.I dentity.IsAuthe nticated == true)
{
Server.Transfer ("~/AccessDeniedPag e.aspx");
//or use response.redire ct(....)
}
}

==============

Also, you need to make sure you add authorization setting to allow all
authenticated users to access the "AccessDeniedPa ge" in web.conifg
====in web.config===== =
.............
<location path="AccessDen iedPage.aspx">
<system.web>
<authorizatio n>
<deny users="?"/>
</authorization>
</system.web>
</location>
............... ....
=============== =============

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 1 '07 #2
Hi Chuck,

Have you got the issue resolved or does the suggestion in my last reply
helps some? If there is any further question, please feel free to let me
know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 5 '07 #3
I'll try that.
I guess the only time I would get sent to the page
while I was authenticated is for a 401.
Mar 5 '07 #4
Thanks for your reply Chuck,

For ASP.NET Forms Authentication, it will send redirect response to client
whenever the user fail to pass auhorization and need to be redirected to
login page. This differs from windows authentication which will result to
401 error. Therefore, the login page is the place you can get the
unauthorized or unauthenticated requests. Anyway, if you have any further
questions, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 6 '07 #5
Hi Chuck,

Have you got any progress or does the suggestion help you some? If there is
anything else we can help, plese feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 8 '07 #6
thanks,
I coded the auth page to check for already authenticated as you suggested.
If authenticated, I assume they are not authorized.


Mar 8 '07 #7

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

Similar topics

4
12034
by: Jay Xx | last post by:
I have an IFrame in design mode. I've tried a bunch of things to capture key presses in that IFrame, but I can't seem to get it. I can capture key presses outside the IFrame fine. I have this problem in Firefox, not IE. I do know it's possible because Blogger.com's rich text editor does it, but their code is cryptic and separated into like 20 files, so I'm going through hell trying to decipher it. (I need to capture the keypress in order...
7
20390
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common browsers? The script bellow is IE only. It fails FF 1.0 and NN 7. Also, if I can trap the keypress I would like to use it to tab to the next tabindex.
1
2029
by: Rick | last post by:
Assuming proper authentication, does the framework offer a way to capture Windows Server 2003 system security events, as found in the event viewer log files? I'd like to be able to write some code to trap certain events and react to them. Thanks, Rick
14
2562
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the internet, they have to login. I want to be able to capture that login versus their Windows login because I need to know who they are from any computer rather than only their computer. Any ideas? Thanks
5
4754
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event gets triggered and the double click is not identified at all. Is there any way I can invoke the double click when the mouse move also exists?
1
2346
by: Mark Olbert | last post by:
I've written a custom MembershipProvider and a custom RoleProvider, and am trying to get them to work with the ASP.NET Configuration tool. Which is a royal pain in the butt, because there doesn't appear to be any way to debug the Configuration tool. In any event, when I create a new user I get the following error message: An error was encountered. Please return to the previous page and try again. The following message may help in...
8
5299
by: Tomasz | last post by:
Hello Developers! I have an interesting problem using my custom MembershipProvider, RoleProvider and Forms Authentication. Both MembershipProvider and RoleProvider require session state, where some very important context data are stored during the Session_Start event. My MembershipProvider and RoleProvider depend on this information. It seems that authentication process works with no problems.
1
1728
by: Arthur Dent | last post by:
Please help... i am stumped... I have an app, written in VB.NET fwiw. I have a custom RoleProvider class, cuz i finally got tired enough of hacking with application variables, to learn the "correct" way to do roles. ;) .... Now, the problem, is that my RoleProvider, and my FormsAuthentication Session do not stay together. That is to say, i frequently see cases where the session will expire, but the RoleProvider does not. Now, they...
2
2331
by: =?Utf-8?B?d2lsbGlhbQ==?= | last post by:
Hi, Could anyone tell me how to change the default roleprovider at runtime? Basically I have a few sets of roleprovider and membership provider, I want to switch among them at runtime based on some sort of identifier. Thanks. William
0
10142
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9970
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11133
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10666
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8228
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6311
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4913
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 we have to send another system
2
4515
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.