This is the common question when we forgot the password of user 'host'.
The difficult is : Dotnetnuke use AspNetSqlMembershipProvider for user administration, this provider gives us theses functions bellow :
- ChangePassword(username, oldPassword, newPassword);
- ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);
- ChangePassword(userInfo, oldPassword, newPassword)
We have the function SetPassword(userInfo , newPassword ) but it not works.
I will provide other solution :
1/ using this statement for get all username anh userid
string strSQL = @"SELECT u.UserName, ms.Password, ms.PasswordFormat, ms.PasswordSalt, u.UserId
FROM aspnet_Users AS u INNER JOIN
aspnet_Membership AS ms ON u.UserId = ms.UserId";
an then use this for change the password of all user (host and other):
string strSQL = "SELECT PasswordSalt from aspnet_Membership where UserId='" + userid + "'";
object oPasswordSalt = DataFactory.ExecuteScalar(strSQL);
Crypto cy = new Crypto();
string password = cy.Encode(txtPassword.Text, oPasswordSalt.ToString());
strSQL = "update aspnet_membership set password='" + password + "' where userid='" + userid + "'";
DataFactory.Execute(strSQL);
Response.Write("<script> K!');</script>");
the class 'Crypto' i will provider after.