ASP.NET Forums注册时,是通过Encrypt(明文密码,Salt)把密码加密后写在users表的password字段里.但我自己也用同样的方法写进这个表里(我自己另做了一个登录的界面).但登录的时候在我的界面里就可能登录,在论坛的登录就登不了.我比较过密码,是一样的.现在问题是
在论坛注册的用户在我自己写的登录界面上可以登录
在我写的注册界面上注册的用户上在论坛不能登录???? 
public static LoginUserStatus ValidUser(User user, bool isRequestFromWebService) 

ForumsDataProvider dp = ForumsDataProvider.Instance(); // Lookup account by provided username 
// 查找用户状态,以确保根据用户帐户状态进行操作. 
// 检查用户登录用户名密码是否统一,帐户是否禁止等. 
User userLookup = Users.FindUserByUsername(user.Username); 
if (userLookup == null) 
return LoginUserStatus.InvalidCredentials; // 检测帐号状态 
if (userLookup.IsBanned && DateTime.Now <= userLookup.BannedUntil) 

// 帐号禁止 
return LoginUserStatus.AccountBanned; 

// 帐号封禁 
else if (userLookup.IsBanned && DateTime.Now > userLookup.BannedUntil) 

// Update to back to datastore 
userLookup.AccountStatus = UserAccountStatus.Approved; 
userLookup.BannedUntil = DateTime.Now; Users.UpdateUser(userLookup); 

// 待批准 
if (userLookup.AccountStatus == UserAccountStatus.ApprovalPending) 

return LoginUserStatus.AccountPending; 

// 未批准 
if (userLookup.AccountStatus == UserAccountStatus.Disapproved) 

return LoginUserStatus.AccountDisapproved; 
} // if (HttpContext.Current.User.Identity.AuthenticationType == "" ) 
// 如果不是来自WS请求 
if (!isRequestFromWebService) 

// 获取用户Salt和密码加密格式,密码 
user.Salt = userLookup.Salt; 
user.PasswordFormat = userLookup.PasswordFormat; // Lucian: I think it must be reused. Usefull when there are a wide range of passwd formats. 
// Set the Password 
user.Password = Users.Encrypt(user.PasswordFormat, user.Password, user.Salt); 

// 通过数据库中验证用户. 
return (LoginUserStatus) dp.ValidateUser(user); 

在这里报的错
User userLookup = Users.FindUserByUsername(user.Username); 
if (userLookup == null) 
return LoginUserStatus.InvalidCredentials; FindUserByUsername中做了值么操作了.谁能给讲一下. 

解决方案 »

  1.   

    我不能在程序里跟,只是看提示的错误是"用户名或密码错误"
    看代码是
    User userLookup = Users.FindUserByUsername(user.Username); 
    if (userLookup == null) 
    return LoginUserStatus.InvalidCredentials; 执行FindUserByUsername错误.
      

  2.   

    我比较过密码,是一样的.
    ---
    你是比较的是明文还是密文? 看看Salt的值是不是相同?
      

  3.   

    那你查查FindUserByUsername的源码吧
      

  4.   

    我这代码不能运行.上hidotnet.com网上问.都是一些垃圾人。一个也不会回答.打开站点就报错.那个错误.版主说是下个版本就解决了.唉.我晕了.
      

  5.   

    hidotnet.com很久没更新了看community server吧