def restore_user_password(self, username, new_password): """Restore user password to its initial state.""" from modoboa.lib.ldap_utils import LDAPAuthBackend backend = LDAPAuthBackend() for password in ["Toto1234", "test"]: try: backend.update_user_password(username, password, new_password) except exceptions.InternalError: pass else: return raise RuntimeError("Can't restore user password.")
def restore_user_password(self, username, new_password): """Restore user password to its initial state.""" from modoboa.lib.ldap_utils import LDAPAuthBackend backend = LDAPAuthBackend() for password in ["Toto1234", "test"]: try: backend.update_user_password( username, password, new_password) except exceptions.InternalError: pass else: return raise RuntimeError("Can't restore user password.")
def set_password(self, raw_value, curvalue=None): """Password update Update the current mailbox's password with the given clear value. This value is encrypted according to the defined method before it is saved. :param raw_value: the new password's value :param curvalue: the current password (for LDAP authentication) """ if self.is_local: self.password = self._crypt_password(raw_value) else: if not ldap_available: raise InternalError( _("Failed to update password: LDAP module not installed")) LDAPAuthBackend().update_user_password(self.username, curvalue, raw_value) events.raiseEvent("PasswordUpdated", self, raw_value, self.pk is None)
def set_password(self, raw_value, curvalue=None): """Password update Update the current mailbox's password with the given clear value. This value is encrypted according to the defined method before it is saved. :param raw_value: the new password's value :param curvalue: the current password (for LDAP authentication) """ ldap_sync_enable = param_tools.get_global_parameter("ldap_enable_sync") if self.is_local or ldap_sync_enable: self.password = self._crypt_password(raw_value) else: if not ldap_available: raise InternalError( _("Failed to update password: LDAP module not installed")) LDAPAuthBackend().update_user_password(self.username, curvalue, raw_value) signals.account_password_updated.send(sender=self.__class__, account=self, password=raw_value, created=self.pk is None)
def ldapauthbackend(self): """Return LDAPAuthBackend instance.""" from modoboa.lib.ldap_utils import LDAPAuthBackend return LDAPAuthBackend()