MembershipUser objUsr = Membership.GetUser(MailId);
if (objUsr != null)
{
lblMsg.Text = "Hi";//here i am getting the mailid(i.e same as UserName) correctly.
}
//objUsr.IsApproved = true;
bool s = Membership.ValidateUser(MailId, Pwd);but here it is not getting validated
if (Membership.ValidateUser(MailId, Pwd))
{
So MailId is the username..that user enter to login correct???
Secondly since ObjUsr is not null....user exists ..that leads to one following:
1: Password incorrect
2: User is Locked
3: User is not Approved
4: somethin else???? and needs more investigation. i.e. was it working before and stopped working? did you make any other changes like passwordFormat or something to your memberhsip provider....and so on.
I have the same problem... for some reason if I use, Membership.ValidateUser(userId, pwd) in the page_load event it always returns false. However, if I use the same code in the Logging_In event of the Login control -- it works... It is still a mystery to me...but,
atleast it works as designed in the Logging_in event. Also, I expected the FormsAuthentication.Authenticate(userID, password) also to work...but this does not work either.... emmm....
Authentication Securityauthorization managementauthorization Asp.net login anonymous
I have the same problem... for some reason if I use, Membership.ValidateUser(userId, pwd) in the page_load event it always returns false. However, if I use the same code in the Logging_In event of the Login control -- it works... It is still a mystery to me...but,
atleast it works as designed in the Logging_in event. Also, I expected the FormsAuthentication.Authenticate(userID, password) also to work...but this does not work either.... emmm....
Membership Provider
Marked as answer by vinayuthappa on Mar 05, 2009 10:34 AM
vinayuthappa
Member
291 Points
151 Posts
Membership.ValidateUser always returns False
Mar 03, 2009 02:38 PM|LINK
Hi All,
I have a code here, when i try to login,the validate user always returns false.
here is the code,
protected void btnSignIn_ServerClick(object sender, EventArgs e)
{
string MailId = txtMailId.Text.Trim();
string Pwd = txtPwd.Text.Trim();
MembershipUser objUsr = Membership.GetUser(MailId);
if (objUsr != null)
{
lblMsg.Text = "Hi";//here i am getting the mailid(i.e same as UserName) correctly.
}
//objUsr.IsApproved = true;
bool s = Membership.ValidateUser(MailId, Pwd);but here it is not getting validated
if (Membership.ValidateUser(MailId, Pwd))
{
lblMsg.Visible = true;
lblMsg.Text = "Successfully login";
string UserID = objUsr.ProviderUserKey.ToString();
string UserName = User.Identity.Name;
Session.Add("UserId", UserID);
}
else
{
lblMsg.Visible = true;
lblMsg.Text = "Invalid User Credential";
}
}
validation membership.validateuser membership.validate membership validate user getuser
C# .Net
Visual Studio 2008
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: Membership.ValidateUser always returns False
Mar 03, 2009 05:01 PM|LINK
So MailId is the username..that user enter to login correct???
Secondly since ObjUsr is not null....user exists ..that leads to one following:
1: Password incorrect
2: User is Locked
3: User is not Approved
4: somethin else???? and needs more investigation. i.e. was it working before and stopped working? did you make any other changes like passwordFormat or something to your memberhsip provider....and so on.
vinayuthappa
Member
291 Points
151 Posts
Re: Membership.ValidateUser always returns False
Mar 04, 2009 03:09 AM|LINK
here is the configuration settings i have made,
<connectionStrings>
<add name="Communities" connectionString="Data Source=VARISTADB1;Initial Catalog=RCB_Community;Persist Security Info=True;User ID=sa;Password=sql2005" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
<authentication mode="Forms">
</authentication>
<membership defaultProvider="SqlMembershipProvider">
<providers>
<add name="SqlMembershipProvider" passwordFormat="Hashed" type="System.Web.Security.SqlMembershipProvider" connectionStringName="Communities" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" requiresUniqueEmail="true"/>
</providers>
</membership>
</system.web>
C# .Net
Visual Studio 2008
buddy1
Member
12 Points
2 Posts
Re: Membership.ValidateUser always returns False
Mar 05, 2009 04:42 AM|LINK
Authentication Security authorization management authorization Asp.net login anonymous
buddy1
Member
12 Points
2 Posts
Re: Membership.ValidateUser always returns False
Mar 05, 2009 04:45 AM|LINK
Membership Provider
Wencui Qian ...
All-Star
56784 Points
5796 Posts
Microsoft
Re: Membership.ValidateUser always returns False
Mar 05, 2009 07:02 AM|LINK
Hi vinayuthappa,
I guess it may be caused by the name of membership provider. Please try again with following code:
Thanks.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework