Skip to content

Commit

Permalink
Merge pull request #176 from fsinfuhh/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid authored Oct 13, 2024
2 parents f54424e + a28fbb2 commit 5a6dcef
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mafiasi/registration/management/commands/irz_ldap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from argparse import ArgumentParser
from pprint import pprint

from django.conf import settings
from django.core.management import BaseCommand

from mafiasi.registration import utils


class Command(BaseCommand):
help = "Utilities for querying the IRZ ldap"

def add_arguments(self, parser: ArgumentParser):
argg = parser.add_mutually_exclusive_group(required=True)
argg.add_argument("--group", nargs=1, help="Query for a group by gidNumber")
argg.add_argument("--user", nargs=1, help="Query for a user by uid")

def handle(self, *args, **options):
if options["group"] is not None:
pprint(utils.get_irz_ldap_group(options["group"]))
elif options["user"] is not None:
pprint(utils.get_irz_ldap_entry(options["user"]))
else:
raise ValueError(f"options contains neither a group nor user parameter: {options}")

0 comments on commit 5a6dcef

Please sign in to comment.