Use LdapManager to change password

This commit is contained in:
PCoder 2019-02-23 19:50:42 +01:00
parent f6f688dcb5
commit 122ee37e48
2 changed files with 8 additions and 5 deletions

View File

@ -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')

View File

@ -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: