Replace simplistic check in has_dn_format
Use python-ldap's explode_dn, which (hopefully) rejects invalid DNs.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user