From d26f2b0f69724c971ad0952509af4ab23363fe5e Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 30 Aug 2021 18:29:42 +0530 Subject: [PATCH] Normalize/convert ascii/ignore unicode characters for homeDirectory --- utils/ldap_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/ldap_manager.py b/utils/ldap_manager.py index ee190732..fadcdbbe 100644 --- a/utils/ldap_manager.py +++ b/utils/ldap_manager.py @@ -3,6 +3,7 @@ import hashlib import random import ldap3 import logging +import unidecode from django.conf import settings @@ -101,7 +102,7 @@ class LdapManager: "uidNumber": [str(uidNumber)], "gidNumber": [str(settings.LDAP_CUSTOMER_GROUP_ID)], "loginShell": ["/bin/bash"], - "homeDirectory": ["/home/{}".format(user).encode("utf-8")], + "homeDirectory": ["/home/{}".format(unicodedata.normalize('NFKD', user).encode('ascii','ignore'))], "mail": email.encode("utf-8"), "userPassword": [self._ssha_password( password.encode("utf-8")