Login with email not UserName

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 [ Mo, 31 März 2008 12:36 ] [ ID #1932599 ]

Re: Login with email not UserName

On Mar 31, 9:36=A0pm, andyt... [at] 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.
andytidy [ Mo, 31 März 2008 13:17 ] [ ID #1932602 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Login with email not UserName

Vorheriges Thema: TreeView, Localized Resource files and Visual Studio 2005
Nächstes Thema: What kind of data access you will use for the project with very large