473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1354
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.Current.User.Identity
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(object sender, EventArgs e)
{

if (Context.User.Identity.IsAuthenticated == true)
{
Server.Transfer("~/AccessDeniedPage.aspx");
//or use response.redirect(....)
}
}

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

Also, you need to make sure you add authorization setting to allow all
authenticated users to access the "AccessDeniedPage" in web.conifg
====in web.config======
.............
<location path="AccessDeniedPage.aspx">
<system.web>
<authorization>
<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
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...
7
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...
1
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...
14
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...
5
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...
1
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...
8
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...
1
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.