473,856 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem handling Login control Authenticate event

I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0.
The existing ASP application has several types of users, each with a separate
login process (separate login page, separate DB tables, etc). For one of
these user types, the current application has an additional input field
required for login… they have a username, password, and another “location
code” field. Please don’t make me explain or justify this… the mandate is
for the new ASP.NET 2.0 site not to require users to log in any differently.

I concatenate the existing username with the “location code”, with a
delimiter character between them. This way I can transition the existing
logins to the aspnet_DB schema that uses the normal username & password
fields. Users who input the additional “location code” field will not know
it, but their username will actually be the form of “current username +
delimiter + location code”.

I have converted the built-in Login control to use a Template, and have the
means to show/hide the extra textbox. I am handling the Login control’s
Authenticate event (code below), and when the extra input field is submitted
I concatenate the username with the location code, passing these to
Membership.Vali dateUser(). This seems to work fine, it returns true and the
next call to FormsAuthentica tion.RedirectFr omLoginPage() works, and the login
seems to work (access is granted to appropriate pages based on web.config,
LoginStatus control displays correctly, etc.)

However, for the users where this concatenation of the two input field
values is executed, the login is somehow not really complete. In these
cases, Membership.GetU ser() returns null, and the LoginName control displays
only the username entered in the default input field, not the full string
that I build with the concatenation of the extra “location code” input field.

For user types where the extra field is not present and the concatenation is
not done, Membership.GetU ser() returns the correct user object.

What am I missing? Is there some other event I need to handle, or method I
need to call? In the .NET 2.0 doc files, “about Membership class” the
Example code only references Membership.Vali dateUser() and
FormsAuthentica tion.RedirectFr omLoginPage() - though this is not handling the
Authenticate event, but is just a traditional login with textboxes, not the
Login control.

Thanks in advance!!

CODE:
Protected Sub MyLogin_Authent icate(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Auth enticateEventAr gs) Handles MyLogin.Authent icate

Dim username, password, location As String

username = MyLogin.UserNam e
password = MyLogin.Passwor d

' concat location with username for special login,
' allows them to log in the same way they always have,
' while allowing us to use Membership API based on username & password
If m_LoginUserType = LoginType.Speci al Then
location = DirectCast(MyLo gin.FindControl ("Location") , TextBox).Text.T rim()
If location.Length > 0 Then
username = username & "~" & location
End If
End If

e.Authenticated = Membership.Vali dateUser(userna me, password)

If e.Authenticated Then
FormsAuthentica tion.RedirectFr omLoginPage(use rname, False)
End If

End Sub
Feb 7 '06 #1
1 4543
I seem to have found my own solution... I'm posting in case anyone else will
find this helpful. I added an event handler for the Login control LoggingIn
event. In this handler method I directly modify the Login control UserName
property when the login is my special case, doing the concatenation of the
additional input field with the UserName. This way, when the Authenticate
event fires next, the value has already been modified as I need it. Now,
everything works, including Membership.GetU ser() returning a valid object.

There is definitely something about the way I was doing it before that is
not sufficient... the same two method calls - Membership.Vali dateUser() and
FormsAuthentica tion.RedirectFr omLoginPage() - ARE sufficient to do everything
on a regular ASPX page with textboxes and a button click event, but NOT when
you just handle the Login control Authenticate event. I also have a need to
accept a simple HTML form post to allow a login from a web page outside my
new ASP.NET app (still in same web domain). For this I use the same two
method calls and everything works fine. But with the Login control, despite
my Authenticate code shown in my post above, there was still something going
on under the hood resulting in a partially incomplete login (see above).
"EricRybarc zyk" wrote:
What am I missing? Is there some other event I need to handle, or method I
need to call? In the .NET 2.0 doc files, “about Membership class” the
Example code only references Membership.Vali dateUser() and
FormsAuthentica tion.RedirectFr omLoginPage() - though this is not handling the
Authenticate event, but is just a traditional login with textboxes, not the
Login control.


Feb 8 '06 #2

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

Similar topics

1
2806
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value in a variable and make the request again with that cookie as a header value (Digest Authentication). But, the problem we are facing is: That the HttpWebRequest is getting two responses simultaneously, which means that the code should wait after the...
3
2479
by: I am Sam | last post by:
Please help. I'm dying here and pulling out the last few remaining elements of my hair over this. I have built a form that will identify and authenticate users. I keep getting the following error with the Form: Compiler Error Message: CS0122: 'Sonar3.Controls.LoginControl.Button_Click(object, System.EventArgs)' is inaccessible due to its protection level
2
1881
by: ad | last post by:
I use Login control's Authenticate event to authenticate use. I find that different users can use the same ID to login in the same time. How can I restrict that the some ID can only login once in the some time
4
1716
by: ad | last post by:
I use Login control to authenticate use. How to get the list of user ID who have login in?
3
3837
by: Brian Henry | last post by:
I have an existing user managment system that has been in our asp.net 1.1 app for a couple years now, all the user managment is done through an application that is a win form, and stored in SQL Server. I want to see if I can at all use the new login controls with my existing scheme for user managment... Is there a way to use your own system with these controls or do you have to use ASP.NET's managment of users to use these controls?...
1
3435
by: leslie_tighe | last post by:
Hello, I have webservice created with Axis 1.2.1 and that I am trying to consuming in .NET (VB) using the Microsoft provided tools. While I am able to consume methods on the service that return simple type, I cannot consume methods that return complex objects. I have tried experimenting, with this, but am at a bit of loss on where the problem lies. When I call the services from a browser, I do get back the response that contains valid...
3
2127
by: Bruce | last post by:
I just started the design of an ASP.NET application which accesses one of our custom web services to provide user authentication, among other purposes. I created a log-in page (code below), using the WebControls.Login control. I put a simple label on the page, to display text showing whether the log-in was successful. I populate the Label.Text from within the event handler for the Login control's Authenticate event. But when I run...
5
1925
by: Afshar | last post by:
Hi everybody there, I have a special Login page that wants users to enter 3 passwords rather than a single password. But can't do it with Login control. I tried following scenarios: 1. Put an Login in the page and set its Visible = False instead put my own username and 3 password on the form. Then I checked 2nd and 3rd password seperately and passed username and password to Login control via its Username and Password properties but...
10
1509
by: SAL | last post by:
Hello, I'm still having trouble getting my app to authenticate correctly. I have read the tips at: http://www.devhood.com/messages/message_view-2.aspx?thread_id=72204 and am still having trouble making this happen correctly. Here are my settings. SQL Server 2005 db access is required Web page Anonymous access is turned off in IIS.
0
9921
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9765
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,...
1
10795
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
10390
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
9536
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 projectplanning, coding, testing, and deploymentwithout 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
7934
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
7098
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
5763
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
4581
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

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.