473,666 Members | 2,114 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 3922


"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
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>
3
4738
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
4221
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
1638
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
4685
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
7510
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
2140
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
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...
0
1559
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
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...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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
7386
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
5664
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
1776
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.