473,401 Members | 2,146 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,401 software developers and data experts.

FormsAuthentication.RedirectFromLoginPage question

Hi. I have two questions, please:

a) If I go DIRECTLY to Login, there's no Request.Params("ReturnURL"), and
therefore RedirectFromLogin won't work, because it will try to go to a page
named "Default", which in my case does not exist. Short of creating a
"mandatory" Default page, what can I do ? RedirectFromLogin not only
redirects me to whereever I came from, but it also creates a ticket - so how
can I still use it if the redirection part is not convenient in my case
(there's no Default.aspx page) ?
Should I check whether Request.Params("ReturnURL") is null, and in this case
set it somehow to the page I want the user to go after login ?
Request.Params("ReturnURL") is read-only !

b) If a user has several roles, how can I list them all ? Now I have some
ugly code like:

If User.IsInRole("Admin") Then
strRole &= "<li>Administrator"
End If
If User.IsInRole("Sales") Then
strRole &= "<li>Sales"
End If
If User.IsInRole("Support") Then
strRole &= "<li>Support"
End If
If User.IsInRole("Guest") Then
strRole &= "<li>Guest"
End If
lblRole.Text = User.Identity.Name & ", your application role is: <h2>" &
strRole & "</h2> !"

I'm asking this because of course there are ways to go around this, but I
wanted to encapsulate this "role" thing in global.asax in
Application_AuthenticateRequest. I could read again somewhere in my
application my "roles" XMLFile (or dbTable) and list all the roles for user
X, maybe even without checking for "IsInRole", but I'm looking for an
elegant, OO solution to this problem. Should I write a function which reads
all the roles for user X in an array and put this function in a module and
call it as well from Application_AuthenticateRequest as from wherever else I
need to list the roles for a specific user ?

Thank you for bearing with me.
Alex.
Nov 19 '05 #1
1 1533
Hi Alex:

For question 'a' - I'm not aware of a way to override the default.aspx
URL of RedirectFromLogin. Someone else might have an idea.

For question 'b' there is no quick and easy method to call,
unforunately, but you can use the DirectorySearcher class from
System.DirectoryServices to look up the user groups. For a sample, see
the code in the following article:
http://msdn.microsoft.com/library/de...m_asp__net.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 12 Feb 2005 02:13:43 -0500, "Alex Nitulescu"
<RE***********************@yahoo.com> wrote:
Hi. I have two questions, please:

a) If I go DIRECTLY to Login, there's no Request.Params("ReturnURL"), and
therefore RedirectFromLogin won't work, because it will try to go to a page
named "Default", which in my case does not exist. Short of creating a
"mandatory" Default page, what can I do ? RedirectFromLogin not only
redirects me to whereever I came from, but it also creates a ticket - so how
can I still use it if the redirection part is not convenient in my case
(there's no Default.aspx page) ?
Should I check whether Request.Params("ReturnURL") is null, and in this case
set it somehow to the page I want the user to go after login ?
Request.Params("ReturnURL") is read-only !

b) If a user has several roles, how can I list them all ? Now I have some
ugly code like:

If User.IsInRole("Admin") Then
strRole &= "<li>Administrator"
End If
If User.IsInRole("Sales") Then
strRole &= "<li>Sales"
End If
If User.IsInRole("Support") Then
strRole &= "<li>Support"
End If
If User.IsInRole("Guest") Then
strRole &= "<li>Guest"
End If
lblRole.Text = User.Identity.Name & ", your application role is: <h2>" &
strRole & "</h2> !"

I'm asking this because of course there are ways to go around this, but I
wanted to encapsulate this "role" thing in global.asax in
Application_AuthenticateRequest. I could read again somewhere in my
application my "roles" XMLFile (or dbTable) and list all the roles for user
X, maybe even without checking for "IsInRole", but I'm looking for an
elegant, OO solution to this problem. Should I write a function which reads
all the roles for user X in an array and put this function in a module and
call it as well from Application_AuthenticateRequest as from wherever else I
need to list the roles for a specific user ?

Thank you for bearing with me.
Alex.


Nov 19 '05 #2

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

Similar topics

2
by: Ben Fidge | last post by:
Is FormsAuthentication.RedirectFromLoginPage the only way to populate the HttpContext.Current.User.Identity.Name property? A base class for each page contains the follwoing property: public...
2
by: tshad | last post by:
I have a logon page that is may be called by the Forms Authentication setup. This would put a ReturnURL as part of the URL. I would normally then just issue a: ...
2
by: Grant Merwitz | last post by:
Hi, i am using forms authentication in an ASP.NET project I am setting the Forms authentication cookie by using: FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); Now when i...
1
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on...
2
by: rn5a | last post by:
A web.config file has the following code: <configuration> <system.web> <authentication mode="Forms"> <forms name="NETConnectCookie" loginUrl="Login.aspx"> <credentials passwordFormat="SHA1"/>...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.