ldap2: add otp support to modify_password

https://fedorahosted.org/freeipa/ticket/4262

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik
2014-05-23 15:53:54 +02:00
parent 3e0245f28f
commit 7fca783ec5

View File

@@ -408,18 +408,21 @@ class ldap2(LDAPClient, CrudBackend):
return False
def modify_password(self, dn, new_pass, old_pass=''):
def modify_password(self, dn, new_pass, old_pass='', otp='', skip_bind=False):
"""Set user password."""
assert isinstance(dn, DN)
# The python-ldap passwd command doesn't verify the old password
# so we'll do a simple bind to validate it.
if old_pass != '':
if not skip_bind and old_pass != '':
pw = old_pass
if (otp):
pw = old_pass+otp
with self.error_handler():
conn = IPASimpleLDAPObject(
self.ldap_uri, force_schema_updates=False)
conn.simple_bind_s(dn, old_pass)
conn.simple_bind_s(dn, pw)
conn.unbind_s()
with self.error_handler():