Use LdapManager to change password
This commit is contained in:
parent
f6f688dcb5
commit
122ee37e48
2 changed files with 8 additions and 5 deletions
|
@ -23,6 +23,7 @@ LDAP_ADMIN_DN = config('LDAP_ADMIN_DN')
|
||||||
LDAP_ADMIN_PASSWORD = config('LDAP_ADMIN_PASSWORD')
|
LDAP_ADMIN_PASSWORD = config('LDAP_ADMIN_PASSWORD')
|
||||||
AUTH_LDAP_BIND_DN = LDAP_ADMIN_DN
|
AUTH_LDAP_BIND_DN = LDAP_ADMIN_DN
|
||||||
AUTH_LDAP_BIND_PASSWORD = LDAP_ADMIN_PASSWORD
|
AUTH_LDAP_BIND_PASSWORD = LDAP_ADMIN_PASSWORD
|
||||||
|
AUTH_LDAP_SERVER = AUTH_LDAP_SERVER_URI
|
||||||
|
|
||||||
LDAP_CUSTOMER_DN = config('LDAP_CUSTOMER_DN')
|
LDAP_CUSTOMER_DN = config('LDAP_CUSTOMER_DN')
|
||||||
LDAP_USERS_DN = config('LDAP_USERS_DN')
|
LDAP_USERS_DN = config('LDAP_USERS_DN')
|
||||||
|
|
12
dal/views.py
12
dal/views.py
|
@ -405,12 +405,14 @@ class ChangePassword(View):
|
||||||
if len(password1) < 8:
|
if len(password1) < 8:
|
||||||
return render(request, 'error.html', { 'urlname': urlname, 'service': service,
|
return render(request, 'error.html', { 'urlname': urlname, 'service': service,
|
||||||
'error': 'The password is too short, please use a longer one. At least 8 characters.' } )
|
'error': 'The password is too short, please use a longer one. At least 8 characters.' } )
|
||||||
with get_pool().next() as rpc:
|
from .ungleich_ldap import LdapManager
|
||||||
# Trying to change the password
|
ldap_manager = LdapManager()
|
||||||
pwd = r'%s' % password1
|
result = ldap_manager.change_password(
|
||||||
result = rpc.changepassword.change_password(user, pwd)
|
("uid={uid}," + settings.LDAP_CUSTOMER_DN).format(uid=user),
|
||||||
|
password1
|
||||||
|
)
|
||||||
# Password was changed
|
# Password was changed
|
||||||
if result == True:
|
if result:
|
||||||
return render(request, 'changedpassword.html', { 'user': user } )
|
return render(request, 'changedpassword.html', { 'user': user } )
|
||||||
# Password not changed, instead got some kind of error
|
# Password not changed, instead got some kind of error
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue