For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > March 2008 > Login with email not UserName









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Login with email not UserName
andytidy@gmail.com

2008-03-31, 6:13 am

When using the membership, user and roles providers, what is a
straight forward way to get users to login using an email address and
not a username?
andytidy@gmail.com

2008-03-31, 8:56 am

On Mar 31, 9:36=A0pm, andyt...@gmail.com wrote:
> When using the membership, user and roles providers, what is a
> straight forward way to get users to login using an email address and
> not a username?


OK, I just persisted on my search and found a simple enough answer:

Protected Sub AuthenticateLogin(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles
Login1.Authenticate
'
Dim UserInfo As MembershipUser
Dim UserInfoColl As MembershipUserCollection
Dim sUserName As String
UserInfoColl =3D Membership.FindUsersByEmail(Login1.UserName)
sUserName =3D ""
For Each UserInfo In UserInfoColl
' Should only return one.
sUserName =3D UserInfo.UserName
Next
If Membership.ValidateUser(sUserName, Login1.Password) Then
e.Authenticated =3D True
Else
e.Authenticated =3D False
End If

End Sub


I'm sure there are better ways, and I will have a look at this later
(although any suggestions would be appreciated).
All I need to do now is find the best way to link this to my Staff
database.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com