1. Peter Sagerson
  2. django-auth-ldap
  3. Issues


Issue #22 wontfix

change password by _LDAPUser

Anonymous created an issue

i needed this feature for my users ... changing theirs own ldap password.

I'll use this code some next weeks and my some tests are concluants with OpenLdap (self write ACL) tell me if i am crazy to use this code.

And may be you are interested to introduce this feature into THE py-django-ldap-backend ?

best regards

scr {{{


class _LDAPUser(object): ... class UpdatePasswordFailed(Exception): pass

def update_ldap_password(self, password, new_password): if self.dn is None: raise self.UpdatePasswordFailed("DN unknown") try: logger.debug(u"update password : %s / %s" % (password, new_password)) self._bind_as(self.dn, password) ldap_cnx = self._get_connection().passwd_s(self.dn, password.encode('utf-8'), new_password.encode('utf-8')) logger.info(u"Successfull password update for %s", self.dn) except self.ldap.INVALID_CREDENTIALS: logger.warn(u"Authentification failed for %s", self.dn) raise self.UpdatePasswordFailed(u"Authentification") except self.ldap.LDAPError, e: logger.error(u"Erreur Ldap (type: %s) :", type(e)) logger.error(''.join(traceback.format_tb(sys.exc_info()[2]))) raise self.UpdatePasswordFailed(u"Failed to update password !")


Comments (2)

  1. Peter Sagerson repo owner

    Thanks for the contribution. At present, django-auth-ldap limits itself to being a django.contrib.auth plugin and does not include any mechanisms to manipulate the directory. One of my projects also has need of this functionality and I implement it in a separate app that uses python-ldap directly (it's pretty straightforward). It's possible that password-changing will appear in a future version, as part of a more carefully thought-out design for supporting directory manipulation.

  2. Log in to comment