473,847 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forms Authentication how to get UserID

I am using Forms Authentication but I want to keep more info on user than
forms authentication keeps.
I thought of 2 ways of doing this
1. To have a linked table holding other data, but for this I need to be able
to get the userID of the logged on user. how do I do this.
2. the other Idea I had was to add more fields to the forms authentication
user table. but I would still need the userID and I'm not sure what
implications this would have.

Any one know how to get the userID of the logged on user or a better way.

thanks

Jun 27 '08 #1
2 3929


"ThatsIT.net.au " <me@workwrote in message
news:92******** *************** ***********@mic rosoft.com...
I am using Forms Authentication but I want to keep more info on user than
forms authentication keeps.
I thought of 2 ways of doing this
1. To have a linked table holding other data, but for this I need to be
able to get the userID of the logged on user. how do I do this.
2. the other Idea I had was to add more fields to the forms authentication
user table. but I would still need the userID and I'm not sure what
implications this would have.

Any one know how to get the userID of the logged on user or a better way.

thanks
The standard way would be to create your own Membership Provider and/or User
classes, then you can access any information via the User object.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

Jun 27 '08 #2
On 17 May, 05:28, "ThatsIT.net.au " <me@workwrote :
I am using Forms Authentication but I want to keep more info on user than
forms authentication keeps.
I thought of 2 ways of doing this
1. To have a linked table holding other data, but for this I need to be able
to get the userID of the logged on user. how do I do this.
2. the other Idea I had was to add more fields to the forms authentication
user table. but I would still need the userID and I'm not sure what
implications this would have.

Any one know how to get the userID of the logged on user or a better way.

thanks
When the user logs in and is authenticated successfully store the
userID in a Session state variable e.g.

// Suppose you have the credentials stored in web.config
// (otherwise you would use an authentication function of your own
// that verifies against a database).

if(FormsAuthent ication.Authent icate(txtUserna me.text,
txtPassword.tex t))
{
Session["userID"] = txtUsername.Tex t;
FormsAuthentica tion.ReturnFrom LoginUrl(...)
// etc
}

where txtUsername, txtPassword are a TextBoxes for entering the
username and password on the login form.

Then anytime later you can retrieve it thus:

string UserID = (string)Session["UserID"];
If, on the other hand, you are using Membership then the GetUser()
method will retrieve all details of the currently logged in user.
Jun 27 '08 #3

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

Similar topics

1
3521
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>
3
4751
by: Martin | last post by:
Dear fellow ASP.NET programmer, I stared using forms authentication and temporarily used a <credentials> tag in web.config. After I got it working I realized this wasn't really practical. I cannot write to web.config so I cannot dynamically update the credentials while the site is up. Since the FormsAuthentication.Authenticate() method's documentations claims the following: "Attempts to validate the credentials against those contained...
0
4260
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com. --------------------------------------------------------------------------------
1
1646
by: Brian Shannon | last post by:
Using forms authentication I want to add several pieces of data to the UserData property in the Forms Ticket. I want to include roles, email, user ID. From reading it seems like you add all that to a string and add it to the UserData property. If that is the case how do you access each individual piece such as email. I am not completely up to date with using ASP.NET's cookies so bare with me.
1
4692
by: Mark Olbert | last post by:
I'm building an ASPNET2 website which uses forms authentication but does not use the Microsoft-supplied membership providers (mostly because I don't want to create my own provider at this point, and the supplied stuff comes with a lot of baggage I don't want/need). In ASPNET1.1 what I would do was something like the following, after authenticating the user on the login form: FormsAuthentication.SetAuthCookie(userInfo.UserID, false); ...
2
7524
by: Frank Swarbrick | last post by:
I am trying to understand "client authentication" works. My environment is DB2/UDB LUW 8.2 on zSeries SLES9 as the database server and DB2 for VSE 7.4 as the client. We currently have DB2/LUW set up as follows: Client Userid-Password Plugin (CLNT_PW_PLUGIN) = Client Kerberos Plugin (CLNT_KRB_PLUGIN) = Group Plugin (GROUP_PLUGIN) = GSS Plugin for Local Authorization ...
8
2157
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs file using examples on MSDN. I have created a FormsAuthenticationTicket and cookie and added the cookie to the response and then set the SetAuthCookie etc. When I go to the redirected page, I am not sure how to read the cookie value so I know who...
4
5332
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...
0
1567
by: goscottie | last post by:
I have web project that doesn't require strict authentication. So I put a persistent Forms Authentication so that user can come back any time and doesn't have to log in (authentication timeout set to something big, like 300000). So far so good. Problem occurs when user closes the browser, thus killing the session and losing Session which I use extensively throughout the application. Only workaround I see is that to create a custom...
0
9890
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
9733
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
10990
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9489
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...
1
7887
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5914
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4537
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
3
3167
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.