Commit f3d90a2b authored by PCoder's avatar PCoder

Add utility code to get max UID

Other changes:
- Introduce logging
- Introduce .env config parameters
  - LDAP_SEARCH_BASE: The base used in the LDAP search to find uid
  - IPV6_WORK_USER_GROUP: The LDAP group to which the newly added
      user should belong to
parent 8e071518
......@@ -12,9 +12,12 @@
import os
import ldap
import logging
from decouple import config, Csv
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
logger = logging.getLogger(__name__)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......@@ -207,6 +210,44 @@ LOGGING = {
LDAP_MAX_UID_PATH = os.path.join(
def set_max_uid(max_uid):
a utility function to save max_uid value to a file
:param max_uid: an integer representing the max uid
with open(LDAP_MAX_UID_PATH, 'w+') as handler:
def get_max_uid():
A utility function to read the max uid value that was previously set
:return: An integer representing the max uid value that was previously set
with open(LDAP_MAX_UID_PATH, 'r+') as handler:
return int(
except FileNotFoundError as fnfe:
logger.error("File not found : " + str(fnfe))
ret = config('DEFAULT_START_UID', cast=int, default=10000)
logger.error("So, returing UID={}".format(ret))
if config('ENABLE_DEBUG_LOG', cast=bool, default=False):
loggers_dict = {}
LOGGING['handlers']['file'] = {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment