add new task set_ldap_user_password
This commit is contained in:
parent
3ab1c8cdbb
commit
023a9eb448
2 changed files with 23 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
* :feature:`-` add new task :py:func:`ldaptasks.tasks.set_ldap_user_password`
|
||||
|
||||
* :release:`0.3.0 <2015-01-19>`
|
||||
* :support:`-` move tasks from osusers to ldaptasks.tasks
|
||||
|
||||
|
|
|
@ -105,6 +105,27 @@ def create_ldap_user(username, uid, gid, gecos, homedir, shell, password):
|
|||
return ldapuser.dn
|
||||
|
||||
|
||||
@shared_task(bind=True)
|
||||
def set_ldap_user_password(self, username, password):
|
||||
"""
|
||||
This task sets the password of an existing :py:class:`LDAP user
|
||||
<ldapentities.models.LdapUser>`.
|
||||
|
||||
:param str username: the user name
|
||||
:param str password: teh clear text password
|
||||
:return: :py:const:`True` if the password has been set, :py:const:`False`
|
||||
if the user does not exist.
|
||||
|
||||
"""
|
||||
try:
|
||||
ldapuser = LdapUser.objects.get(username=username)
|
||||
except LdapUser.DoesNotExist:
|
||||
return False
|
||||
ldapuser.set_password(password)
|
||||
ldapuser.save()
|
||||
return True
|
||||
|
||||
|
||||
@shared_task(bind=True)
|
||||
def add_ldap_user_to_group(self, username, groupname):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue