Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: page_load & response.redirect???


Message #1 by "Yu, Kevin" <kyu@N...> on Tue, 13 Nov 2001 13:44:15 -0500

I use windows authentication mode, in my login page, the page_load sub will

determine

weather the user is admin or regular user and then redirect them to an

appropriate page,

but it seems the the response.redirect("whatever.aspx") doesn't work? how

come?



my code:



Sub Page_Load()



  'see if the user has been authenticated

  If User.Identity.IsAuthenticated Then



    'create a reference to a WIndowsIdentity object that

    'represents this users Indentity object

    Dim objIdentity = CType(User.Identity, WindowsIdentity)



    'get the current WindowsIdentity object for this user

    'this contains more specific information

    Dim objWinIdentity = objIdentity.GetCurrent()



    'display the properties

    'NOTE: change the group names and the machine name to suit your setup

    msgHello.InnerHtml = "Hello <b>" & objWinIdentity.Name & "</b><br />" _

                       & "The authentication method used was <b>" _

                       & objWinIdentity.AuthenticationType & "</b><br />" _

                       & "Is this a System account: <b>" _

                       & objWinIdentity.IsSystem & "</b><br />" _

                       & "Is this an Anonymous account: <b>" _

                       & objWinIdentity.IsAnonymous & "</b><br />" _

                       & "Is this a Guest account: <b>" _

                       & objWinIdentity.IsGuest & "</b><br />" _

                       & "Is this account a member of the 'Administrators'

group: <b>" _

                       & User.IsInRole("BUILTIN\Administrators") & "</b><br

/>" _

                       & "Is this account a member of the 'Users' group:

<b>" _

                       & User.IsInRole("BUILTIN\Users") & "</b><br />" _

                       & "Is this account a member of the

'DANDARE\TestGroup' group: <b>" _

                       & User.IsInRole("DANDARE\TestGroup") & "</b><br />" _

                       & "Is this account a member of the

'DANDARE\NoMembers' group: <b>" _

                       & User.IsInRole("DANDARE\NoMembers") & "</b>"



' note the messgae above display properly without the following added,

otherwise the page is blank. 



  if User.IsInRole("BUILTIN\Administrators") 

 	response.redirect("login_admin.aspx")

 else 

	response.redirect("login_user.aspx")

 end if







  Else



    msgHello.InnerHtml = "Hello, you were not authenticated"



  End If



End Sub



Kevin Yu

system.data.oledb

coop student

Western Research Center - Natural Resource Canada

email: kyu@n...

phone:(780) 987-8611




  Return to Index