From 122ee37e48fc759cd425c510dcaf02da03321a28 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 23 Feb 2019 19:50:42 +0100 Subject: [PATCH] Use LdapManager to change password --- dal/settings.py | 1 + dal/views.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dal/settings.py b/dal/settings.py index a716182..8ba5c15 100644 --- a/dal/settings.py +++ b/dal/settings.py @@ -23,6 +23,7 @@ LDAP_ADMIN_DN = config('LDAP_ADMIN_DN') LDAP_ADMIN_PASSWORD = config('LDAP_ADMIN_PASSWORD') AUTH_LDAP_BIND_DN = LDAP_ADMIN_DN AUTH_LDAP_BIND_PASSWORD = LDAP_ADMIN_PASSWORD +AUTH_LDAP_SERVER = AUTH_LDAP_SERVER_URI LDAP_CUSTOMER_DN = config('LDAP_CUSTOMER_DN') LDAP_USERS_DN = config('LDAP_USERS_DN') diff --git a/dal/views.py b/dal/views.py index 8020e44..419e3b0 100644 --- a/dal/views.py +++ b/dal/views.py @@ -405,12 +405,14 @@ class ChangePassword(View): if len(password1) < 8: return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'The password is too short, please use a longer one. At least 8 characters.' } ) - with get_pool().next() as rpc: - # Trying to change the password - pwd = r'%s' % password1 - result = rpc.changepassword.change_password(user, pwd) + from .ungleich_ldap import LdapManager + ldap_manager = LdapManager() + result = ldap_manager.change_password( + ("uid={uid}," + settings.LDAP_CUSTOMER_DN).format(uid=user), + password1 + ) # Password was changed - if result == True: + if result: return render(request, 'changedpassword.html', { 'user': user } ) # Password not changed, instead got some kind of error else: