Login Problem

Topics: ASP.NET 2.0
Apr 14, 2009 at 6:59 PM
Added new columns firstname,lastname and sex in the sql be_users table, but now unable to login please suggest.
Apr 14, 2009 at 8:30 PM
Either delete those columns, or make them NULL-able.
Apr 15, 2009 at 6:35 AM
This problem has been solved but
 After log in I am trying to to get the userid and username using Linq, since there is a encryption for password I may not be able to get it.
  My code is lilke this, pleae suggest how can I use the code without membership usage.

    LinqChatDataContext db = new LinqChatDataContext();
        var user = (from u in db.be_Users
                    where u.Username == Login1.UserName
                    && u.Password == Login1.Password
                    select u).SingleOrDefault();

        if (user != null)
        Session["ChatUserID"] = user.UserID;
       Session["ChatUsername"] = Login1.UserName;

Prashanth Kumar Ganathe

Apr 15, 2009 at 6:41 AM
In login.aspx.cs, there's a Login1_LoggedIn() event handler (it's already in there).  I would suggest letting Membership do it's normal authentication.

When a person is authenticated, the Login1_LoggedIn event handler fires.  In that event handler, you can use your Linq query to lookup the other information.  The logged in username is available thru User.Identity.Name.  Each username is unique ... so you don't need to worry about checking the password.  So your Linq statement would look something like:

var user = (from u in db.be_Users
            where u.Username == User.Identity.Name
            select u).SingleOrDefault();
Apr 15, 2009 at 7:04 AM
Acutally I have many new table have included in the database to implement chating option which is are related to be_users by UserID, so I need to retrive
Apr 15, 2009 at 8:03 AM
It looks like the XmlMembershipProvider uses the Utils.HashPassword() method.

So in you Linq query, you should be able to do:

u.Password == Utils.HashPassword(Login1.Password)

You might need to fully qualify "Utils" ... i.e. BlogEngine.Core.Utils.HashPassword().