2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This module defines `Celery`_ tasks to manage LDAP entities.
|
|
|
|
|
|
|
|
.. _Celery: http://www.celeryproject.org/
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2014-05-30 12:12:21 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-02-07 22:41:36 +01:00
|
|
|
from copy import deepcopy
|
2020-03-03 12:20:13 +01:00
|
|
|
|
2014-05-30 12:12:21 +02:00
|
|
|
from celery import shared_task
|
2014-05-30 18:42:04 +02:00
|
|
|
from celery.exceptions import Reject
|
2020-03-03 12:20:13 +01:00
|
|
|
from celery.utils.log import get_task_logger
|
2014-05-31 15:18:39 +02:00
|
|
|
|
2020-03-03 12:20:13 +01:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2020-03-03 14:50:03 +01:00
|
|
|
from django.db.utils import Error as DjangoDBUtilsError
|
2014-05-30 12:12:21 +02:00
|
|
|
|
2020-03-03 12:20:13 +01:00
|
|
|
from ldapentities.models import LdapGroup, LdapUser
|
2014-05-30 12:12:21 +02:00
|
|
|
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER = get_task_logger(__name__)
|
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2016-02-07 22:41:36 +01:00
|
|
|
def create_ldap_group(groupname, gid, description):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This task creates an :py:class:`LDAP group <ldapentities.models.LdapGroup>`
|
|
|
|
if it does not exist yet.
|
|
|
|
|
|
|
|
If a group with the given name exists its group id and description
|
|
|
|
attributes are updated.
|
|
|
|
|
|
|
|
:param str groupname: the group name
|
|
|
|
:param int gid: the group id
|
2016-02-07 22:41:36 +01:00
|
|
|
:param str description: description text for the group
|
|
|
|
:return: dictionary containing groupname, gid, description and
|
|
|
|
:py:const:`group_dn` set to the distinguished name of the newly created
|
|
|
|
or existing LDAP group
|
|
|
|
:rtype: dict
|
|
|
|
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
2014-05-30 18:42:04 +02:00
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(name=groupname)
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP group %s with groupname %s already exists", ldapgroup.dn, groupname
|
|
|
|
)
|
2014-05-30 18:42:04 +02:00
|
|
|
ldapgroup.gid = gid
|
|
|
|
except LdapGroup.DoesNotExist:
|
|
|
|
ldapgroup = LdapGroup(gid=gid, name=groupname)
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("created LDAP group %s", ldapgroup.dn)
|
2016-02-07 22:41:36 +01:00
|
|
|
ldapgroup.description = description
|
2014-05-30 12:12:21 +02:00
|
|
|
ldapgroup.save()
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("set description of LDAP group %s", ldapgroup.dn)
|
2016-02-07 22:41:36 +01:00
|
|
|
return {
|
2020-03-03 12:20:13 +01:00
|
|
|
"groupname": groupname,
|
|
|
|
"gid": gid,
|
|
|
|
"description": description,
|
|
|
|
"group_dn": ldapgroup.dn,
|
2016-02-07 22:41:36 +01:00
|
|
|
}
|
2014-05-30 12:12:21 +02:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2014-05-30 18:42:04 +02:00
|
|
|
def create_ldap_user(username, uid, gid, gecos, homedir, shell, password):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This task creates an :py:class:`LDAP user <ldapentities.models.LdapUser>`
|
|
|
|
if it does not exist yet.
|
|
|
|
|
|
|
|
The task is rejected if the primary group of the user is not defined.
|
|
|
|
|
|
|
|
The user's fields are updated if the user already exists.
|
|
|
|
|
|
|
|
:param str username: the user name
|
|
|
|
:param int uid: the user id
|
|
|
|
:param int gid: the user's primary group's id
|
|
|
|
:param str gecos: the text for the GECOS field
|
|
|
|
:param str homedir: the user's home directory
|
|
|
|
:param str shell: the user's login shell
|
|
|
|
:param str or None password: the clear text password, if :py:const:`None`
|
|
|
|
is passed the password is not touched
|
|
|
|
:raises celery.exceptions.Reject: if the specified primary group does not
|
|
|
|
exist
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary containing username, uid, gid, gecos, homedir, shell,
|
|
|
|
password and :py:const:`user_dn` set to the distinguished name of the
|
|
|
|
newly created or existing LDAP user
|
|
|
|
:rtype: dict
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
"""
|
2014-05-30 18:42:04 +02:00
|
|
|
try:
|
|
|
|
ldapuser = LdapUser.objects.get(username=username)
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s with username %s already exists", ldapuser.dn, username
|
|
|
|
)
|
2014-05-30 18:42:04 +02:00
|
|
|
except LdapUser.DoesNotExist:
|
|
|
|
ldapuser = LdapUser(username=username)
|
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(gid=gid)
|
|
|
|
except ObjectDoesNotExist as exc:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.error("LDAP group with gid %d does not exist", gid)
|
2015-01-29 18:41:44 +01:00
|
|
|
raise Reject(exc, requeue=False)
|
2014-05-30 18:42:04 +02:00
|
|
|
ldapuser.uid = uid
|
|
|
|
ldapuser.group = gid
|
|
|
|
ldapuser.gecos = gecos
|
|
|
|
ldapuser.home_directory = homedir
|
|
|
|
ldapuser.login_shell = shell
|
|
|
|
ldapuser.username = username
|
|
|
|
ldapuser.common_name = username
|
|
|
|
if password is not None:
|
|
|
|
ldapuser.set_password(password)
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("set password for LDAP user %s", ldapuser.dn)
|
2015-01-29 21:35:33 +01:00
|
|
|
ldapuser.save()
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("LDAP user %s created", ldapuser.dn)
|
2014-05-30 18:42:04 +02:00
|
|
|
if ldapuser.username in ldapgroup.members:
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s is already member of LDAP group %s", ldapuser.dn, ldapgroup.dn
|
|
|
|
)
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
|
|
|
ldapgroup.members.append(ldapuser.username)
|
|
|
|
ldapgroup.save()
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s has been added to LDAP group %s", ldapuser.dn, ldapgroup.dn
|
|
|
|
)
|
2016-02-07 22:41:36 +01:00
|
|
|
return {
|
2020-03-03 12:20:13 +01:00
|
|
|
"username": username,
|
|
|
|
"uid": uid,
|
|
|
|
"gid": gid,
|
|
|
|
"gecos": gecos,
|
|
|
|
"homedir": homedir,
|
|
|
|
"shell": shell,
|
|
|
|
"user_dn": ldapuser.dn,
|
2016-02-07 22:41:36 +01:00
|
|
|
}
|
2014-05-30 18:42:04 +02:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2016-02-07 22:41:36 +01:00
|
|
|
def set_ldap_user_password(username, password):
|
2015-01-19 22:38:58 +01:00
|
|
|
"""
|
|
|
|
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
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary containing the username and a flag
|
|
|
|
:py:const:`password_set` that is set to :py:const:`True` if the
|
|
|
|
password has been set, :py:const:`False` if the user does not exist.
|
|
|
|
:rtype: dict
|
2015-01-19 22:38:58 +01:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"username": username, "password_set": False}
|
2015-01-19 22:38:58 +01:00
|
|
|
try:
|
|
|
|
ldapuser = LdapUser.objects.get(username=username)
|
|
|
|
except LdapUser.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("there is no LDAP user with username %s", username)
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
2015-01-19 22:38:58 +01:00
|
|
|
ldapuser.set_password(password)
|
|
|
|
ldapuser.save()
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info("set new password for LDAP user %s", ldapuser.dn)
|
2020-03-03 12:20:13 +01:00
|
|
|
retval["password_set"] = True
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
2015-01-19 22:38:58 +01:00
|
|
|
|
|
|
|
|
2020-03-03 14:54:16 +01:00
|
|
|
@shared_task(bind=True, autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2014-05-30 18:42:04 +02:00
|
|
|
def add_ldap_user_to_group(self, username, groupname):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This task adds the specified user to the given group.
|
|
|
|
|
|
|
|
This task does nothing if the user is already member of the group.
|
|
|
|
|
|
|
|
:param str username: the user name
|
|
|
|
:param str groupname: the group name
|
|
|
|
:raises celery.exceptions.Retry: if the user does not exist yet,
|
|
|
|
:py:func:`create_ldap_user` should be called before
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary containing the username, groupname and a flag
|
|
|
|
:py:const`added` that is as a :py:const:`True` if the user has been
|
|
|
|
added to the group otherwise to :py:const:`False`
|
|
|
|
:rtype: dict
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"username": username, "groupname": groupname, "added": False}
|
2014-05-30 18:42:04 +02:00
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(name=groupname)
|
|
|
|
ldapuser = LdapUser.objects.get(username=username)
|
|
|
|
except LdapGroup.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.error("LDAP group with groupname %s does not exist", groupname)
|
2014-05-30 18:42:04 +02:00
|
|
|
except LdapUser.DoesNotExist as exc:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.error("LDAP user with username %s does not exist", username)
|
2014-05-30 18:42:04 +02:00
|
|
|
self.retry(exc=exc, time_limit=5)
|
|
|
|
else:
|
2015-01-29 18:31:10 +01:00
|
|
|
if ldapuser.username not in ldapgroup.members:
|
2014-05-30 18:42:04 +02:00
|
|
|
ldapgroup.members.append(ldapuser.username)
|
|
|
|
ldapgroup.save()
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s has been added to LDAP group %s",
|
|
|
|
ldapuser.username,
|
|
|
|
ldapgroup.dn,
|
|
|
|
)
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s is already in LDAP group %s",
|
|
|
|
ldapuser.username,
|
|
|
|
ldapgroup.dn,
|
|
|
|
)
|
|
|
|
retval["added"] = True
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
2014-05-30 18:42:04 +02:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2014-05-30 18:42:04 +02:00
|
|
|
def remove_ldap_user_from_group(username, groupname):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This task removes the given user from the given group.
|
|
|
|
|
|
|
|
:param str username: the user name
|
|
|
|
:param str groupname: the group name
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary containing the input parameters and a flag
|
|
|
|
:py:const:`removed` that is set to :py:const:`True` if the user has
|
|
|
|
been removed, False otherwise
|
|
|
|
:rtype: dict
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"username": username, "groupname": groupname, "removed": False}
|
2015-01-29 18:31:10 +01:00
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(name=groupname)
|
|
|
|
ldapuser = LdapUser.objects.get(username=username)
|
|
|
|
except LdapGroup.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.error("LDAP group with groupname %s does not exist", groupname)
|
2015-01-29 18:31:10 +01:00
|
|
|
except LdapUser.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.error("LDAP user with username %s does not exist", username)
|
2015-01-29 18:31:10 +01:00
|
|
|
else:
|
|
|
|
if ldapuser.username in ldapgroup.members:
|
|
|
|
ldapgroup.members.remove(ldapuser.username)
|
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"removed LDAP user %s from LDAP group %s", ldapuser.dn, ldapgroup.dn
|
|
|
|
)
|
2015-01-29 18:31:10 +01:00
|
|
|
ldapgroup.save()
|
2020-03-03 12:20:13 +01:00
|
|
|
retval["removed"] = True
|
2015-01-29 18:31:10 +01:00
|
|
|
else:
|
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP user %s is not a member of LDAP group %s",
|
|
|
|
ldapuser.dn,
|
|
|
|
ldapgroup.dn,
|
|
|
|
)
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
2014-05-30 18:42:04 +02:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2016-02-07 22:41:36 +01:00
|
|
|
def delete_ldap_user(username, *args, **kwargs):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
|
|
|
This task deletes the given user.
|
|
|
|
|
|
|
|
:param str username: the user name
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary containing the username and a flag :py:const:`deleted`
|
|
|
|
that is set to :py:const:`True` if the user has been deleted and is set
|
|
|
|
to :py:const:`False` otherwise
|
|
|
|
:rtype: dict
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
This variant can only be used at the beginning of a Celery task chain
|
|
|
|
or as a standalone task.
|
|
|
|
|
|
|
|
Use :py:func:`ldaptasks.tasks.delete_ldap_user_chained` at other
|
|
|
|
positions in the task chain
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"username": username, "deleted": False}
|
2014-05-30 18:42:04 +02:00
|
|
|
try:
|
|
|
|
ldapuser = LdapUser.objects.get(username=username)
|
|
|
|
except LdapUser.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("there is no LDAP user with username %s", username)
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(gid=ldapuser.group)
|
|
|
|
except LdapGroup.DoesNotExist:
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP group %s of LDAP user %s does not exist",
|
|
|
|
ldapuser.group,
|
|
|
|
ldapuser.dn,
|
|
|
|
)
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
|
|
|
if ldapuser.username in ldapgroup.members:
|
|
|
|
ldapgroup.members.remove(ldapuser.username)
|
|
|
|
ldapgroup.save()
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"removed LDAP user %s from LDAP group %s", ldapuser.dn, ldapgroup.dn
|
|
|
|
)
|
2015-01-29 18:31:10 +01:00
|
|
|
userdn = ldapuser.dn
|
2014-05-30 18:42:04 +02:00
|
|
|
ldapuser.delete()
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("deleted LDAP user %s", userdn)
|
|
|
|
retval["deleted"] = True
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2016-02-07 22:41:36 +01:00
|
|
|
def delete_ldap_user_chained(previous_result, *args, **kwargs):
|
|
|
|
"""
|
|
|
|
This task deletes the given user.
|
|
|
|
|
|
|
|
:param dict previous_result: a dictionary describing the result of the
|
|
|
|
previous step in the Celery task chain. This dictionary must contain a
|
|
|
|
:py:const:`username` key
|
|
|
|
:return: a copy of the :py:obj:`previous_result` dictionary with a new
|
|
|
|
:py:const:`deleted` key set to :py:const:`True` if the user has been
|
|
|
|
deleted and set to :py:const:`False` otherwise
|
|
|
|
:rtype: dict
|
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
username = previous_result["username"]
|
2016-02-07 22:41:36 +01:00
|
|
|
retval = deepcopy(previous_result)
|
|
|
|
retval.update(delete_ldap_user(username))
|
|
|
|
return retval
|
2014-05-30 18:42:04 +02:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2014-05-30 18:42:04 +02:00
|
|
|
def delete_ldap_group_if_empty(groupname):
|
2014-05-31 15:18:39 +02:00
|
|
|
"""
|
2016-02-07 22:41:36 +01:00
|
|
|
This task deletes the given group if it is empty.
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
:param str groupname: the group name
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary that contains the groupname and a flag
|
|
|
|
:py:const:`deleted` that is set to :py:const:`True` if the group has
|
|
|
|
been deleted and is set to :py:const:`False` otherwise
|
|
|
|
:rtype: dict
|
2014-05-31 15:18:39 +02:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"groupname": groupname, "deleted": False}
|
2014-05-30 18:42:04 +02:00
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(name=groupname)
|
|
|
|
except LdapGroup.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("LDAP group with groupname %s does not exist", groupname)
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
|
|
|
if len(ldapgroup.members) == 0:
|
2015-01-29 18:31:10 +01:00
|
|
|
groupdn = ldapgroup.dn
|
2014-05-30 18:42:04 +02:00
|
|
|
ldapgroup.delete()
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("deleted LDAP group %s", groupdn)
|
|
|
|
retval["deleted"] = True
|
2014-05-30 18:42:04 +02:00
|
|
|
else:
|
2015-01-29 18:31:10 +01:00
|
|
|
_LOGGER.info(
|
2020-03-03 12:20:13 +01:00
|
|
|
"LDAP group %s has not been deleted. It still has %d members",
|
|
|
|
ldapgroup.dn,
|
|
|
|
len(ldapgroup.members),
|
|
|
|
)
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|
2014-12-29 15:04:00 +01:00
|
|
|
|
|
|
|
|
2020-03-03 14:50:03 +01:00
|
|
|
@shared_task(autoretry_for=(DjangoDBUtilsError,), default_retry_delay=10)
|
2014-12-29 15:04:00 +01:00
|
|
|
def delete_ldap_group(groupname):
|
|
|
|
"""
|
2016-02-07 22:41:36 +01:00
|
|
|
This task deletes the given group.
|
2014-12-29 15:04:00 +01:00
|
|
|
|
|
|
|
:param str groupname: the group name
|
2016-02-07 22:41:36 +01:00
|
|
|
:return: dictionary that contains the groupname and a flag
|
|
|
|
:py:const:`deleted` that is set to :py:const:`True` if the group has
|
|
|
|
been deleted and is set to :py:const:`False` otherwise
|
|
|
|
:rtype: dict
|
2014-12-29 15:04:00 +01:00
|
|
|
|
|
|
|
"""
|
2020-03-03 12:20:13 +01:00
|
|
|
retval = {"groupname": groupname, "deleted": False}
|
2014-12-29 15:04:00 +01:00
|
|
|
try:
|
|
|
|
ldapgroup = LdapGroup.objects.get(name=groupname)
|
|
|
|
except LdapGroup.DoesNotExist:
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("LDAP group with name %s does not exist", groupname)
|
2014-12-29 15:04:00 +01:00
|
|
|
else:
|
2015-01-29 18:31:10 +01:00
|
|
|
groupdn = ldapgroup.dn
|
2014-12-29 15:04:00 +01:00
|
|
|
ldapgroup.delete()
|
2020-03-03 12:20:13 +01:00
|
|
|
_LOGGER.info("deleted LDAP group %s", groupdn)
|
|
|
|
retval["deleted"] = True
|
2016-02-07 22:41:36 +01:00
|
|
|
return retval
|