Replace simplistic check in has_dn_format

Use python-ldap's explode_dn, which (hopefully) rejects invalid DNs.
This commit is contained in:
kaminski_k
2016-03-02 17:59:07 +01:00
parent 13c6566c7f
commit b8a7e6d275

View File

@@ -110,12 +110,14 @@ class LdapUserDir(object):
@staticmethod
def has_dn_format(name):
"""returns true if name has the format of a distinguished name
"""Returns true iff name has the format of a distinguished name
"""
# currently we are satisfied with a very primitive check
if ',' in name:
try:
ldap.explode_dn(name)
except Exception:
return False
else:
return True
return False
@staticmethod
def dn_to_cn(dn):