Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FormsAuthentication.RedirectFromLoginPage question

Reply
Thread Tools

FormsAuthentication.RedirectFromLoginPage question

 
 
Alex Nitulescu
Guest
Posts: n/a
 
      02-12-2005
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.


 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      02-12-2005
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"
<> 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.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57