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.ValidateUser(). This seems to work fine, it returns true and the
next call to FormsAuthentication.RedirectFromLoginPage() 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.GetUser() 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.GetUser() 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.ValidateUser() and
FormsAuthentication.RedirectFromLoginPage() - 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_Authenticate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles MyLogin.Authenticate

Dim username, password, location As String

username = MyLogin.UserName
password = MyLogin.Password

' 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.Special Then
location = DirectCast(MyLogin.FindControl("Location"), TextBox).Text.Trim()
If location.Length > 0 Then
username = username & "~" & location
End If
End If

e.Authenticated = Membership.ValidateUser(username, password)

If e.Authenticated Then
FormsAuthentication.RedirectFromLoginPage(username, False)
End If

End Sub


.



Relevant Pages

  • Re: Unable to log into OWA despite using correct username and pass
    ... the OWA interface despite using the correct username and password. ... OWA login page is displayed correctly but when trying to login users get ... "You could not be logged on to Outlook Web Access. ... The issue is affecting all accounts including the 'Administrator' ...
    (microsoft.public.exchange.clients)
  • Re: ADSL connection username change (bt_test) - Side effects?
    ... automatically re-establish itself after a failure, ... does using the BT test login have any side effects. ... Has you tried re-entering the username and PW prior to trying ... My router recently locked me out of MAC code filtering settings and it was ...
    (uk.telecom.broadband)
  • Re: failed password tries...!!
    ... but log only the username if the ... password/username pair is reversed but otherwise valid; and if a login ... The encryption code must be on the auth ... without first compromising your private key somehow. ...
    (comp.lang.java.programmer)
  • Re: Problem with Upgrade MS Access 2003 to Access 2007
    ... requires a login (I assume you mean username) and password. ... When working with Workgroup Security the best advice is to realize ... I did go to the immediate window posting, and tried it out, doing the command ...
    (microsoft.public.access.security)
  • eFiction <= 2.0 multiple vulnerabilities
    ... "Efiction is a software program that enables users to run automated original or fanfiction ... if magic_quotes_gpc off -> Login bypass: ... username: 'UNION SELECT 'd41d8cd98f00b204e9800998ecf8427e',penname,uid,userskin,level,email FROM fanfiction_authors where level=1/* ...
    (Bugtraq)