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中做了值么操作了.谁能给讲一下.
在论坛注册的用户在我自己写的登录界面上可以登录
在我写的注册界面上注册的用户上在论坛不能登录????
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中做了值么操作了.谁能给讲一下.
解决方案 »
- 。。。访问外网的WCF,有IP过滤。。只添加了我本地的一个IP,那我局域网的其他机器怎么办?有没有类似添加代理服务器的功能?
- c#WinForm问题 请教高手
- 【。.[]】c# form里面的listBox控件里item有data属性吗?
- 带有密匙的安装程序怎么做?
- 树形控件怎么用啊,求高手
- 取PropertyGrid中一个单元的选择值
- 在C#中如何让播放器自动播放下一首歌?求大侠
- 大哥们救命,IDictionary的问题。
- 关于DataGrid最菜鸟的问题
- 窗体自动消失的问题
- 在vs2005中怎么在DataList中绑定超链接啊 ?
- 头一次使用.net2005 winfrom ,请问如何使用treeview控件?
看代码是
User userLookup = Users.FindUserByUsername(user.Username);
if (userLookup == null)
return LoginUserStatus.InvalidCredentials; 执行FindUserByUsername错误.
---
你是比较的是明文还是密文? 看看Salt的值是不是相同?