Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add management command for irz ldap utils #176

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
Loading