diff --git a/ldapuserdir/ldapuserdir.py b/ldapuserdir/ldapuserdir.py index b8a9534..f324658 100644 --- a/ldapuserdir/ldapuserdir.py +++ b/ldapuserdir/ldapuserdir.py @@ -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):