J
Jeff
hi
asp.net 3.5
Below is my code for changing username and password of a user.
The problem is that I can make only 1 change. I mean I can once make a
change to username or password, or both. But the second time I make a change
the user will not be able to login
any suggestions?
ProfileCommon userProfile = GetProfileBySaleId(salgsid);
if (userProfile != null)
{
user.ChangePassword(userProfile.Postal.Code, postalcode);
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);
else
{
//okay, changing password wasn't enough, then the
//username need to be changed
try
{
string connstr =
ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();
using (SqlConnection cn = new SqlConnection(connstr))
{
SqlCommand cmd = new SqlCommand("ah_Updateuser", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@newname", SqlDbType.NVarChar).Value =
username;
cmd.Parameters.Add("@oldname", SqlDbType.NVarChar).Value =
userProfile.UserName;
cn.Open();
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);
}
}
}
asp.net 3.5
Below is my code for changing username and password of a user.
The problem is that I can make only 1 change. I mean I can once make a
change to username or password, or both. But the second time I make a change
the user will not be able to login
any suggestions?
ProfileCommon userProfile = GetProfileBySaleId(salgsid);
if (userProfile != null)
{
user.ChangePassword(userProfile.Postal.Code, postalcode);
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);
else
{
//okay, changing password wasn't enough, then the
//username need to be changed
try
{
string connstr =
ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();
using (SqlConnection cn = new SqlConnection(connstr))
{
SqlCommand cmd = new SqlCommand("ah_Updateuser", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@newname", SqlDbType.NVarChar).Value =
username;
cmd.Parameters.Add("@oldname", SqlDbType.NVarChar).Value =
userProfile.UserName;
cn.Open();
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);
}
}
}