473,666 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

forms authentication question

Everything is working in my authentication process except
for the fact that I can't retrieve the "UserData" property
from the "FormsAuthentic ationTicket".

Write before I do a "RedirectFromLo ginPage", I check
the "UserData" property of
the "FormsAuthentic ationTicket". It's set to the
value "Admin" (a role for the user) which is what I want.

Here is the code:

strUserName = CType(drOLEDBNi cemScheduling.G etValue(1) &
Chr(32) & drOLEDBNicemSch eduling.GetValu e(2), String)
'Set the authentication ticket
Dim arrRoles(0) As String
arrRoles(0) =
drOLEDBNicemSch eduling.GetValu e(3)
Dim ticket As New
FormsAuthentica tionTicket(1, strUserName, Now, DateAdd
(DateInterval.M inute, 60, Now),
ValidateLogin.P ersistantCookie , arrRoles(0))
Dim cookie = New HttpCookie
(FormsAuthentic ation.FormsCook ieName,
FormsAuthentica tion.Encrypt(ti cket))
If ValidateLogin.P ersistantCookie Then
Response.Cookie s.Add(cookie)
End If
'Create Identity
Dim objIdentity As New
Security.Princi pal.GenericIden tity(strUserNam e)
Dim objPrincipal As New
Security.Princi pal.GenericPrin cipal(objIdenti ty, arrRoles)

FormsAuthentica tion.RedirectFr omLoginPage(str UserName,
ValidateLogin.P ersistantCookie )

However, once I get in the Global.asax file in
the "Application_Au thenticateReque st" event (fired by the
FormsAuthentica tion.RedirectFr omLoginPage method), I check
the "UserData" property of the ticket and it's an empty
string! All the other properties pertaining to the ticket
are there. I'm setting up the cookie, so the "Userdata"
property should be populated.

Here is the code in the global.asax file:

Sub Application_Aut henticateReques t(ByVal sender As
Object, ByVal e As EventArgs)

If (Not (HttpContext.Cu rrent.User Is Nothing)) Then
If
HttpContext.Cur rent.User.Ident ity.Authenticat ionType
= "Forms" Then
If
HttpContext.Cur rent.User.Ident ity.IsAuthentic ated Then
Dim id As FormsIdentity =
HttpContext.Cur rent.User.Ident ity
Dim ticket As
FormsAuthentica tionTicket = id.Ticket
Dim roles(0) As String
roles(0) = ticket.UserData
HttpContext.Cur rent.User = New
System.Security .Principal.Gene ricPrincipal(id , roles)
End If
End If
End If

End Sub

What am I doing wrong??? I need to be able to identify the
role of the user (they will only have 1 role).

Thanks,

Bill........
Nov 17 '05 #1
0 2258

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

Similar topics

6
4819
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and the other named Public. I placed my web.config file in my
3
2710
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent, however we will have brokers and customers that also need to connect and will require a username and password. In this case we were going to store their credentials in a SQL database. Internal users will have the ability to access the same resources...
11
3567
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get any requested page to automatically go to the Login.aspx page, AND, the ReturnURL querystring is correct in the address bar, but no matter what, I can't get it, once the user is authenticated, to redirect to the new page. It ALWAYS refreshes the...
1
3493
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The web.config file is configured as such: <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" name="myApplication"/> </authentication>
2
2496
by: Eric | last post by:
I am trying to build an app where the stuff in the root directory is open to all, but anything under the Restricted directory requires you to login and I want to use Forms to do it. I'm having trouble getting the web.config to work properly. First I tried to have a second web.config in the sub directory with authentication and authorization set to forms, but it blew up. Next, I tried to modify the root web.config in the following manner...
7
2034
by: Justin | last post by:
I am trying to password protect a subdirectory using forms authentication. I am using the "Location" tag to specify the directory to be protected. The login.aspx page is in the root directory of the app. Here is the web.config: <location path="Admin"> <system.web> <authentication mode="Forms"> <forms name="authAdmin" loginUrl="Login.aspx" protection="All" timeout="30"> <credentials passwordFormat="Clear"> <user name="Admin"...
5
1660
by: V. Jenks | last post by:
Using forms authentication, can I control which pages and/or directories a user would have access to or is that only available with Windows authentication? Thanks!
18
6869
by: Rippo | last post by:
Hi I am using role base forms authentication in asp.net and have come across a problem that I would like advice on. On a successful login a session variable is set to identify a user. This is all good as this session variable is used to retrieve data for that user etc. However if I restart the webserver then the users session is lost but the ticket is still active. Therefore the user is not redirected back to the login page.
4
5322
by: Bjorn Sagbakken | last post by:
In a web-application with login creds (user, pwd), these are checked against a user table on a SQL server. On a positive validation I have saved the userID, name, custno and role-settings in a userobject (custom build class) and added this to the session using as session variable like session For all other pages I have added a small test in the page_load event, basically testing if the session != null, but also checking if the...
5
3546
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the creation of content which adjusts based on the user. I have several pages which require a user to be logged on and several which do not. Prior to this point in time I have used 2 different master pages. one with a control which checks a session...
0
8443
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
8356
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
8781
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
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.