cannot login with Login control

A

ad

I use login control of VS2005 in my web application.
The web applicaiton is developed in my notebook.
It run ok in my notebook,
but when I login in from another PC with the user ID and password, it can't
login in.

I tried again and again. When I login with incorrect password, the login
control display the FailureText.
But when I enter the correct password, the Failure Text disappear but it
still stay in the login page.

How can I do?
 
G

Guest

Are you using Forms Authentication? You really haven't provided much
information at all here. Do you want to post some sample code?
Peter
 
A

ad

Yes, I am using Forms Authentication, I inherrited a MembershipProvider.
My custom MembershipProvider is below



//-------------------Code----------------------------------------------
public class MyMembershipProvider : MembershipProvider
{
private FormsAuthenticationUserCollection _users = null;
private FormsAuthPasswordFormat _passwordFormat;
//private int _MinRequiredNonAlphanumericCharacters = 0;
private int _MinRequiredPasswordLength = 4;
//private int _MaxInvalidPasswordAttempts = 5;
//private int _PasswordAttemptWindow = 5;


#region Not Implemented Members
public override string ApplicationName
{
get
{
throw new Exception("The method or operation is not
implemented.");
}
set
{
throw new Exception("The method or operation is not
implemented.");
}
}


public override bool ChangePasswordQuestionAndAnswer(string
username, string password, string newPasswordQuestion, string
newPasswordAnswer)
{
throw new Exception("The method or operation is not
implemented.");
}

public override MembershipUser CreateUser(string username, string
password, string email, string passwordQuestion, string passwordAnswer, bool
isApproved, object providerUserKey, out MembershipCreateStatus status)
{
throw new Exception("The method or operation is not
implemented.");
}

public override bool DeleteUser(string username, bool
deleteAllRelatedData)
{
throw new Exception("The method or operation is not
implemented.");
}

public override bool EnablePasswordReset
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override bool EnablePasswordRetrieval
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override MembershipUserCollection FindUsersByEmail(string
emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new Exception("The method or operation is not
implemented.");
}

public override MembershipUserCollection FindUsersByName(string
usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new Exception("The method or operation is not
implemented.");
}

public override MembershipUserCollection GetAllUsers(int pageIndex,
int pageSize, out int totalRecords)
{
throw new Exception("The method or operation is not
implemented.");
}

public override int GetNumberOfUsersOnline()
{
throw new Exception("The method or operation is not
implemented.");
}

public override string GetPassword(string username, string answer)
{
throw new Exception("The method or operation is not
implemented.");
}


public override MembershipUser GetUser(object providerUserKey, bool
userIsOnline)
{
throw new Exception("The method or operation is not
implemented.");
}

public override string GetUserNameByEmail(string email)
{
throw new Exception("The method or operation is not
implemented.");
}


public override int PasswordAttemptWindow
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override MembershipPasswordFormat PasswordFormat
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override string PasswordStrengthRegularExpression
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override bool RequiresQuestionAndAnswer
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override bool RequiresUniqueEmail
{
get { throw new Exception("The method or operation is not
implemented."); }
}

public override string ResetPassword(string username, string answer)
{
throw new Exception("The method or operation is not
implemented.");
}

public override bool UnlockUser(string userName)
{
throw new Exception("The method or operation is not
implemented.");
}

public override void UpdateUser(MembershipUser user)
{
throw new Exception("The method or operation is not
implemented.");
}

#endregion

public override int MaxInvalidPasswordAttempts
{
get {
throw new Exception("The method or operation is not
implemented.");
//return _MaxInvalidPasswordAttempts;
}
}

public override int MinRequiredNonAlphanumericCharacters
{
get {
throw new Exception("The method or operation is not
implemented.");
// return _MinRequiredNonAlphanumericCharacters;
}
}

public override int MinRequiredPasswordLength
{
get
{
throw new Exception("The method or operation is not
implemented.");

// return _MinRequiredPasswordLength;
}

}

public override MembershipUser GetUser(string username, bool
userIsOnline)
{
DateTime myDate = DateTime.Today;
MembershipUser user = new MembershipUser(
Name, // Provider name
username, // Username
null, // providerUserKey
"(e-mail address removed)", // Email
String.Empty, // passwordQuestion
"Comment", // Comment
true, // isApproved
false, // isLockedOut
DateTime.Now, // creationDate
DateTime.Now, // lastLoginDate
DateTime.Now, // lastActivityDate
DateTime.Now, // lastPasswordChangedDate
new DateTime(1980, 1, 1) // lastLockoutDate
);
return user;

}


public override bool ChangePassword(string username, string
oldPassword, string newPassword)
{
if (DMHealth.CheckPW(username, oldPassword))
{
//newPassword = DMHealth.MyEncrypt(newPassword);//¤£¥[±K
string sSql = string.Empty;
if (username == DMHealth.sAd)
{
sSql = "Update SystemSet set Setting='" + newPassword +
"' where Item='" + DMHealth.sAd + "'";
Se.SetKey(DMHealth.sAd, newPassword);
}
else
{
int iYears = DMHealth.GetYearsFromUserID(username);
string sYears = iYears.ToString();
int iClassID = DMHealth.GetClassIDFromUserID(username);
string sClassID = iClassID.ToString();
sSql = "Update YearsClass set PW='" + newPassword + "'
where Years=" + sYears + " and ClassID=" + sClassID;
}
WillNs.DM.ExecuteNonQuery(sSql);
//FailureText.Text = "±K½X§ó§ï¦¨¥\";
return true;
}
else
{
//FailureText.Text = "±K½X¿ù»~";
return false;
}
}


public override void Initialize(string name,
System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
_passwordFormat = getPasswordFormat();
string sMin=config["minRequiredPasswordLength"].ToString();
sMin = WillNs.Util.GetDefault(sMin, "4");
_MinRequiredPasswordLength = int.Parse(sMin);
}

public override bool ValidateUser(string username, string password)
{
bool Authenticated = false;
Authenticated = DMHealth.CheckPW(username, password);
if (Authenticated)
{
HttpContext.Current.Session.Abandon();
new AuthenticationSuccessEvent(username, this).Raise();




return true;
}
else
{
new AuthenticationFailureEvent(username, this).Raise();
return false;
}
}

protected FormsAuthenticationUserCollection getUsers()
{
if (_users == null)
{
AuthenticationSection section = getAuthenticationSection();
FormsAuthenticationCredentials creds =
section.Forms.Credentials;
_users = section.Forms.Credentials.Users;
}

return _users;
}

protected AuthenticationSection getAuthenticationSection()
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
return
(AuthenticationSection)config.GetSection("system.web/authentication");
}

protected FormsAuthPasswordFormat getPasswordFormat()
{
return
getAuthenticationSection().Forms.Credentials.PasswordFormat;
}
protected MembershipSection getMembershipSection()
{
Configuration config =
WebConfigurationManager.OpenWebConfiguration("~");
return
(MembershipSection)config.GetSection("system.web/Membership");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top