为什么我可以创建新用户,但当我立即尝试使用他们的凭据进行身份验证时,却失败了?
我创建一个新用户,批准他们,然后立即尝试使用我刚刚用于创建用户的凭据进行身份验证...并在 Authenticate 方法中返回“false”。
string username = "me";
string password = "mypassword";
string email = "[email protected]";
Membership.CreateUser(username, password, email);
currentUser = Membership.GetUser(username);
currentUser.IsApproved = true;
bool isAuthenticated = FormsAuthentication.Authenticate(username, password);
我检查了数据库表——用户是使用该用户名、密码和电子邮件创建的。根据数据库表,他们已获得批准。
然而,Authenticate 方法仍然返回 false。
I create a new user, approve them, then immediately attempt to authenticate with the credentials I just used to create the user...and get "false" back the Authenticate method.
string username = "me";
string password = "mypassword";
string email = "[email protected]";
Membership.CreateUser(username, password, email);
currentUser = Membership.GetUser(username);
currentUser.IsApproved = true;
bool isAuthenticated = FormsAuthentication.Authenticate(username, password);
I checked the database table -- the user is created with that username, password, and email. According to the database table, they are approved.
Yet, the Authenticate method still returns false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在更改其批准状态后调用 UpdateUser 方法...
http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.isapproved.aspx
You need to call the UpdateUser method after you change their approved status...
http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.isapproved.aspx
身份验证机制可能正在使用尚未级联的不同数据存储。
Likely that the authentication mechanism is using a different data store under the covers that has yet to be cascade to.