473,725 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass UserID instead of Username to other pages after logged on, ASP.NET 2.0

Hi,
I have my own user table with definition like

UserID int not null primary key,
Username varchar(50) not null,
Password varchar(50) not null,
Firstname varchar(50) not null,
Lastname varchar(50) not null,
Email varchar(50) not null,
......

I create my own Membership provider to inherit SqlMembershipPr ovider

public class MyMembershipPro vider :
System.Web.Secu rity.SqlMembers hipProvider {
public MyMembershipPro vider() {
}

public override bool ValidateUser(st ring username, string password) {
// query my DB to verify user
MyUser mu = new MyUser();
return mu.VerifyUser(u sername, password);
}
}

In Asp.Net 1.1, we can use
FormsAuthentica tion.RedirectFr omLoginPage(Use rID.ToString(), false); to save
UserID (which is whatever I return from my own function, including UserID
from User table). Later on, we just call User.Identity.N ame to retrieve the
UserID and it could be used as I like.

But in ASP.NET 2.0, I just need to add

<membership defaultProvider ="MyMembershipP rovider">
<providers>
<add name="MyMembers hipProvider"
type="MyMembers hipProvider"/>
</providers>
</membership>

to my web.config file, it will handle authentication autimatically. In this
case how can I pass UserID instead of username to other pages?
Thanks
Hardy
Dec 4 '05 #1
1 2246
Hardy,

Why pass it around? Why not set a session variable with the information
you need?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Hardy Wang" <ha*******@hotm ail.com> wrote in message
news:um******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi,
I have my own user table with definition like

UserID int not null primary key,
Username varchar(50) not null,
Password varchar(50) not null,
Firstname varchar(50) not null,
Lastname varchar(50) not null,
Email varchar(50) not null,
.....

I create my own Membership provider to inherit SqlMembershipPr ovider

public class MyMembershipPro vider :
System.Web.Secu rity.SqlMembers hipProvider {
public MyMembershipPro vider() {
}

public override bool ValidateUser(st ring username, string password) {
// query my DB to verify user
MyUser mu = new MyUser();
return mu.VerifyUser(u sername, password);
}
}

In Asp.Net 1.1, we can use
FormsAuthentica tion.RedirectFr omLoginPage(Use rID.ToString(), false); to
save UserID (which is whatever I return from my own function, including
UserID from User table). Later on, we just call User.Identity.N ame to
retrieve the UserID and it could be used as I like.

But in ASP.NET 2.0, I just need to add

<membership defaultProvider ="MyMembershipP rovider">
<providers>
<add name="MyMembers hipProvider"
type="MyMembers hipProvider"/>
</providers>
</membership>

to my web.config file, it will handle authentication autimatically. In
this case how can I pass UserID instead of username to other pages?
Thanks
Hardy

Dec 5 '05 #2

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

Similar topics

3
1729
by: anon | last post by:
<?php if(! isset($_POST)) { header("Location: login.php"); } mysql_connect(DELETED) mysql_select_db(DELETED) $username = $_POST;
0
1205
by: Ash | last post by:
I want to provide the ability for my users to login from any page that they are on. ie. have a login user control with a username and password box on each page (not a link to a login page). However, as the values of other controls on the page , and whether these controls are displayed, rely on whether the user is logged in, I need to get the UserID before the controls are created. I suppose that I could set these properties in the...
3
5013
by: sileesh | last post by:
Hi I have a weird problem. I am using User.Identity.Name() in my application to get the Logged in person Network ID. In one application it retruns the correct Network userid. But in the other applications it says it cannot get the Network UserId. In both the applications i have set "<authentication mode="Windows" /> <identity impersonate="true"></identity>" in my web.config file.
4
3325
by: James | last post by:
I succesfully pass username , domain and password via this function (taken from MSDN) Private Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal lpszUsername As , _ ByVal lpszDomain As , ByVal lpszPassword As , _ ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
1
1459
by: Hardy Wang | last post by:
Hi, I have my own user table with definition like UserID int not null primary key, Username varchar(50) not null, Password varchar(50) not null, Firstname varchar(50) not null, Lastname varchar(50) not null, Email varchar(50) not null, ......
19
248238
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer. This article is a basic tutorial on how to user HTML Forms, the most common method of data collection. Assumptions - Basic HTML knowledge. - Basic PHP knowledge. HTML Forms A common and simple way of...
4
1922
by: jobs | last post by:
Hello. If my users are logged in, and try to access restricted pages I want to direct them to a custom 403 page. If they are not logged in, I would like to continue to direct them to the login page as is currently happening. Curently, they always direct to the Login page in both cases, which i think is confusing.
11
2075
by: Helmut Jarausch | last post by:
Sorry, but I'm a complete newbee! I need find out under which userid the browser is running. Is this possible with JavaScript? Many thanks for a hint, Helmut Jarausch Lehrstuhl fuer Numerische Mathematik
2
3925
by: ThatsIT.net.au | last post by:
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...
0
8878
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
9398
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...
1
9165
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
9097
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...
1
6699
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
6006
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
4507
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...
1
3216
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
2626
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.