reset user password
I have a server which has machines...
I have an administrator and multiple users... these are all windows users and not present in the databse.
How do i reset the user password.... i log in using the administrator and provide the username that needs to be reset..
I tried
string newPassword;
u = Membership.GetUser(UsernameTextBo开发者_如何学Pythonx.Text, false);
but this does not work...
any suggestions... thanks
Code to add users:
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry NewUser = AD.Children.Add(username, "user");
NewUser.Invoke("SetPassword", new object[] { password });
NewUser.Invoke("Put", new object[] { "Description", description });
NewUser.CommitChanges();
try this
string username = "user";
string password = "newpassword";
MembershipUser mu = Membership.GetUser(username);
mu.ChangePassword(mu.ResetPassword(), password);
if you have in your web.config requiresQuestionAnswer="true", you will get an error when you try and reset the password.
You are probably looking for the ResetPassword method. To reset to a known password you can use something like this:
MembershipUser currentUser = Membership.GetUser(user_name);
bool bPasswordChanged = false;
bPasswordChanged = currentUser.ChangePassword(currentUser.ResetPassword(), new_password);
I got it done by this methid.. it works thanks for the answers though
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry HostedUser = AD.Children.Find(hostedUserName, "user");
string password = new HostedGuiAddMachines().CreateRandomPassword(8);
HostedUser.Invoke("SetPassword", new object[] { password });
HostedUser.Close();
AD.Close();
精彩评论