ldap: use PASSWD command if old password is known (#30577)

If we do not know the old password it's better to try a MOD_REPLACE.
This commit is contained in:
Benjamin Dauvergne 2019-02-13 10:37:02 +01:00
parent e3e03d17e5
commit 75025ab544
1 changed files with 2 additions and 2 deletions

View File

@ -1002,8 +1002,8 @@ class LDAPBackend(object):
@classmethod
def modify_password(cls, conn, block, dn, old_password, new_password):
'''Change user password with adaptation for Active Directory'''
if block['use_password_modify'] and not block['active_directory']:
conn.passwd_s(dn, old_password or None, new_password)
if old_password is not None and (block['use_password_modify'] and not block['active_directory']):
conn.passwd_s(dn, old_password, new_password)
else:
modlist = []
if block['active_directory']: