diff --git a/gen_config.py b/gen_config.py index c3ff0a2b5b8269ab7aca76c5d359757f631401ed..70586e0daa9fe02231d6dd43e117b377aaeaa57d 100755 --- a/gen_config.py +++ b/gen_config.py @@ -6,7 +6,6 @@ import sys import argparse import xml.etree.ElementTree as ET import json -import mpildap def err(msg): print('ERROR: '+msg, file=sys.stderr) @@ -15,7 +14,17 @@ def warn(msg): def info(msg): print(msg) +try: + import mpildap + mpildap_available = True +except ModuleNotFoundError: + warn('mpildap module not available, email normalization will be skipped') + mpildap_available = False + pass + def normalize_email(email): + if not mpildap_available: + return email lp, domain = email.split('@') ldap_mail = mpildap.ldaps(f'&(istEmailName={lp})(istMailDomainReceive={domain})', 'mail', unique=True) if ldap_mail: