आप पासवर्ड बदलने के लिए सक्षम नहीं हैं, तो requiresQuestionAndAnswer = "true"
मैं web.config में इस
निर्मित दो सदस्यता प्रदाताओं के लिए चारों ओर काम मिल गया
मैं पासवर्ड रीसेट करने के लिए AspNetSqlMembershipProviderReset प्रदाता का उपयोग कर रहा हूं क्योंकि इसकी आवश्यकता है QuestionAndAnswer = false जहां AspNetSqlMembershipProvider डिफ़ॉल्ट प्रदाता का उपयोग किया जाता है।
मैंने उपयोगकर्ता के लिए पासवर्ड रीसेट करने के लिए निम्न कोड लिखा था।
सार्वजनिक bool ResetUserPassword (स्ट्रिंग psUserName, स्ट्रिंग psNewPassword) { कोशिश { // आवश्यक प्रश्न जवाब गलत पर सेट के साथ secound सदस्यता प्रदाता का उपयोग कर सदस्यता उपयोगकर्ता विवरण प्राप्त करें।
MembershipUser currentUser = Membership.Providers["AspNetSqlMembershipProviderReset"].GetUser(psUserName,false);
//Reset the user password.
String vsResetPassword = currentUser.ResetPassword();
//Change the User password with the required password
currentUser.ChangePassword(vsResetPassword, psNewPassword);
//Changed the comments to to force the user to change the password on next login attempt
currentUser.Comment = "CHANGEPASS";
//Check if the user is locked out and if yes unlock the user
if (currentUser.IsLockedOut == true)
{
currentUser.UnlockUser();
}
Membership.Providers["AspNetSqlMembershipProviderReset"].UpdateUser(currentUser); return true;
}
catch (Exception ex)
{
throw ex;
return false;
}
}
स्रोत
2011-02-04 16:38:09
आपको अपना प्रश्न अलग करना चाहिए और एक उत्तर जोड़ना चाहिए। –
@mcqwerty, अब हमने आपका जवाब अलग कर दिया है, आपको अपने उत्तर को "स्वीकार" करना चाहिए – harriyott
अच्छी नौकरी, मैंने इसे चेंजपासवर्ड नियंत्रण के हमारे संस्करण (उपयोगकर्ताओं के लिए व्यवस्थापक बदलना पासवर्ड) के साथ किया;) – CheGueVerra