473,847 Members | 1,894 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 1461
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

1
8875
by: jach | last post by:
How can I get the domain, username and PC network name (Win 2000 Pro & Win XP Pro PC's) of the current logged on user (logged onto a domain and access an intranet page, Window 2000 server running IIS) and put this automatically in a textbox in an webpage. Can this be done with asp & VB? I basically want to automatically populate a username field with the users logon so the do not need to type it themselves, leading to type errors. ...
3
1733
by: anon | last post by:
<?php if(! isset($_POST)) { header("Location: login.php"); } mysql_connect(DELETED) mysql_select_db(DELETED) $username = $_POST;
0
1213
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
5016
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
3333
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
2251
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
248324
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
1929
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
2087
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
3929
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
9879
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
9727
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
10978
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
10330
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
9477
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
7879
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
5716
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...
2
4113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3158
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.